From 7517763b008c04717967a72f2a6542c41a62fc3d Mon Sep 17 00:00:00 2001 From: olivier Date: Fri, 15 Sep 2023 16:36:18 +0100 Subject: [PATCH 1/2] bugfix: listing of collections do not skip repeat protocols in acqusition description --- ibllib/__init__.py | 2 +- ibllib/io/session_params.py | 26 +++++++++++++++++++++++--- ibllib/tests/test_io.py | 10 ++++++++++ release_notes.md | 4 +++- 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/ibllib/__init__.py b/ibllib/__init__.py index a588ec46c..79d4d537a 100644 --- a/ibllib/__init__.py +++ b/ibllib/__init__.py @@ -2,7 +2,7 @@ import logging import warnings -__version__ = '2.25.1' +__version__ = '2.25.2' warnings.filterwarnings('always', category=DeprecationWarning, module='ibllib') # if this becomes a full-blown library we should let the logging configuration to the discretion of the dev diff --git a/ibllib/io/session_params.py b/ibllib/io/session_params.py index a15802a3f..34e668ced 100644 --- a/ibllib/io/session_params.py +++ b/ibllib/io/session_params.py @@ -382,7 +382,7 @@ def get_task_protocol_number(sess_params, task_protocol=None): return (next(iter(numbers)) if len(numbers) == 1 else numbers) or None -def get_collections(sess_params): +def get_collections(sess_params, flat=False): """ Find all collections associated with the session. @@ -390,12 +390,17 @@ def get_collections(sess_params): ---------- sess_params : dict The loaded experiment description map. + flat : bool (False) + If True, return a flat list of unique collections, otherwise return a map of device/sync/task Returns ------- dict[str, str] A map of device/sync/task and the corresponding collection name. + list[str] + A flat list of unique collection names. + Notes ----- - Assumes only the following data types contained: list, dict, None, str. @@ -408,12 +413,27 @@ def iter_dict(d): for d in filter(lambda x: isinstance(x, dict), v): iter_dict(d) elif isinstance(v, dict) and 'collection' in v: - collection_map[k] = v['collection'] + print(k) + # if the key already exists, append the collection name to the list + if k in collection_map: + clist = collection_map[k] if isinstance(collection_map[k], list) else [collection_map[k]] + collection_map[k] = list(set(clist + [v['collection']])) + else: + collection_map[k] = v['collection'] elif isinstance(v, dict): iter_dict(v) iter_dict(sess_params) - return collection_map + if flat: + cflat = [] + for k, v in collection_map.items(): + if isinstance(v, list): + cflat.extend(v) + else: + cflat.append(v) + return list(set(cflat)) + else: + return collection_map def get_video_compressed(sess_params): diff --git a/ibllib/tests/test_io.py b/ibllib/tests/test_io.py index 967a88d32..4cb0dba46 100644 --- a/ibllib/tests/test_io.py +++ b/ibllib/tests/test_io.py @@ -578,6 +578,16 @@ def test_get_collections(self): } self.assertCountEqual(expected, collections) + def test_get_collections_repeat_protocols(self): + tasks = dict(tasks=[ + {'passiveChoiceWorld': {'collection': 'raw_passive_data', 'sync_label': 'bpod'}}, + {'ephysChoiceWorld': {'collection': 'raw_behavior_data', 'sync_label': 'bpod'}}, + {'passiveChoiceWorld': {'collection': 'raw_passive_data_bis'}}]) + collections = session_params.get_collections(tasks) + self.assertEqual(set(collections['passiveChoiceWorld']), set(['raw_passive_data_bis', 'raw_passive_data'])) + collections = session_params.get_collections(tasks, flat=True) + self.assertEqual(set(collections), set(['raw_passive_data_bis', 'raw_passive_data', 'raw_behavior_data'])) + class TestRawDaqLoaders(unittest.TestCase): """Tests for raw_daq_loaders module""" diff --git a/release_notes.md b/release_notes.md index 5262c7b59..7e1552106 100644 --- a/release_notes.md +++ b/release_notes.md @@ -8,7 +8,9 @@ ### bugfixes - fix for untrainable, unbiasable don't repolulate if already exists ### 2.25.1 -- relax assertion on Neuropixel channel mappings to allow for personal projects +- relax assertion on Neuropixel channel mappings to allow for personal projects +### 2.25.2 +- listing of all collections does not skip repeat task protocols anymore for copy/extraction ## Release Notes 2.23 ### Release Notes 2.23.1 2023-06-15 From 7f62b4ce66b6e2d154f77a74034c0a4b96a0fa55 Mon Sep 17 00:00:00 2001 From: olivier Date: Thu, 21 Sep 2023 12:58:40 +0100 Subject: [PATCH 2/2] add ibl-neuropixel 0.8.1 requirement --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 3f49398c7..ed29169af 100644 --- a/requirements.txt +++ b/requirements.txt @@ -23,7 +23,7 @@ sparse seaborn>=0.9.0 tqdm>=4.32.1 # ibl libraries -ibl-neuropixel>=0.8.0 +ibl-neuropixel>=0.8.1 iblutil>=1.7.0 labcams # widefield extractor ONE-api>=2.2