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

MINOR - Airflow dag_tag PK #16314

Merged
merged 2 commits into from
May 17, 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
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,17 @@ def build_workflow_config_property(

def clean_name_tag(tag: str) -> Optional[str]:
"""
Clean the tag to be used in Airflow
:param tag: tag to be cleaned
:return: cleaned tag
Clean the tag to be used in Airflow.
Airflow supports 100 characters. We'll keep just 90
since we add prefixes on the tags
"""
if not tag:
return None
try:
return fqn.split(tag)[-1][:100]
return fqn.split(tag)[-1][:90]
except Exception as exc:
logger.warning("Error cleaning tag: %s", exc)
return tag[:100]
return tag[:90]


def build_dag_configs(ingestion_pipeline: IngestionPipeline) -> dict:
Expand Down Expand Up @@ -273,8 +273,8 @@ def build_dag_configs(ingestion_pipeline: IngestionPipeline) -> dict:
"OpenMetadata",
clean_name_tag(ingestion_pipeline.displayName)
or clean_name_tag(ingestion_pipeline.name.__root__),
ingestion_pipeline.pipelineType.value,
clean_name_tag(ingestion_pipeline.service.name),
f"type:{ingestion_pipeline.pipelineType.value}",
f"service:{clean_name_tag(ingestion_pipeline.service.name)}",
],
}

Expand Down
2 changes: 1 addition & 1 deletion openmetadata-airflow-apis/tests/unit/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ def test_clean_tag():
assert clean_name_tag("hello") == "hello"
assert clean_name_tag("hello(world)") == "hello(world)"
assert clean_name_tag("service.pipeline") == "pipeline"
assert clean_name_tag(f"service.{'a' * 200}") == "a" * 100
assert clean_name_tag(f"service.{'a' * 200}") == "a" * 90
Loading