📘 Introduction

In this hands-on tutorial, we’ll walk you step-by-step through adding your dbt models as assets to your Dagster projects. Once done, your dbt models will appear in the Dagster UI, making it easy to orchestrate, run, and monitor them.

✅ Prerequisites

🐍☑️ Installed Python
📦☑️Installed Pip
🌐☑️ Created a virtual environment (venv)
🗂️☑️ A dbt project set up
🧪☑️ Existing dbt models defined in your models/ directory
🐙☑️ Created a Dagster project within your dbt project

🗂️ Existing dbt project with a Dagster project

In this tutorial, we’re working with a dbt project called dlnerds_university. Inside it, we’ve already created a Dagster project named dlnerds_university_dagster.

🔎1️⃣ Check manifest.json in your dbt project

Inside your dbt project, go to the target/ folder and verify that manifest.json exists.

💡
Why it matters:
The manifest.json file is automatically generated by dbt and contains metadata about your models, sources, tests, and dependencies. Dagster uses this file to understand your project structure and expose your models as assets in the UI.

🚪2️⃣ Open assets.py in your Dagster project

Navigate to your Dagster project folder and open assets.py. This is where we’ll define your dbt models as Dagster assets.

📥3️⃣ Import modules

At the top of assets.py, add:

from dagster import AssetExecutionContext
from dagster_dbt import DbtCliResource, dbt_assets
from .project import dlnerds_university_project

🛠️4️⃣ Add dbt models as assets

Next, let’s tell Dagster to treat your dbt models as assets. This way, Dagster can run, track, and visualize them.

Use the @dbt_assets decorator to convert your dbt models into Dagster assets:

You can view this post with the tier: Academy Membership

Join academy now to read the post and get access to the full library of premium posts for academy members only.

Join Academy Already have an account? Sign In