Skip to content

Commit

Permalink
Merge pull request #65 from dagster-io/christian-dagster-asset-check-…
Browse files Browse the repository at this point in the history
…tuneup

update dagster asset check to fail"better"
  • Loading branch information
cnolanminich authored Mar 11, 2024
2 parents 4f0c7c8 + 5070f06 commit 88c4300
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions hooli_data_eng/assets/raw_data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
Backoff,
DailyPartitionsDefinition,
Jitter,
MetadataValue,
RetryPolicy,
)
import pandas as pd
Expand Down Expand Up @@ -57,10 +58,17 @@ def users(context, api: RawDataAPI) -> pd.DataFrame:
description="check that users are from expected companies",
)
def check_users(context, users: pd.DataFrame):
unique_companies = pd.unique(users['company']).tolist()
observed_companies = set(pd.unique(users['company']))
expected_companies = {"ShopMart", "SportTime", "FamilyLtd", "DiscountStore"}

return AssetCheckResult(
passed= (unique_companies == ["FoodCo", "ShopMart", "SportTime", "FamilyLtd"]),
metadata={"companies": unique_companies},
passed= (set(observed_companies) == expected_companies),
metadata={"result": MetadataValue.md(
f"""
Observed the following unexpected companies:
{list(observed_companies - expected_companies)}
"""
)},
severity=AssetCheckSeverity.WARN
)

Expand Down

0 comments on commit 88c4300

Please sign in to comment.