Skip to content

Commit e5eb52a

Browse files
committed
Try to find data for dlc qc locally first
1 parent 65af4b4 commit e5eb52a

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

ibllib/qc/dlc.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from ibllib.qc import base
1616
import one.alf.io as alfio
17+
from one.alf.exceptions import ALFObjectNotFound
1718
from one.alf.spec import is_session_path
1819
from iblutil.util import Bunch
1920

@@ -23,7 +24,6 @@
2324
class DlcQC(base.QC):
2425
"""A class for computing camera QC metrics"""
2526

26-
dstypes = ['camera.dlc', 'camera.times']
2727
bbox = {
2828
'body': {
2929
'xrange': range(201, 500),
@@ -96,15 +96,18 @@ def _ensure_required_data(self):
9696
it an exception is raised.
9797
:return:
9898
"""
99-
assert self.one is not None, 'ONE required to download data'
100-
for dstype in self.dstypes:
101-
dataset = self.one.type2datasets(self.eid, dstype, details=True)
102-
present = (
103-
self.one._download_datasets(dataset)
104-
if self.download_data
105-
else (next(self.session_path.rglob(d), None) for d in dataset['rel_path'] if self.side in d)
106-
)
107-
assert (not dataset.empty and all(present)), f'Dataset {dstype} not found'
99+
# Check if data available locally
100+
for ds in [f'_ibl_{self.side}Camera.dlc.*', f'_ibl_{self.side}Camera.times.*']:
101+
if not next(self.session_path.rglob(ds), None):
102+
# If download is allowed, try to download
103+
if self.download_data is True:
104+
assert self.one is not None, 'ONE required to download data'
105+
try:
106+
self.one.load_dataset(self.eid, ds, download_only=True)
107+
except ALFObjectNotFound:
108+
raise AssertionError(f'Dataset {ds} not found locally and failed to download')
109+
else:
110+
raise AssertionError(f'Dataset {ds} not found locally and download_data is False')
108111

109112
def run(self, update: bool = False, **kwargs) -> (str, dict):
110113
"""

0 commit comments

Comments
 (0)