Skip to content

Commit

Permalink
feat(cli): add aspects parameter to DataHubGraph.get_entity_semityped
Browse files Browse the repository at this point in the history
  • Loading branch information
Masterchen09 committed Jul 26, 2024
1 parent 01b3461 commit 1362190
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions metadata-ingestion/src/datahub/ingestion/graph/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,8 @@ def get_aspects_for_entity(
responds to these calls, and will be fixed automatically when the server-side issue is fixed.
:param str entity_urn: The urn of the entity
:param List[Type[Aspect]] aspect_type_list: List of aspect type classes being requested (e.g. [datahub.metadata.schema_classes.DatasetProperties])
:param List[str] aspects_list: List of aspect names being requested (e.g. [schemaMetadata, datasetProperties])
:param List[str] aspects: List of aspect names being requested (e.g. [schemaMetadata, datasetProperties])
:param List[Type[Aspect]] aspect_types: List of aspect type classes being requested (e.g. [datahub.metadata.schema_classes.DatasetProperties])
:return: Optionally, a map of aspect_name to aspect_value as a dictionary if present, aspect_value will be set to None if that aspect was not found. Returns None on HTTP status 404.
:raises HttpError: if the HTTP response is not a 200
"""
Expand All @@ -549,8 +549,8 @@ def get_aspects_for_entity(

return result

def get_entity_semityped(self, entity_urn: str) -> AspectBag:
"""Get all non-timeseries aspects for an entity (experimental).
def get_entity_semityped(self, entity_urn: str, aspects: Optional[List[str]] = None) -> AspectBag:
"""Get (all) non-timeseries aspects for an entity (experimental).
This method is called "semityped" because it returns aspects as a dictionary of
properly typed objects. While the returned dictionary is constrained using a TypedDict,
Expand All @@ -560,11 +560,12 @@ def get_entity_semityped(self, entity_urn: str) -> AspectBag:
something, even if the entity doesn't actually exist in DataHub.
:param entity_urn: The urn of the entity
:param Optional[List[str]] aspects: Optional list of aspect names being requested (e.g. [schemaMetadata, datasetProperties])
:returns: A dictionary of aspect name to aspect value. If an aspect is not found, it will
not be present in the dictionary. The entity's key aspect will always be present.
"""

response_json = self.get_entity_raw(entity_urn)
response_json = self.get_entity_raw(entity_urn, aspects)

# Now, we parse the response into proper aspect objects.
result: AspectBag = {}
Expand Down

0 comments on commit 1362190

Please sign in to comment.