Skip to content

Commit 3394ea0

Browse files
committed
Change test, fig no longer created when data missing
1 parent e555c75 commit 3394ea0

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

ibllib/plots/figures.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -701,19 +701,23 @@ def dlc_qc_plot(session_path, one=None):
701701
data[f'{cam}_frame'] = get_video_frame(video_path, frame_number=5 * 60 * SAMPLING[cam])[:, :, 0]
702702
# If not, try to stream a frame (try three times)
703703
else:
704-
video_url = url_from_eid(one.path2eid(session_path), one=one)[cam]
705-
for tries in range(3):
706-
try:
707-
data[f'{cam}_frame'] = get_video_frame(video_url, frame_number=5 * 60 * SAMPLING[cam])[:, :, 0]
708-
break
709-
except BaseException:
710-
if tries < 2:
711-
tries += 1
712-
logger.info(f"Streaming {cam} video failed, retrying x{tries}")
713-
time.sleep(30)
714-
else:
715-
logger.warning(f"Could not load video frame for {cam} cam. Skipping trace on frame.")
716-
data[f'{cam}_frame'] = None
704+
try:
705+
video_url = url_from_eid(one.path2eid(session_path), one=one)[cam]
706+
for tries in range(3):
707+
try:
708+
data[f'{cam}_frame'] = get_video_frame(video_url, frame_number=5 * 60 * SAMPLING[cam])[:, :, 0]
709+
break
710+
except BaseException:
711+
if tries < 2:
712+
tries += 1
713+
logger.info(f"Streaming {cam} video failed, retrying x{tries}")
714+
time.sleep(30)
715+
else:
716+
logger.warning(f"Could not load video frame for {cam} cam. Skipping trace on frame.")
717+
data[f'{cam}_frame'] = None
718+
except KeyError:
719+
logger.warning(f"Could not load video frame for {cam} cam. Skipping trace on frame.")
720+
data[f'{cam}_frame'] = None
717721
# Other camera associated data
718722
for feat in ['dlc', 'times', 'features', 'ROIMotionEnergy']:
719723
# Check locally first, then try to load from alyx, if nothing works, set to None

ibllib/tests/test_plots.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ def tearDownClass(cls):
148148

149149
def test_without_inputs(self):
150150
eid = '3473f9d2-aa5d-41a6-9048-c65d0b7ab97c'
151-
with self.assertLogs('ibllib', 'WARNING'):
152-
fig = dlc_qc_plot(eid, self.one)
153-
fig_path = (Path(self.tmp_dir.name).joinpath('dlc_qc_plot.png'))
154-
fig.savefig(fig_path)
155-
with Image.open(fig_path) as im:
156-
self.assertEqual(im.size, (1700, 1000))
151+
with self.assertRaises(AssertionError):
152+
fig = dlc_qc_plot(self.one.eid2path(eid), self.one)
153+
# fig_path = (Path(self.tmp_dir.name).joinpath('dlc_qc_plot.png'))
154+
# fig.savefig(fig_path)
155+
# with Image.open(fig_path) as im:
156+
# self.assertEqual(im.size, (1700, 1000))

0 commit comments

Comments
 (0)