Skip to content

Commit

Permalink
move to dbt docs
Browse files Browse the repository at this point in the history
  • Loading branch information
benpankow committed Jun 7, 2024
1 parent ac47dcd commit f4e6d8e
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 34 deletions.
Binary file modified docs/content/api/modules.json.gz
Binary file not shown.
Binary file modified docs/content/api/searchindex.json.gz
Binary file not shown.
Binary file modified docs/content/api/sections.json.gz
Binary file not shown.
35 changes: 1 addition & 34 deletions docs/content/guides/dagster/code-references.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,40 +62,7 @@ A link to the asset's source in `with_source_code_references.py` will then be vi

### dbt assets

Dagster's dbt integration can automatically attach references to the SQL files backing your dbt assets. To enable this feature, set the `enable_code_references` parameter to `True` in the <PyObject module="dagster_dbt" object="DagsterDbtTranslatorSettings" /> passed to your <PyObject module="dagster_dbt" object="DagsterDbtTranslator" />:

```python file=/guides/dagster/code_references/with_dbt_code_references.py
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]))
```
Dagster's dbt integration can automatically attach references to the SQL files backing your dbt assets. For more information, see the [dagster-dbt integration reference](/integrations/dbt/reference#attaching-code-reference-metadata).

---

Expand Down
37 changes: 37 additions & 0 deletions docs/content/integrations/dbt/reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,43 @@ def my_dbt_assets(context: AssetExecutionContext, dbt: DbtCliResource):

Dagster also supports fetching additional metadata at dbt execution time to attach to asset materializations. For more information, see the [Customizing asset materialization metadata](#customizing-asset-materialization-metadata) section.

#### Attaching code reference metadata

Dagster's dbt integration can automatically attach [Code reference](/guides/dagster/code-references) metadata to the SQL files backing your dbt assets. To enable this feature, set the `enable_code_references` parameter to `True` in the <PyObject module="dagster_dbt" object="DagsterDbtTranslatorSettings" /> passed to your <PyObject module="dagster_dbt" object="DagsterDbtTranslator" />:

```python file=/guides/dagster/code_references/with_dbt_code_references.py
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]))
```

### Customizing tags

<Note>
Expand Down

0 comments on commit f4e6d8e

Please sign in to comment.