ibllib.io.session_params
A module for handling experiment description files.
Each device computer adds its piece of information and consolidates into the final acquisition description.
- The purpose is 3-fold:
provide modularity in the extraction: the acquisition description allows to dynamically build
pipelines. - assist the copying of the experimental data from device computers to the server computers, in a way that each device is independent from another. - assist the copying of the experimental data from device computers to the server computers, in a way that intermediate states (failed copies) are easily recoverable from and completion criteria (ie. session ready to extract) is objective and simple (all device files copied).
- INGRESS
each device computer needs to know the session path on the server.
create a device file locally in a queue directory. This will serve as a copy flag.
copy the device file to the local server.
- EGRESS
- got through the queue and for each item:
if the device file is not on the server create it.
once copy is complete aggregate the qc from file.
Functions
Add the contents of a device file to the main acquisition description file. |
|
Copy acquisition description yaml to the server and local transfers folder. |
|
Load an experiment description file. |
|
:param session_path : pathlib.Path, str :param ad: :return: pathlib.Path: yaml full file path |
|
Write a device file. |
- write_yaml(file_path, data)[source]
Write a device file. This is basically just a yaml dump that ensures the folder tree exists.
- Parameters
file_path (pathlib.Path) – The full path to the description yaml file to write to.
data (dict) – The data to write to the yaml file.
- write_params(session_path, data) Path [source]
:param session_path : pathlib.Path, str :param ad: :return: pathlib.Path: yaml full file path
- read_params(path) dict [source]
Load an experiment description file.
In addition to reading the yaml data, this functions ensures that the specification is the most recent one. If the file is missing None is returned. If the file cannot be parsed an empty dict is returned.
- Parameters
path (pathlib.Path, str) – The path to the description yaml file (or it’s containing folder) to load.
- Returns
The parsed yaml data, or None if the file was not found.
- Return type
dict, None
Examples
# Load a session’s _ibl_experiment.description.yaml file
>>> data = read_params('/home/data/subject/2020-01-01/001')
# Load a specific device’s description file
>>> data = read_params('/home/data/subject/2020-01-01/001/_devices/behaviour.yaml')
- aggregate_device(file_device, file_acquisition_description, unlink=False)[source]
Add the contents of a device file to the main acquisition description file.
- Parameters
file_device (pathlib.Path) – The full path to the device yaml file to add to the main description file.
file_acquisition_description (pathlib.Path) – The full path to the main acquisition description yaml file to add the device file to.
unlink (bool) – If True, the device file is removed after successfully aggregation.
- Raises
AssertionError – Device file contains a main ‘sync’ key that is already present in the main description file. For an experiment only one main sync device is allowed.