-
Project Setup
- Copy your dbt project into the root of your Dagster repository
- Add
profiles.yml
to the root of your dbt project - Update the
profiles.yml
with the appropriatedbt adapter
connection info- We recommend using environment variables—see example configuration
-
Update Dependencies
-
Add the following packages to your
setup.py
:dagster-dbt
dbt-<your_adapter>
-
Add the following package_data config to the
setup.py
:from setuptools import find_packages, setup setup( name="my_example_dagster_project", version="0.0.1", packages=find_packages(), package_data={ "my-dagster-code-location": [ "dbt-project/**/*", ], }, ...
-
-
Configure the
dagster-dbt
(dbt Core) integration-
Create a
project.py
file with the following code to your existing code location:from pathlib import Path from dagster_dbt import DbtProject my_dbt_project = DbtProject( project_dir=Path(__file__).joinpath("..", "..", "my_dbt_project").resolve(), packaged_project_dir=Path(__file__).joinpath("..", "dbt-project").resolve(), ) my_dbt_project.prepare_if_dev()
-
Be sure to update the
project_dir
variable with your dbt project name
-
-
Create dbt Assets
-
Either:
- Copy the provided
assets.py
file, or
from dagster import AssetExecutionContext from dagster_dbt import DbtCliResource, dbt_assets from .project import my_dbt_project @dbt_assets(manifest=my_dbt_project.manifest_path) def my_dbt_assets(context: AssetExecutionContext, dbt: DbtCliResource): yield from dbt.cli(["build"], context=context).stream()
- Add the
dbt_assets
code to an existing asset file
- Copy the provided
-
Ensure the dbt assets and resource are included with your other asset definitions:
from dagster import Definitions from dagster_dbt import DbtCliResource from .assets import my_dbt_assets from .project import my_dbt_project defs = Definitions( assets=[my_dbt_assets], resources={ "dbt": DbtCliResource(project_dir=my_dbt_project), }, )
-
-
Update GitHub Action
- Add a "Prepare dbt project for deployment" step just before the "Build and upload Docker image" step:
- name: Prepare DBT project for deployment run: | python -m pip install pip --upgrade pip install . --upgrade --upgrade-strategy eager ## Install the Python dependencies from the setup.py file, ex: dbt-core and dbt-duckdb dagster-dbt project prepare-and-package --file my_dagster_code_location/project.py ## Replace with the project.py location in the Dagster project folder shell: bash
- Note: You'll need to add dbt variables/secrets in GitHub that correspond to the environment variables in your
profiles.yml
- These credentials are used to create the
manifest.json
- These credentials are used to create the
- Add a "Prepare dbt project for deployment" step just before the "Build and upload Docker image" step:
-
Testing
- Test the dbt Core integration locally using
dagster dev
- If everything works as expected, open a Pull Request
- Test the dbt Core integration locally using
-
Notifications
You must be signed in to change notification settings - Fork 0
izzye84/my_example_dagster_project
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published