Skip to content

Commit

Permalink
Register inputs without rename in RegisterSnapshots (#861)
Browse files Browse the repository at this point in the history
* Register inputs without rename in RegisterSnapshots
* Short circuit when output_files signature empty
  • Loading branch information
k1o0 authored Oct 8, 2024
1 parent 2365a7c commit ae6c886
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ibllib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import warnings

__version__ = '2.39.rc1'
__version__ = '2.39.rc2'
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
Expand Down
3 changes: 3 additions & 0 deletions ibllib/pipes/base_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,9 @@ def register_snapshots(self, unlink=False, collection=None):

def _run(self, **kwargs):
self.rename_files(**kwargs)
if not self.output_files:
return []

# FIXME Can be done with Task.assert_expected_outputs
ok, out_files, missing = map(flatten, zip(*map(lambda x: x.find_files(self.session_path), self.output_files)))
if not ok:
Expand Down
15 changes: 7 additions & 8 deletions ibllib/pipes/mesoscope_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,12 @@ class MesoscopeRegisterSnapshots(base_tasks.MesoscopeTask, base_tasks.RegisterRa

@property
def signature(self):
I = ExpectedDataset.input # noqa
signature = {
'input_files': [('referenceImage.raw.tif', f'{self.device_collection}/reference', False),
('referenceImage.stack.tif', f'{self.device_collection}/reference', False),
('referenceImage.meta.json', f'{self.device_collection}/reference', False)],
'output_files': [('referenceImage.raw.tif', f'{self.device_collection}/reference', False),
('referenceImage.stack.tif', f'{self.device_collection}/reference', False),
('referenceImage.meta.json', f'{self.device_collection}/reference', False)]
'input_files': [I('referenceImage.raw.tif', f'{self.device_collection}/reference', False, register=True),
I('referenceImage.stack.tif', f'{self.device_collection}/reference', False, register=True),
I('referenceImage.meta.json', f'{self.device_collection}/reference', False, register=True)],
'output_files': []
}
return signature

Expand All @@ -77,8 +76,8 @@ def _run(self):
list of pathlib.Path containing renamed reference image.
"""
# Assert that only one tif file exists per collection
file, collection, _ = self.signature['input_files'][0]
reference_images = list(self.session_path.rglob(f'{collection}/{file}'))
dsets = dataset_from_name('referenceImage.raw.tif', self.input_files)
reference_images = list(chain.from_iterable(map(lambda x: x.find_files(self.session_path)[1], dsets)))
assert len(set(x.parent for x in reference_images)) == len(reference_images)
# Rename the reference images
out_files = super()._run()
Expand Down

0 comments on commit ae6c886

Please sign in to comment.