Example #1
0
def create_ephyspc_params(force=False, silent=False):
    if Path(params.getfile("ephyspc_params")).exists() and not force:
        print(f"{params.getfile('ephyspc_params')} exists already, exiting...")
        print(Path(params.getfile("ephyspc_params")).exists())
        return
    if silent:
        data_folder_path = r"D:\iblrig_data\Subjects"
        remote_data_folder_path = r"\\iblserver.champalimaud.pt\ibldata\Subjects"
        probe_type_00 = "3A"
        probe_type_01 = "3B"
    else:
        data_folder_path = cli_ask_default(
            r"Where's your LOCAL 'Subjects' data folder?",
            r"D:\iblrig_data\Subjects")
        remote_data_folder_path = cli_ask_default(
            r"Where's your REMOTE 'Subjects' data folder?",
            r"\\iblserver.champalimaud.pt\ibldata\Subjects",
        )
        probe_type_00 = cli_ask_options("What's the type of PROBE 00?",
                                        ["3A", "3B"])
        probe_type_01 = cli_ask_options("What's the type of PROBE 01?",
                                        ["3A", "3B"])
    param_dict = {
        "DATA_FOLDER_PATH": data_folder_path,
        "REMOTE_DATA_FOLDER_PATH": remote_data_folder_path,
        "PROBE_TYPE_00": probe_type_00,
        "PROBE_TYPE_01": probe_type_01,
    }
    params.write("ephyspc_params", param_dict)
    print(f"Created {params.getfile('ephyspc_params')}")
    print(param_dict)
    return param_dict
Example #2
0
def create_videopc_params(force=False):
    if Path(params.getfile('videopc_params')).exists() and not force:
        print(f"{params.getfile('videopc_params')} exists already, exiting...")
        print(Path(params.getfile('videopc_params')).exists())
        return
    data_folder_path = cli_ask_default(
        r"Where's your LOCAL 'Subjects' data folder?",
        r"D:\iblrig_data\Subjects")
    remote_data_folder_path = cli_ask_default(
        r"Where's your REMOTE 'Subjects' data folder?",
        r"\\iblserver.champalimaud.pt\ibldata\Subjects")
    body_cam_idx = cli_ask_default(
        "Please select the index of the BODY camera", '0')
    left_cam_idx = cli_ask_default(
        "Please select the index of the LEFT camera", '1')
    right_cam_idx = cli_ask_default(
        "Please select the index of the RIGHT camera", '2')

    param_dict = {
        'DATA_FOLDER_PATH': data_folder_path,
        'REMOTE_DATA_FOLDER_PATH': remote_data_folder_path,
        'BODY_CAM_IDX': body_cam_idx,
        'LEFT_CAM_IDX': left_cam_idx,
        'RIGHT_CAM_IDX': right_cam_idx,
    }
    params.write('videopc_params', param_dict)
    print(f"Created {params.getfile('videopc_params')}")
    print(param_dict)
    return param_dict
Example #3
0
def create_ephyspc_params(force=False):
    if Path(params.getfile('ephyspc_params')).exists() and not force:
        print(f"{params.getfile('ephyspc_params')} exists already, exiting...")
        print(Path(params.getfile('ephyspc_params')).exists())
        return
    data_folder_path = cli_ask_default(
        r"Where's your LOCAL 'Subjects' data folder?",
        r"D:\iblrig_data\Subjects")
    remote_data_folder_path = cli_ask_default(
        r"Where's your REMOTE 'Subjects' data folder?",
        r"\\iblserver.champalimaud.pt\ibldata\Subjects")
    probe_type_00 = cli_ask_options("What's the type of PROBE 00?",
                                    ['3A', '3B'])
    probe_type_01 = cli_ask_options("What's the type of PROBE 01?",
                                    ['3A', '3B'])
    param_dict = {
        'DATA_FOLDER_PATH': data_folder_path,
        'REMOTE_DATA_FOLDER_PATH': remote_data_folder_path,
        'PROBE_TYPE_00': probe_type_00,
        'PROBE_TYPE_01': probe_type_01,
    }
    params.write('ephyspc_params', param_dict)
    print(f"Created {params.getfile('ephyspc_params')}")
    print(param_dict)
    return param_dict
Example #4
0
 def test_param_get_file(self):
     home_dir = Path(params.getfile("toto")).parent
     # straight case the file is .{str} in the home directory
     assert home_dir.joinpath(".toto") == Path(params.getfile("toto"))
     # straight case the file is .{str} in the home directory
     assert home_dir.joinpath(".toto") == Path(params.getfile(".toto"))
     # subfolder case
     assert home_dir.joinpath(".toto", ".titi") == Path(params.getfile("toto/titi"))
Example #5
0
def setup():
    par_default = default()
    par_current = iopar.read(_PAR_ID_STR, par_default)

    par = iopar.as_dict(par_default)
    for k in par.keys():
        cpar = _get_current_par(k, par_current)
        if "PWD" not in k:
            par[k] = input("Param " + k + ",  current value is [" + str(cpar) +
                           "]:") or cpar

    cpar = _get_current_par("ALYX_PWD", par_current)
    prompt = "Enter the Alyx password for " + par[
        "ALYX_LOGIN"] + '(leave empty to keep current):'
    par["ALYX_PWD"] = getpass(prompt) or cpar

    cpar = _get_current_par("HTTP_DATA_SERVER_PWD", par_current)
    prompt = "Enter the FlatIron HTTP password for " + par["HTTP_DATA_SERVER_LOGIN"] +\
             '(leave empty to keep current): '
    par["HTTP_DATA_SERVER_PWD"] = getpass(prompt) or cpar

    # default to home dir if empty dir somehow made it here
    if len(par['CACHE_DIR']) == 0:
        par['CACHE_DIR'] = str(Path.home() / "Downloads" / "FlatIron")

    par = iopar.from_dict(par)

    # create directory if needed
    if par.CACHE_DIR and not os.path.isdir(par.CACHE_DIR):
        os.mkdir(par.CACHE_DIR)
    iopar.write(_PAR_ID_STR, par)
    print('ONE Parameter file location: ' + iopar.getfile(_PAR_ID_STR))
Example #6
0
def load_params_dict(params_fname: str) -> dict:
    params_fpath = Path(params.getfile(params_fname))
    if not params_fpath.exists():
        return None
    with open(params_fpath, 'r') as f:
        out = json.load(f)
    return out
Example #7
0
File: alyx.py Project: k1o0/iblrig
def create_session(session_folder):
    pfile = Path(lib_params.getfile("lib_params"))
    if not pfile.exists():
        oneibl.params.setup_alyx_params()

    flags.create_create_flags(session_folder)
    create(session_folder, dry=False)
Example #8
0
def create_session(session_folder, one=None):
    one = one or ONE()
    pfile = Path(lib_params.getfile("one_params"))
    if not pfile.exists():
        oneibl.params.setup_alyx_params()

    RegistrationClient(one=one).register_session(session_folder,
                                                 file_list=False)
Example #9
0
 def setUp(self):
     self.par_current = params.default()
     self.par_default = params.default()
     self.existing_params = Path(iopar.getfile(params._PAR_ID_STR))
     self.bk_params = self.existing_params.parent.joinpath('.one_params_bk')
     if self.existing_params.exists():
         shutil.copy(self.existing_params, self.bk_params)
         self.existing_params.unlink()
Example #10
0
def create_videopc_params(force=False, silent=False):
    if Path(params.getfile("videopc_params")).exists() and not force:
        print(f"{params.getfile('videopc_params')} exists already, exiting...")
        print(Path(params.getfile("videopc_params")).exists())
        return
    if silent:
        data_folder_path = r"D:\iblrig_data\Subjects"
        remote_data_folder_path = r"\\iblserver.champalimaud.pt\ibldata\Subjects"
        body_cam_idx = 0
        left_cam_idx = 1
        right_cam_idx = 2
    else:
        data_folder_path = cli_ask_default(
            r"Where's your LOCAL 'Subjects' data folder?",
            r"D:\iblrig_data\Subjects")
        remote_data_folder_path = cli_ask_default(
            r"Where's your REMOTE 'Subjects' data folder?",
            r"\\iblserver.champalimaud.pt\ibldata\Subjects",
        )
        body_cam_idx = cli_ask_default(
            "Please select the index of the BODY camera", "0")
        left_cam_idx = cli_ask_default(
            "Please select the index of the LEFT camera", "1")
        right_cam_idx = cli_ask_default(
            "Please select the index of the RIGHT camera", "2")

    param_dict = {
        "DATA_FOLDER_PATH": data_folder_path,
        "REMOTE_DATA_FOLDER_PATH": remote_data_folder_path,
        "BODY_CAM_IDX": body_cam_idx,
        "LEFT_CAM_IDX": left_cam_idx,
        "RIGHT_CAM_IDX": right_cam_idx,
    }
    params.write("videopc_params", param_dict)
    print(f"Created {params.getfile('videopc_params')}")
    print(param_dict)
    return param_dict
Example #11
0
 def test_new_default_param(self):
     # in this case an updated version of the codes brings in a new parameter
     default = {
         'A': 'tata2',
         'O': 'toto2',
         'I': 'titi2',
         'E': 'tete2',
         'num': 15,
         'liste': [1, 'turlu']
     }
     expected_result = {
         'A': 'tata',
         'O': 'toto',
         'I': 'titi',
         'num': 15,
         'liste': [1, 'turlu'],
         'apath': str(Path('/gna/gna/gna')),
         'E': 'tete2',
     }
     par2 = params.read('toto', default=default)
     self.assertCountEqual(par2.as_dict(), expected_result)
     # on the next path the parameter has been added to the param file
     par2 = params.read('toto', default=default)
     self.assertCountEqual(par2.as_dict(), expected_result)
     # check that it doesn't break if a named tuple is given instead of a dict
     par3 = params.read('toto', default=par2)
     self.assertEqual(par2, par3)
     # check that a non-existing parfile raises error
     pstring = str(uuid.uuid4())
     with self.assertRaises(FileNotFoundError):
         params.read(pstring)
     # check that a non-existing parfile with default returns default
     par = params.read(pstring, default=default)
     self.assertCountEqual(par, params.from_dict(default))
     # even if this default is a Params named tuple
     par = params.read(pstring, default=par)
     self.assertEqual(par, params.from_dict(default))
     # check default empty dict
     pstring = 'foobar'
     filename = Path(params.getfile(pstring))
     self.assertFalse(filename.exists())
     par = params.read(pstring, default={})
     self.assertIsNone(par)
     self.assertTrue(filename.exists())
Example #12
0
 def tearDown(self):
     # at last delete the param file
     os.remove(params.getfile('toto'))
Example #13
0
def main():
    pfile = Path(params.getfile("one_params"))
    if not pfile.exists():
        oneibl.params.setup_alyx_params()

    RegistrationClient(one=None).create_sessions(IBLRIG_DATA, dry=False)
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Author: Niccolò Bonacchi
# @Date: Thursday, May 2nd 2019, 5:41:56 pm
import argparse
import datetime
from pathlib import Path

import ibllib.io.params as params
from alf.folders import next_num_folder

EPHYSPC_PARAMS_FILE = Path(params.getfile('ephyspc_params'))


def load_ephyspc_params():
    if not EPHYSPC_PARAMS_FILE.exists():
        create_ephyspc_params()

    return params.read('ephyspc_params')


def create_ephyspc_params():
    if EPHYSPC_PARAMS_FILE.exists():
        print(f"{EPHYSPC_PARAMS_FILE} exists already, exiting...")
        return
    else:
        default = " [default: {}]: "
        data_folder_path = input(r"Where's your 'Subjects' data folder?" +
                                 default.format(r"C:\iblrig_data\Subjects")
                                 ) or r"C:\iblrig_data\Subjects"
Example #15
0
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Author: Niccolò Bonacchi
# @Date: Thursday, May 2nd 2019, 5:41:56 pm
import argparse
import datetime
from pathlib import Path
import subprocess

import ibllib.io.params as params
from alf.folders import next_num_folder
import config_cameras as cams

VIDEOPC_PARAMS_FILE = Path(params.getfile('videopc_params'))


def load_videopc_params():
    if not VIDEOPC_PARAMS_FILE.exists():
        create_videopc_params()

    return params.read('videopc_params')


def create_videopc_params():
    if VIDEOPC_PARAMS_FILE.exists():
        print(f"{VIDEOPC_PARAMS_FILE} exists already, exiting...")
        return
    else:
        default = " [default: {}]: "
        data_folder_path = input(r"Where's your 'Subjects' data folder?" +
                                 default.format(r"C:\iblrig_data\Subjects")
Example #16
0
 def tearDown(self):
     # at last delete the param file
     Path(params.getfile('toto')).unlink(missing_ok=True)
     Path(params.getfile('foobar')).unlink(missing_ok=True)
Example #17
0
def main():
    pfile = Path(params.getfile('one_params'))
    if not pfile.exists():
        oneibl.params.setup_alyx_params()

    create(IBLRIG_DATA, dry=False)