Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): add aspects parameter to DataHubGraph.get_entity_semityped #11009

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 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,10 @@ 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).
hsheth2 marked this conversation as resolved.
Show resolved Hide resolved

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 +562,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])
hsheth2 marked this conversation as resolved.
Show resolved Hide resolved
: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
Loading