Skip to content

Commit

Permalink
updated asset check look
Browse files Browse the repository at this point in the history
  • Loading branch information
cnolanminich committed Mar 11, 2024
1 parent f2f2009 commit e36a625
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions hooli_data_eng/assets/raw_data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,25 @@ def users(context, api: RawDataAPI) -> pd.DataFrame:
description="check that users are from expected companies",
)
def check_users(context, users: pd.DataFrame):
unique_companies = set(pd.unique(users['company']))
observed_companies = set(pd.unique(users['company']))
expected_companies = {"ShopMart", "SportTime", "FamilyLtd", "DiscountStore"}

asset_check_output ={"observed_companies": list(unique_companies),
asset_check_output ={"observed_companies": list(observed_companies),
"expected_comanies": list(expected_companies),
"in_observed_not_expected": list(unique_companies - expected_companies),
"in_expected_not_observed": list(expected_companies - unique_companies)
"in_observed_not_expected": list(observed_companies - expected_companies),
"in_expected_not_observed": list(expected_companies - observed_companies)
}

df = pd.DataFrame({key: pd.Series(value) for key, value in asset_check_output.items() })

return AssetCheckResult(
passed= (set(unique_companies) == expected_companies),
metadata={"result": MetadataValue.md(df.to_markdown())
},
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 e36a625

Please sign in to comment.