diff --git a/dcicutils/portal_object_utils.py b/dcicutils/portal_object_utils.py index 9bec68d08..9a64cb2bd 100644 --- a/dcicutils/portal_object_utils.py +++ b/dcicutils/portal_object_utils.py @@ -145,15 +145,12 @@ def diff_deleting(value: Any) -> object: # noqa return diffs @lru_cache(maxsize=1) - def _get_identifying_paths(self, all: bool = True, - ref_lookup_strategy: Optional[Callable] = None) -> Optional[List[str]]: + def _get_identifying_paths(self, ref_lookup_strategy: Optional[Callable] = None) -> Optional[List[str]]: if not self._portal and (uuid := self.uuid): - if all is True and (type := self.type): - return [f"/{type}/{uuid}", f"/{uuid}"] return [f"/{uuid}"] # Migrating to and unifying this in portal_utils.Portal.get_identifying_paths (2024-05-26). return self._portal.get_identifying_paths(self._data, - portal_type=self.schema, all=all, + portal_type=self.schema, lookup_strategy=ref_lookup_strategy) if self._portal else None def _normalized_refs(self, refs: List[dict]) -> Tuple[PortalObject, int]: diff --git a/dcicutils/portal_utils.py b/dcicutils/portal_utils.py index 1c2bfd1a5..42f3a4927 100644 --- a/dcicutils/portal_utils.py +++ b/dcicutils/portal_utils.py @@ -407,7 +407,7 @@ def get_schema_subtype_names(self, type_name: str) -> List[str]: @function_cache(maxsize=100, serialize_key=True) def get_identifying_paths(self, portal_object: dict, portal_type: Optional[Union[str, dict]] = None, - all: bool = True, lookup_strategy: Optional[Union[Callable, bool]] = None) -> List[str]: + lookup_strategy: Optional[Union[Callable, bool]] = None) -> List[str]: """ Returns the list of the identifying Portal (URL) paths for the given Portal object. Favors any uuid and identifier based paths and defavors aliases based paths (ala self.get_identifying_property_names); @@ -467,15 +467,11 @@ def is_lookup_subtypes(lookup_options: int) -> bool: # noqa # And note the disction of just using /{uuid} here rather than /{type}/{uuid} as in the else # statement below is not really necessary; just here for emphasis that this is all that's needed. # - if all is True: - results.append(f"/{portal_type}/{identifying_value}") results.append(f"/{identifying_value}") elif isinstance(identifying_value, list): for identifying_value_item in identifying_value: if identifying_value_item: results.append(f"/{portal_type}/{identifying_value_item}") - if all is True: - results.append(f"/{identifying_value_item}") else: lookup_options = Portal.LOOKUP_UNDEFINED if schema := self.get_schema(portal_type): @@ -542,7 +538,7 @@ def get_identifying_property_names(self, schema: Union[str, dict], @staticmethod def _lookup_strategy(portal: Portal, type_name: str, schema: dict, value: str) -> (int, Optional[str]): # - # Note this slight odd situation WRT object lookups by submitted_id and accession: + # Note this slightly odd situation WRT object lookups by submitted_id and accession: # -----------------------------+-----------------------------------------------+---------------+ # PATH | EXAMPLE | LOOKUP RESULT | # -----------------------------+-----------------------------------------------+---------------+ diff --git a/pyproject.toml b/pyproject.toml index 1f1dcbd3a..5ed46ce3e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dcicutils" -version = "8.8.6.1b7" +version = "8.8.6.1b8" description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources" authors = ["4DN-DCIC Team "] license = "MIT" diff --git a/test/test_portal_object_utils.py b/test/test_portal_object_utils.py index 18e632620..9ed1868f3 100644 --- a/test/test_portal_object_utils.py +++ b/test/test_portal_object_utils.py @@ -600,8 +600,7 @@ def test_compare(): assert portal_object.types == ["IngestionSubmission", "Item"] assert not portal_object.schema assert not portal_object.identifying_properties - assert portal_object._get_identifying_paths() == [f"/{TEST_OBJECT_DATABASE_JSON['@type'][0]}/{TEST_OBJECT_UUID}", - f"/{TEST_OBJECT_UUID}"] + assert portal_object._get_identifying_paths() == [f"/{TEST_OBJECT_UUID}"] assert portal_object.compare(TEST_OBJECT_DATABASE_JSON) == ({}, 0) portal_object_copy = portal_object.copy() @@ -628,10 +627,9 @@ def test_compare(): assert portal_object_found.schema == TEST_OBJECT_SCHEMA_JSON assert portal_object_found.identifying_properties == ["uuid", "aliases"] assert portal_object_found._get_identifying_paths() == ( - [f"/{TEST_OBJECT_DATABASE_JSON['@type'][0]}/{TEST_OBJECT_UUID}", - f"/{TEST_OBJECT_UUID}", - "/IngestionSubmission/foo", "/foo", - "/IngestionSubmission/bar", "/bar"]) + [f"/{TEST_OBJECT_UUID}", + "/IngestionSubmission/foo", + "/IngestionSubmission/bar"]) portal_object_copy = portal_object.copy() portal_object_copy.data["xyzzy"] = 123