-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
412a4dc
commit 18756f9
Showing
5 changed files
with
41 additions
and
59 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,2 +1,34 @@ | ||
from .blocking import blocking_dbt_snowflake_assets as blocking_dbt_snowflake_assets | ||
from .nonblocking import nonblocking_dbt_snowflake_assets as nonblocking_dbt_snowflake_assets | ||
import os | ||
from pathlib import Path | ||
|
||
from dagster_dbt import DbtCliResource, dbt_assets | ||
|
||
from dagster import OpExecutionContext | ||
from dagster_cloud.metrics import SnowflakeConnectionDetails, store_dbt_adapter_metrics | ||
|
||
snowflake_connection_details = SnowflakeConnectionDetails( | ||
user=os.getenv("SNOWFLAKE_USER", ""), | ||
password=os.getenv("SNOWFLAKE_PASSWORD", ""), | ||
account="na94824.us-east-1", | ||
warehouse="DEVELOPMENT", | ||
) | ||
|
||
dbt_project_dir = Path(__file__).joinpath("..", "..", "..", "..", "dbt_project").resolve() | ||
dbt_cli_resource = DbtCliResource( | ||
project_dir=os.fspath(dbt_project_dir), | ||
profiles_dir=os.fspath(dbt_project_dir.joinpath("config")), | ||
target="staging", | ||
) | ||
|
||
dbt_parse_invocation = dbt_cli_resource.cli(["parse"]).wait() | ||
dbt_manifest_path = dbt_parse_invocation.target_path.joinpath("manifest.json") | ||
|
||
|
||
@dbt_assets(manifest=dbt_manifest_path) | ||
def nonblocking_dbt_snowflake_assets(context: OpExecutionContext, dbt: DbtCliResource): | ||
dbt_cli_invocation = dbt.cli(["build"], context=context) | ||
yield from dbt_cli_invocation.stream() | ||
|
||
run_results = dbt_cli_invocation.get_artifact("run_results.json") | ||
manifest = dbt_cli_invocation.get_artifact("manifest.json") | ||
store_dbt_adapter_metrics(context, manifest, run_results, snowflake_connection_details) |
This file was deleted.
Oops, something went wrong.
Empty file.
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