Skip to content

Commit

Permalink
Update quickstart post-review
Browse files Browse the repository at this point in the history
  • Loading branch information
maximearmstrong committed May 14, 2024
1 parent 368d373 commit a5952c4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
31 changes: 24 additions & 7 deletions docs/content/integrations/dbt/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,34 @@ This command creates a new directory called `my_dagster_project/` inside the cur
</TabItem>
<TabItem name="Option 2: Use an existing Dagster project">

### Option 2: Use an existing Dagster project
### Option 2: Load your dbt project in an existing Dagster project

You can use an existing Dagster project to run your dbt project. To do so, you'll need to add some objects using the [dagster-dbt library](/\_apidocs/libraries/dagster-dbt) and update your `Definitions` object. This example assumes that your existing Dagster project includes both `assets.py` and `definitions.py` files.
You can use an existing Dagster project to run your dbt project. To do so, you'll need to add some objects using the [dagster-dbt library](/\_apidocs/libraries/dagster-dbt) and update your `Definitions` object. This example assumes that your existing Dagster project includes both `assets.py` and `definitions.py` files, among other required files.

```shell
my_dagster_project
├── __init__.py
├── assets.py
├── definitions.py
├── pyproject.toml
├── setup.cfg
└── setup.py
```

1. Change directories to the Dagster project directory:

```shell
cd my-dagster-project/
cd my_dagster_project/
```

2. Create a Python file named `project.py` and add the following code. The DbtProject object is a representation of your dbt project that assist with managing manifest.json preparation.
2. Create a Python file named `project.py` and add the following code. The DbtProject object is a representation of your dbt project that assist with managing `manifest.json` preparation.

```python file=/integrations/dbt/quickstart.py startafter=start_dbt_project_example endbefore=end_dbt_project_example
from pathlib import Path

from dagster_dbt import DbtProject

RELATIVE_PATH_TO_MY_DBT_PROJECT = "./my-dbt-project"
RELATIVE_PATH_TO_MY_DBT_PROJECT = "./my_dbt_project"

my_project = DbtProject(
project_dir=Path(__file__)
Expand All @@ -92,7 +102,7 @@ You can use an existing Dagster project to run your dbt project. To do so, you'l
)
```

3. In your `assets.py` file, add the following code. Using the `dbt_assets` decorator allows Dagster to create a definition for how to compute a set of dbt resources, described by a manifest.json.
3. In your `assets.py` file, add the following code. Using the `dbt_assets` decorator allows Dagster to create a definition for how to compute a set of dbt resources, described by a `manifest.json`.

```python file=/integrations/dbt/quickstart.py startafter=start_dbt_assets_example endbefore=end_dbt_assets_example
from dagster import AssetExecutionContext
Expand All @@ -115,8 +125,15 @@ You can use an existing Dagster project to run your dbt project. To do so, you'l
from .project import my_project

defs = Definitions(
assets=[my_dbt_assets],
assets=[
# your other assets here,
my_dbt_assets
],
jobs=[
# your jobs here
],
resources={
# your other resources here,
"dbt": DbtCliResource(project_dir=my_project),
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def dbt_project_example():

from dagster_dbt import DbtProject

RELATIVE_PATH_TO_MY_DBT_PROJECT = "./my-dbt-project"
RELATIVE_PATH_TO_MY_DBT_PROJECT = "./my_dbt_project"

my_project = DbtProject(
project_dir=Path(__file__)
Expand Down Expand Up @@ -82,8 +82,15 @@ def dbt_definitions_example():
from .project import my_project

defs = Definitions(
assets=[my_dbt_assets],
assets=[
# your other assets here,
my_dbt_assets
],
jobs=[
# your jobs here
],
resources={
# your other resources here,
"dbt": DbtCliResource(project_dir=my_project),
},
)
Expand Down

0 comments on commit a5952c4

Please sign in to comment.