From f30cc2fcfcaa7c361c53ae436871082e14677478 Mon Sep 17 00:00:00 2001 From: Dan Birman Date: Fri, 15 Nov 2024 09:05:22 -0800 Subject: [PATCH] fix: fixing errors that were crashing functional QC objects --- src/aind_qc_portal/panel/custom_metrics.py | 2 +- src/aind_qc_portal/panel/media.py | 5 ++++- src/aind_qc_portal/panel/quality_control.py | 7 ++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/aind_qc_portal/panel/custom_metrics.py b/src/aind_qc_portal/panel/custom_metrics.py index b80e08b..6b59a4f 100644 --- a/src/aind_qc_portal/panel/custom_metrics.py +++ b/src/aind_qc_portal/panel/custom_metrics.py @@ -114,4 +114,4 @@ def _checkbox_helper(self, data: dict): self._panel.param.watch(self._callback_helper, "value") def _rulebased_helper(self, data: dict): - self._panel = pn.widgets.StaticText("Todo") + self._panel = pn.widgets.StaticText(value="Todo") diff --git a/src/aind_qc_portal/panel/media.py b/src/aind_qc_portal/panel/media.py index b6830d2..594a508 100644 --- a/src/aind_qc_portal/panel/media.py +++ b/src/aind_qc_portal/panel/media.py @@ -2,6 +2,7 @@ from io import BytesIO from urllib.parse import urlparse import param +from pathlib import Path from panel.reactive import ReactiveHTML CSS = """ @@ -150,10 +151,12 @@ def parse_reference(self, reference): return _get_s3_asset(self.parent.s3_client, bucket, key) elif "png" in reference: + print(self.parent.s3_bucket) + print(Path(self.parent.s3_prefix) / reference) return _get_s3_asset( self.parent.s3_client, self.parent.s3_bucket, - self.parent.s3_prefix + reference, + str(Path(self.parent.s3_prefix) / reference), ) elif reference == "ecephys-drift-map": diff --git a/src/aind_qc_portal/panel/quality_control.py b/src/aind_qc_portal/panel/quality_control.py index 188bf88..2d851b2 100644 --- a/src/aind_qc_portal/panel/quality_control.py +++ b/src/aind_qc_portal/panel/quality_control.py @@ -70,11 +70,16 @@ def get_data(self): else: return - if "data_description" in json_data: + if "data_description" in json_data and json_data["data_description"] and "modality" in json_data["data_description"]: self.modalities = [ modality["abbreviation"] for modality in json_data["data_description"]["modality"] ] + else: + # fallback: pull the modality from the name + self.modalities = [ + json_data["name"].split("_")[0] + ] s3_location = json_data.get("location", None) if s3_location: