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 14, 2024
1 parent e636152 commit 7ba1322
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ dcicutils
Change Log
----------

8.14.1
======
* Minor changes to utility/troubleshooting/convenience script view-portal-object.


8.14.0
======
* Minor updates to the view-portal-object dev/troubleshooting utility script.
Expand Down
24 changes: 21 additions & 3 deletions dcicutils/scripts/view_portal_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,31 @@ def _get_portal_object(portal: Portal, uuid: str,
if not ((supertypes := portal.get_schemas_super_type_map()) and (subtypes := supertypes.get(results_type))):
subtypes = None
response = {}
results_index = 0
results_total = len(results)
def get_metadata_for_individual_result_type(uuid: str) -> Optional[dict]: # noqa
# There can be a lot of individual results for which we may need to get the actual type,
# so do this in a function we were can give verbose output feedback.
nonlocal portal, results_index, results_total, verbose
if verbose:
_print(f"Getting actual type for {results_type} result:"
f" {uuid} [{results_index} of {results_total}]", end="")
result = portal.get_metadata(uuid, raise_exception=False)
if (isinstance(result_types := result.get("@type"), list) and
result_types and (result_type := result_types[0])): # noqa
if verbose:
_print(f" -> {result_type}")
return result_type
if verbose:
_print()
return None
for result in results:
results_index += 1
result.pop("schema_version", None)
if (subtypes and
(result_uuid := result.get("uuid")) and
(individual_result := portal.get_metadata(result_uuid, raise_exception=False)) and
isinstance(result_type:= individual_result.get("@type"), list) and result_type and result_type[0]): # noqa
result_type = result_type[0]
(individual_result_type := get_metadata_for_individual_result_type(result_uuid))): # noqa
result_type = individual_result_type
else:
result_type = results_type
if response.get(result_type):
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"
version = "8.14.0.1b1" # 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 7ba1322

Please sign in to comment.