Skip to content

Commit

Permalink
added check_country_stats asset check
Browse files Browse the repository at this point in the history
  • Loading branch information
izzye84 committed Sep 26, 2023
1 parent 8714daa commit d9ffbda
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion hooli_basics/definitions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dagster import asset
from dagster import asset, asset_check, AssetCheckResult, Definitions
from pandas import DataFrame, read_html, get_dummies, to_numeric
from sklearn.linear_model import LinearRegression as Regression

Expand All @@ -9,6 +9,12 @@ def country_stats() -> DataFrame:
df["pop_change"] = ((to_numeric(df["pop_2023"]) / to_numeric(df["pop_2022"])) - 1)*100
return df

@asset_check(
asset=country_stats
)
def check_country_stats(country_stats):
return AssetCheckResult(success=True)

@asset
def change_model(country_stats: DataFrame) -> Regression:
data = country_stats.dropna(subset=["pop_change"])
Expand All @@ -21,3 +27,8 @@ def continent_stats(country_stats: DataFrame, change_model: Regression) -> DataF
result["pop_change_factor"] = change_model.coef_
return result

defs = Definitions(
assets=[country_stats, continent_stats, change_model],
asset_checks=[check_country_stats]
)

0 comments on commit d9ffbda

Please sign in to comment.