Skip to content

Commit

Permalink
updated checks with latest API
Browse files Browse the repository at this point in the history
  • Loading branch information
slopp committed Sep 14, 2023
1 parent 745122c commit d782a60
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions hooli_data_eng/assets/marketing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def avg_orders(context: AssetExecutionContext, company_perf: pd.DataFrame) -> pd
})

@asset_check(
description="check that avg ordres are expected",
severity=AssetCheckSeverity.WARN,
description="check that avg orders are expected",
asset=avg_orders
)
def check_avg_orders(context, avg_orders: pd.DataFrame):
avg = avg_orders['avg_order'][0]
Expand Down
8 changes: 5 additions & 3 deletions hooli_data_eng/assets/raw_data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pandas as pd
from dagster import asset, RetryPolicy, Backoff, Jitter, DailyPartitionsDefinition, OpExecutionContext, build_op_context, build_resources, asset_check, AssetCheckSeverity, AssetCheckResult
from dagster import asset, RetryPolicy, Backoff, Jitter, DailyPartitionsDefinition, OpExecutionContext, build_op_context, build_resources, asset_check, AssetCheckSeverity, AssetCheckResult, AssetKey
from datetime import datetime, timedelta
from hooli_data_eng.resources.api import RawDataAPI

Expand Down Expand Up @@ -38,14 +38,16 @@ def users(context, api: RawDataAPI) -> pd.DataFrame:
return pd.concat(all_users)

@asset_check(
asset=AssetKey(["RAW_DATA", "users"]),
description="check that users are from expected companies",
severity=AssetCheckSeverity.WARN,
#severity=AssetCheckSeverity.WARN,
)
def check_users(context, users: pd.DataFrame):
unique_companies = pd.unique(users['company']).tolist()
return AssetCheckResult(
success= (unique_companies == ["FoodCo", "ShopMart", "SportTime", "FamilyLtd"]),
metadata={"companies": unique_companies}
metadata={"companies": unique_companies},
severity=AssetCheckSeverity.WARN
)

@asset(
Expand Down

0 comments on commit d782a60

Please sign in to comment.