Skip to content

Commit

Permalink
Minor changes to utility/troubleshooting/convenience script view-port…
Browse files Browse the repository at this point in the history
…al-object.
  • Loading branch information
dmichaels-harvard committed Aug 17, 2024
1 parent 59ffd9a commit 4f950d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
18 changes: 7 additions & 11 deletions dcicutils/scripts/view_portal_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ def get_metadata_for_individual_result_type(uuid: str) -> Optional[dict]: # noq
results_total = len(results)
for result in results:
results_index += 1
if debug:
print(f"Processing result: {results_index}")
result.pop("schema_version", None)
result = prune_data(result)
if (subtypes and one_or_more_objects_of_types_exists(portal, subtypes, debug=debug) and
Expand Down Expand Up @@ -374,14 +376,7 @@ def get_metadata_for_individual_result_type(uuid: str) -> Optional[dict]: # noq

def one_or_more_objects_of_types_exists(portal: Portal, schema_types: List[str], debug: bool = False) -> bool:
for schema_type in schema_types:
try:
if one_or_more_objects_of_type_exists(portal, schema_type, debug=debug):
return True
response = portal.get(f"/{schema_type}")
if response and response.status_code == 404:
_print(f"There are no objects of sub-type: {schema_type}")
return False
except Exception:
if one_or_more_objects_of_type_exists(portal, schema_type, debug=debug):
return True
return False

Expand All @@ -393,14 +388,15 @@ def one_or_more_objects_of_type_exists(portal: Portal, schema_type: str, debug:
_print(f"Checking if there are actually any objects of type: {schema_type}")
if portal.get(f"/{schema_type}").status_code == 404:
if debug:
_print(f"No any objects of type exist: {schema_type}")
_print(f"No objects of type actually exist: {schema_type}")
return False
else:
if debug:
_print(f"One or more objects of type exist: {schema_type}")
except Exception as e:
_print(f"ERROR: Checking if there are actually any objects of type: {schema_type}")
_print(f"ERROR: Cannot determine if there are actually any objects of type: {schema_type}")
_print(e)
return False
return True


@lru_cache(maxsize=1)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "dcicutils"
version = "8.14.0.1b8" # TODO: To become 8.14.1
version = "8.14.0.1b9" # TODO: To become 8.14.1
description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources"
authors = ["4DN-DCIC Team <support@4dnucleome.org>"]
license = "MIT"
Expand Down

0 comments on commit 4f950d9

Please sign in to comment.