clean-crayon-15379
10/06/2021, 2:45 PMadd_dataset_tags
What kind of output must my user defined function provide? A str or list of strings leads to errors. Thank you
Example:
import logging
import datahub.emitter.mce_builder as builder
from datahub.metadata.schema_classes import (
DatasetSnapshotClass,
TagAssociationClass,
)
def custom_tags(current: DatasetSnapshotClass):
""" Returns tags to associate to a dataset depending on custom logic
This function receives a DatasetSnapshotClass, performs custom logic and returns
a list of TagAssociationClass-wrapped tags.
Args:
current (DatasetSnapshotClass): Single DatasetSnapshotClass object
Returns:
List of TagAssociationClass objects.
"""
tag_strings = []
### Add custom logic here
tag_strings.append('custom1')
tag_strings.append('custom2')
tag_strings = [builder.make_tag_urn(tag=n) for n in tag_strings]
tags = [TagAssociationClass(tag=tag) for tag in tag_strings]
<http://logging.info|logging.info>(f"Tagging dataset {current.urn} with {tag_strings}.")
return tags
clean-crayon-15379
10/06/2021, 4:32 PMmammoth-bear-12532
get_tags_to_add: Callable[[DatasetSnapshotClass], List[TagAssociationClass]]
mammoth-bear-12532
DatasetSnapshotClass
as input and must return a list of TagAssociationClass
as outputmammoth-bear-12532
clean-crayon-15379
10/07/2021, 6:56 AMclean-crayon-15379
10/07/2021, 6:56 AMclean-crayon-15379
10/07/2021, 6:58 AMmammoth-bear-12532