Hi team, I have created a custom action for when ...
# advice-metadata-modeling
g
Hi team, I have created a custom action for when a tag "pii" has been added to a dataset. I would like to access the metadata of each dataset when this tag has been added, in order to then upload said dataset with its metadata to dataverse. How can I access the dataset's metadata?
class CustomActionConfig(BaseModel):
# Whether to print the message in upper case.
to_upper: Optional[bool]
# A basic example of a DataHub action that prints all
# events received to the console.
class CustomAction(Action):
@classmethod
def create(cls, config_dict: dict, ctx: PipelineContext) -> "Action":
action_config = CustomActionConfig.parse_obj(config_dict or {})
return cls(action_config, ctx)
def __init__(self, config: CustomActionConfig, ctx: PipelineContext):
self.config = config
def act(self, event: EventEnvelope) -> None:
print("Custom Action! Received event:")
metadata = event.event
print(json.dumps(<http://metadata.as|metadata.as>_dict(), indent=4))
def close(self) -> None:
pass
Thank you for your help
r
Hi Erman- one way is to achieve this is to read the tags of the dataset via API & SDKs. We have a guide on GraphQL, Python SDK, etc here : https://datahubproject.io/docs/next/api/tutorials/tags#read-tags