From bf9a5d97f24a3dcbc65619803e3853c75fab9c68 Mon Sep 17 00:00:00 2001 From: Keith Wiley Date: Fri, 20 Dec 2024 11:56:20 -0800 Subject: [PATCH 1/2] SkeletonClient retrieves valid skeleton versions from server instead of having them hard-coded. No future updates necessary when new versions are introduced. --- caveclient/skeletonservice.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/caveclient/skeletonservice.py b/caveclient/skeletonservice.py index bb6a535d..5d9a0605 100644 --- a/caveclient/skeletonservice.py +++ b/caveclient/skeletonservice.py @@ -362,10 +362,10 @@ def get_cache_contents( datastack_name = self._datastack_name assert datastack_name is not None - valid_skeleton_versions = [-1, 0, 1, 2, 3] - if skeleton_version not in valid_skeleton_versions: + skeleton_versions = self.get_versions() + if skeleton_version not in skeleton_versions: raise ValueError( - f"Unknown skeleton version: {skeleton_version}. Valid options: {valid_skeleton_versions}" + f"Unknown skeleton version: {skeleton_version}. Valid options: {skeleton_versions}" ) if isinstance(root_id_prefixes, int): @@ -408,10 +408,10 @@ def skeletons_exist( datastack_name = self._datastack_name assert datastack_name is not None - valid_skeleton_versions = [-1, 0, 1, 2, 3] - if skeleton_version not in valid_skeleton_versions: + skeleton_versions = self.get_versions() + if skeleton_version not in skeleton_versions: raise ValueError( - f"Unknown skeleton version: {skeleton_version}. Valid options: {valid_skeleton_versions}" + f"Unknown skeleton version: {skeleton_version}. Valid options: {skeleton_versions}" ) if isinstance(root_ids, int): @@ -540,10 +540,10 @@ def get_skeleton( elif output_format == "swc": endpoint_format = "swccompressed" - valid_skeleton_versions = [-1, 0, 1, 2, 3] - if skeleton_version not in valid_skeleton_versions: + skeleton_versions = self.get_versions() + if skeleton_version not in skeleton_versions: raise ValueError( - f"Unknown skeleton version: {skeleton_version}. Valid options: {valid_skeleton_versions}" + f"Unknown skeleton version: {skeleton_version}. Valid options: {skeleton_versions}" ) if verbose_level >= 1: @@ -650,10 +650,10 @@ def get_bulk_skeletons( elif output_format == "swc": endpoint_format = "swccompressed" - valid_skeleton_versions = [-1, 0, 1, 2, 3] - if skeleton_version not in valid_skeleton_versions: + skeleton_versions = self.get_versions() + if skeleton_version not in skeleton_versions: raise ValueError( - f"Unknown skeleton version: {skeleton_version}. Valid options: {valid_skeleton_versions}" + f"Unknown skeleton version: {skeleton_version}. Valid options: {skeleton_versions}" ) url = self._build_bulk_endpoint( From c777dae47e7196e19c8c79b2c56c02c1c2b2dbc6 Mon Sep 17 00:00:00 2001 From: Keith Wiley Date: Fri, 20 Dec 2024 12:35:40 -0800 Subject: [PATCH 2/2] ruff cleanup --- caveclient/skeletonservice.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/caveclient/skeletonservice.py b/caveclient/skeletonservice.py index 5d9a0605..4ca6d25c 100644 --- a/caveclient/skeletonservice.py +++ b/caveclient/skeletonservice.py @@ -418,7 +418,9 @@ def skeletons_exist( root_ids = str(root_ids) if isinstance(root_ids, np.ndarray): root_ids = root_ids.tolist() - if not isinstance(root_ids, List): # If not a list, it can only be a string at this point + if not isinstance( + root_ids, List + ): # If not a list, it can only be a string at this point root_ids = [root_ids] if len(root_ids) > MAX_SKELETONS_EXISTS_QUERY_SIZE: