-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from dagster-io/izzy/add_storage_kind_tags
Add storage_kind tag
- Loading branch information
Showing
4 changed files
with
55 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import datetime | ||
|
||
from dagster import ( | ||
asset, | ||
build_last_update_freshness_checks, | ||
|
@@ -9,16 +11,20 @@ | |
AssetCheckResult, | ||
asset_check, | ||
AssetKey, | ||
FreshnessPolicy, | ||
define_asset_job, | ||
ScheduleDefinition, | ||
AssetSelection | ||
) | ||
import pandas as pd | ||
import datetime | ||
from dagster._core.definitions.tags import StorageKindTagSet | ||
from dagster_cloud.anomaly_detection import build_anomaly_detection_freshness_checks | ||
import pandas as pd | ||
|
||
from hooli_data_eng.assets.dbt_assets import allow_outdated_parents_policy | ||
from hooli_data_eng.utils.config_utils import get_storage_kind | ||
|
||
|
||
# dynamically determine storage_kind based on environment | ||
storage_kind = get_storage_kind() | ||
|
||
|
||
# These assets take data from a SQL table managed by | ||
|
@@ -29,6 +35,7 @@ | |
compute_kind="pandas", | ||
owners=["team:programmers", "[email protected]"], | ||
ins={"company_perf": AssetIn(key_prefix=["ANALYTICS"])}, | ||
tags={**StorageKindTagSet(storage_kind=storage_kind)}, | ||
) | ||
def avg_orders( | ||
context: AssetExecutionContext, company_perf: pd.DataFrame | ||
|
@@ -51,9 +58,10 @@ def check_avg_orders(context, avg_orders: pd.DataFrame): | |
|
||
@asset( | ||
key_prefix="MARKETING", | ||
compute_kind="snowflake", | ||
compute_kind="pandas", | ||
owners=["team:programmers"], | ||
ins={"company_perf": AssetIn(key_prefix=["ANALYTICS"])}, | ||
tags={**StorageKindTagSet(storage_kind=storage_kind)}, | ||
) | ||
def min_order(context, company_perf: pd.DataFrame) -> pd.DataFrame: | ||
"""Computes min order KPI""" | ||
|
@@ -73,6 +81,7 @@ def min_order(context, company_perf: pd.DataFrame) -> pd.DataFrame: | |
compute_kind="hex", | ||
key_prefix="MARKETING", | ||
ins={"sku_stats": AssetIn(key_prefix=["ANALYTICS"])}, | ||
tags={**StorageKindTagSet(storage_kind="s3")}, | ||
) | ||
def key_product_deepdive(context, sku_stats): | ||
"""Creates a file for a BI tool based on the current quarters top product, represented as a dynamic partition""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import os | ||
|
||
def get_storage_kind() -> str: | ||
""" | ||
Determine the storage kind based on the environment. | ||
Returns: | ||
str: The storage kind ('snowflake' or 'duckdb'). | ||
""" | ||
if ( | ||
os.getenv("DAGSTER_CLOUD_DEPLOYMENT_NAME", "") == "data-eng-prod" or | ||
os.getenv("DAGSTER_CLOUD_IS_BRANCH_DEPLOYMENT", "") == "1" | ||
): | ||
return "snowflake" | ||
return "duckdb" |