From f172f4a6b9eb1ce970e3c6fde22bc48b12f76c84 Mon Sep 17 00:00:00 2001 From: "isaak.willett@alleninstitute.org" Date: Thu, 20 Feb 2020 12:51:57 -0800 Subject: [PATCH 1/2] Fixed bug requiring additional IDs for BehaviorDataLimsApi Previously BehaviorDataLimsApi would raise an exception if no container id was returned from lims id for given ophys id. This has been changed at allenskd/internal/api/behavior_data_lims_api.py 105 - 108. Now the query will return None for the container id if the query results in an empty list return. Resolves: #1354 --- allensdk/internal/api/behavior_data_lims_api.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/allensdk/internal/api/behavior_data_lims_api.py b/allensdk/internal/api/behavior_data_lims_api.py index 3c544632f..00d71ddd8 100644 --- a/allensdk/internal/api/behavior_data_lims_api.py +++ b/allensdk/internal/api/behavior_data_lims_api.py @@ -102,7 +102,10 @@ def _get_ids(self) -> Dict[str, Optional[Union[int, List[int]]]]: WHERE ophys_experiment_id IN ({",".join(set(map(str, oed)))}); """ - container_id = self.lims_db.fetchone(container_query, strict=True) + try: + container_id = self.lims_db.fetchone(container_query, strict=True) + except OneResultExpectedError: + container_id = None ids_dict.update({"ophys_experiment_ids": oed, "ophys_container_id": container_id}) From 08808db5bedbde7e4285c48ae695417f6ded092f Mon Sep 17 00:00:00 2001 From: "isaak.willett@alleninstitute.org" Date: Thu, 20 Feb 2020 14:21:05 -0800 Subject: [PATCH 2/2] Return None instead of empty list if there are no ophys_experiment_ids --- allensdk/internal/api/behavior_data_lims_api.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/allensdk/internal/api/behavior_data_lims_api.py b/allensdk/internal/api/behavior_data_lims_api.py index 00d71ddd8..a2d7087b3 100644 --- a/allensdk/internal/api/behavior_data_lims_api.py +++ b/allensdk/internal/api/behavior_data_lims_api.py @@ -93,6 +93,8 @@ def _get_ids(self) -> Dict[str, Optional[Union[int, List[int]]]]: WHERE ophys_session_id = {ids_dict["ophys_session_id"]}; """ oed = self.lims_db.fetchall(oed_query) + if len(oed) == 0: + oed = None container_query = f""" SELECT DISTINCT