Skip to content

Commit

Permalink
Merge pull request #291 from CAVEconnectome/skeletons_v4
Browse files Browse the repository at this point in the history
SkeletonClient retrieves valid skeleton versions from server instead …
  • Loading branch information
kebwi authored Dec 20, 2024
2 parents af16785 + c777dae commit 6e4ffcc
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions caveclient/skeletonservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -408,17 +408,19 @@ 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):
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:
Expand Down Expand Up @@ -540,10 +542,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:
Expand Down Expand Up @@ -650,10 +652,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(
Expand Down

0 comments on commit 6e4ffcc

Please sign in to comment.