From 4f950d9613557d45d0eae08e63f8fd64ff854450 Mon Sep 17 00:00:00 2001 From: David Michaels Date: Sat, 17 Aug 2024 08:43:44 -0400 Subject: [PATCH] Minor changes to utility/troubleshooting/convenience script view-portal-object. --- dcicutils/scripts/view_portal_object.py | 18 +++++++----------- pyproject.toml | 2 +- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/dcicutils/scripts/view_portal_object.py b/dcicutils/scripts/view_portal_object.py index 15e4c92df..1128d1539 100644 --- a/dcicutils/scripts/view_portal_object.py +++ b/dcicutils/scripts/view_portal_object.py @@ -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 @@ -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 @@ -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) diff --git a/pyproject.toml b/pyproject.toml index 2f24410ec..0f6e6cf13 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "] license = "MIT"