Skip to content

Commit

Permalink
Account for non cadet refresh period (#1074)
Browse files Browse the repository at this point in the history
* Account for non cadet refresh period
  • Loading branch information
murdo-moj authored Nov 19, 2024
1 parent a28500f commit 6e4ce32
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def get_refresh_period_from_cadet_tags(
logger.warn(f"More than one refresh period tag found: {tags=}")

if relevant_refresh_schedules:
refresh_schedule = relevant_refresh_schedules[0].capitalize()
refresh_schedule = ", ".join(relevant_refresh_schedules).capitalize()
return refresh_schedule

if not relevant_refresh_schedules:
Expand Down Expand Up @@ -249,7 +249,9 @@ def parse_properties(
usage_restrictions = UsageRestrictions.model_validate(custom_properties_dict)
data_summary = DataSummary.model_validate(custom_properties_dict)
tags = parse_tags(entity)
data_summary.refresh_period = get_refresh_period_from_cadet_tags(tags)
cadet_refresh_period = get_refresh_period_from_cadet_tags(tags)
if cadet_refresh_period:
data_summary.refresh_period = cadet_refresh_period
audience = custom_properties_dict.get("audience", "Internal")

further_information = FurtherInformation.model_validate(custom_properties_dict)
Expand Down
10 changes: 9 additions & 1 deletion lib/datahub-client/tests/client/datahub/test_graphql_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ def test_parse_properties():
{"key": "row_count", "value": 100},
{"key": "Not_IN", "value": "dddd"},
{"key": "audience", "value": "Internal"},
{"key": "refresh_period", "value": "Weekly"},
],
"name": "test",
"description": "test description",
Expand All @@ -311,7 +312,7 @@ def test_parse_properties():
source_dataset_name="",
s3_location="s3://databucket/",
),
data_summary=DataSummary(row_count=100),
data_summary=DataSummary(row_count=100, refresh_period="Weekly"),
further_information=FurtherInformation(
dc_slack_channel_name="test-channel", dc_slack_channel_url="test-url"
),
Expand Down Expand Up @@ -666,6 +667,13 @@ def test_parse_updated():
([TagRef(display_name="daily_opg", urn="urn:li:tag:daily_opg")], "Daily"),
([TagRef(display_name="monthly", urn="urn:li:tag:monthly")], "Monthly"),
([TagRef(display_name="dc_cadet", urn="urn:li:tag:dc_cadet")], ""),
(
[
TagRef(display_name="daily", urn="urn:li:tag:dc_cadet"),
TagRef(display_name="monthly", urn="urn:li:tag:dc_cadet")
],
"Daily, monthly"
),
],
)
def test_get_refresh_period_from_cadet_tags(tags, expected_refresh_period):
Expand Down

0 comments on commit 6e4ce32

Please sign in to comment.