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

add custom cadet tag transformer #135

Merged
merged 1 commit into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 2 additions & 10 deletions ingestion/cadet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ source:
stateful_ingestion:
remove_stale_metadata: true
transformers:
- type: "pattern_add_dataset_domain"
- type: "add_dataset_tags"
config:
semantics: OVERWRITE
domain_pattern:
rules:
'urn:li:dataset:\(urn:li:dataPlatform:dbt,awsdatacatalog.*common_platform.*':
["HMCTS"]
'urn:li:dataset:\(urn:li:dataPlatform:dbt,awsdatacatalog.*prison.*':
["HMPPS"]
'urn:li:dataset:\(urn:li:dataPlatform:dbt,awsdatacatalog.*sirius.*':
["OPG"]
get_tags_to_add: "ingestion.cadet_display_in_catalogue_tagger.add_display_in_catalogue_tag"
17 changes: 17 additions & 0 deletions ingestion/cadet_display_in_catalogue_tagger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import logging
from typing import List

import datahub.emitter.mce_builder as builder
from datahub.metadata.schema_classes import TagAssociationClass


def add_display_in_catalogue_tag(entity_urn: str) -> List[TagAssociationClass]:
"""Compute the tags to associate to a given dataset."""
if "athena_cadet" not in entity_urn:
tag_urn = builder.make_tag_urn(tag="display_in_catalogue")
tags = [TagAssociationClass(tag=tag_urn)]

logging.info(f"Tagging dataset {entity_urn} with {tags}.")
else:
tags = []
return tags