Skip to content

Commit

Permalink
Update post review
Browse files Browse the repository at this point in the history
  • Loading branch information
maximearmstrong committed Jun 6, 2024
1 parent 34f6c96 commit 6614302
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
16 changes: 13 additions & 3 deletions docs/content/integrations/dbt/reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,32 @@ When deploying your Dagster project to production, **we recommend generating the
Creating the manifest at runtime in production is known to cause issues and is not recommended. This is often caused by the following code and should be avoided.

```python startafter=start_troubleshooting_dbt_manifest endbefore=end_troubleshooting_dbt_manifest file=/integrations/dbt/dbt.py dedent=4
"""❌ This is not recommended."""
import os
from pathlib import Path

from dagster_dbt import DbtCliResource

dbt_project_dir = Path(__file__).joinpath("..", "..", "..").resolve()
dbt = DbtCliResource(project_dir=os.fspath(dbt_project_dir))
dbt_parse_invocation = dbt.cli(["parse"], target_path=Path("target")).wait()
dbt_manifest_path = dbt_parse_invocation.target_path.joinpath("manifest.json")

# A manifest will always be created at runtime.
dbt_manifest_path = (
dbt.cli(
["--quiet", "parse"],
target_path=Path("target"),
)
.wait()
.target_path.joinpath("manifest.json")
)
```

In this example, the command `dbt parse` is invoked at run time. To avoid any issues, it is recommended to create the manifest at build time, like in the following example.
To avoid any issues, we recommend that the manifest is created at run time only during local development. In production, the manifest should be created at build time.

In the Dagster project created by the [`dagster-dbt project scaffold`](/\_apidocs/libraries/dagster-dbt#dagster-dbt-project-scaffold) command line interface, we offer you both ways to load your dbt models:

```python startafter=start_compile_dbt_manifest endbefore=end_compile_dbt_manifest file=/integrations/dbt/dbt.py dedent=4
"""✅ This is recommended!"""
import os
from pathlib import Path

Expand Down
14 changes: 12 additions & 2 deletions examples/docs_snippets/docs_snippets/integrations/dbt/dbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

def scope_compile_dbt_manifest(manifest):
# start_compile_dbt_manifest
"""✅ This is recommended!"""
import os
from pathlib import Path

Expand All @@ -31,15 +32,24 @@ def scope_compile_dbt_manifest(manifest):

def scope_troubleshooting_dbt_manifest(manifest):
# start_troubleshooting_dbt_manifest
"""❌ This is not recommended."""
import os
from pathlib import Path

from dagster_dbt import DbtCliResource

dbt_project_dir = Path(__file__).joinpath("..", "..", "..").resolve()
dbt = DbtCliResource(project_dir=os.fspath(dbt_project_dir))
dbt_parse_invocation = dbt.cli(["parse"], target_path=Path("target")).wait()
dbt_manifest_path = dbt_parse_invocation.target_path.joinpath("manifest.json")

# A manifest will always be created at runtime.
dbt_manifest_path = (
dbt.cli(
["--quiet", "parse"],
target_path=Path("target"),
)
.wait()
.target_path.joinpath("manifest.json")
)
# end_troubleshooting_dbt_manifest


Expand Down

0 comments on commit 6614302

Please sign in to comment.