-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docs] add dbt code references guide
- Loading branch information
Showing
5 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
30 changes: 30 additions & 0 deletions
30
...es/docs_snippets/docs_snippets/guides/dagster/code_references/with_dbt_code_references.py
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,30 @@ | ||
from pathlib import Path | ||
|
||
from dagster_dbt import ( | ||
DagsterDbtTranslator, | ||
DagsterDbtTranslatorSettings, | ||
DbtCliResource, | ||
dbt_assets, | ||
) | ||
|
||
from dagster import AssetExecutionContext, Definitions | ||
from dagster._core.definitions.metadata import with_source_code_references | ||
|
||
manifest_path = Path("path/to/dbt_project/target/manifest.json") | ||
|
||
# links to dbt model source code from assets | ||
dagster_dbt_translator = DagsterDbtTranslator( | ||
settings=DagsterDbtTranslatorSettings(enable_code_references=True) | ||
) | ||
|
||
|
||
@dbt_assets( | ||
manifest=manifest_path, | ||
dagster_dbt_translator=dagster_dbt_translator, | ||
) | ||
def my_dbt_assets(context: AssetExecutionContext, dbt: DbtCliResource): | ||
yield from dbt.cli(["build"], context=context).stream() | ||
|
||
|
||
# optionally, add references to the Python source with with_source_code_references | ||
defs = Definitions(assets=with_source_code_references([my_dbt_assets])) |