From d4cd61d5b8d9fe9c69a09a15afbccd492479ab3a Mon Sep 17 00:00:00 2001 From: Rob Court Date: Wed, 4 Sep 2024 11:12:39 +0100 Subject: [PATCH 1/2] adding version reporting vfb.__version__ --- src/vfb_connect/cross_server_tools.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/vfb_connect/cross_server_tools.py b/src/vfb_connect/cross_server_tools.py index a43941a9..74c5d41e 100644 --- a/src/vfb_connect/cross_server_tools.py +++ b/src/vfb_connect/cross_server_tools.py @@ -260,6 +260,15 @@ def lookup_id(self, key, return_curie=False, allow_subsitutions=True, subsitutio print(f"\033[31mError:\033[0m Unrecognized value: \033[31m{key}\033[0m") return '' + def __version__(self): + from importlib.metadata import version, PackageNotFoundError + return version('vfb_connect') + try: + return version('vfb_connect') + except PackageNotFoundError: + return '0.0.0' + return '0.0.0' + def get_terms_by_region(self, region, cells_only=False, verbose=False, query_by_label=True, summary=True, return_dataframe=True): """Generate TermInfo reports for all terms relevant to annotating a specific region, optionally limited to cells. From f07ef1123c7b286779e64948a43e804581149e1f Mon Sep 17 00:00:00 2001 From: Rob Court Date: Wed, 4 Sep 2024 11:28:07 +0100 Subject: [PATCH 2/2] handling network issues on get_images --- src/vfb_connect/neo/query_wrapper.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/vfb_connect/neo/query_wrapper.py b/src/vfb_connect/neo/query_wrapper.py index b9262657..8b0698c4 100644 --- a/src/vfb_connect/neo/query_wrapper.py +++ b/src/vfb_connect/neo/query_wrapper.py @@ -329,8 +329,11 @@ def get_images(self, short_forms: iter, template, image_folder, image_type='swc' continue for imv in image_matches: if imv['template_anatomy']['label'] == template: - r = requests.get(imv['image_folder'] + '/volume.' + image_type) - ### Slightly dodgy warning - could mask network errors + try: + r = requests.get(imv['image_folder'] + '/volume.' + image_type) + except requests.exceptions.RequestException as e: + print(f"\033[33mWarning:\033[0m No '{image_type}' file found for '{label}'. Error: {e}") + continue if not r.ok: print("33mWarning:\033[0m No '%s' file found for '%s'." % (image_type, label)) continue