Welcome! Let's create a simple Dagster project step by step. 🎉
Step 1: Scaffold a New Dagster Project
Open your WSL terminal and run:
pip install create-dagster
create-dagster project my-first-dagster-project
Then navigate into your project:
cd my-first-dagster-project
Step 2: Set Up Your Virtual Environment
python -m venv .venv
source .venv/bin/activate
pip install --editable .
Step 3: Your Project Structure
Your project should look like this:
.
├── pyproject.toml
├── README.md
├── src
│ └── my_first_dagster_project
│ ├── __init__.py
│ ├── definitions.py
│ └── defs
│ └── __init__.py
└── tests
└── __init__.py
Step 4: Create Your First Asset
Inside src/my_first_dagster_project/defs/, create a file called assets.py and add this simple code:
import dagster as dg
@dg.asset
def my_first_asset():
print("Hello from my first Dagster asset!")
return [1, 2, 3, 4, 5]
@dg.asset
def my_second_asset(my_first_asset):
total = sum(my_first_asset)
print(f"The sum is: {total}")
return total
Step 5: Register Your Assets in definitions.py
Open src/my_first_dagster_project/definitions.py and update it:
import dagster as dg
from my_first_dagster_project.defs.assets import my_first_asset, my_second_asset
defs = dg.Definitions(
assets=[my_first_asset, my_second_asset],
)
Step 6: Launch the Dagster UI
Run the following command:
dg dev
Then open your browser and go to:
👉 http://127.0.0.1:3000
Step 7: Materialize Your Assets
- In the Dagster UI, click on Assets in the top navigation
- You should see
my_first_assetandmy_second_asset - Click Materialize All to run them
- Watch them execute and check the logs! ✅
What Just Happened? 🤔
-
my_first_assetruns first and returns a list of numbers -
my_second_assetdepends onmy_first_assetand calculates the sum - Dagster automatically figures out the execution order based on dependencies!
Question: Should I be running this everytime, Even though I installed Dagster?
Great question! No, you don't need to run those commands every time. Here's what each command does and when you need it:
One-Time Commands (Run Only Once)
These are setup commands you only run when creating a new project:
pip install create-dagster # Installs the create-dagster tool
create-dagster project my-first-dagster-project # Creates your project folder
Think of it like creating a new folder/workspace — you only do it once! 1
Every Time You Work on Your Project
These are the commands you run each time you open a new terminal session:
# 1. Navigate to your project
cd my-first-dagster-project
# 2. Activate your virtual environment (REQUIRED every new terminal session)
source .venv/bin/activate
# 3. Start the Dagster UI
dg dev
Quick Summary Table
| Command | When to Run |
|---|---|
pip install create-dagster |
✅ Once ever |
create-dagster project my-project |
✅ Once per new project |
python -m venv .venv |
✅ Once per new project |
source .venv/bin/activate |
🔁 Every new terminal session |
dg dev |
🔁 Every time you want to use the UI |
Pro Tip 💡
Since you're on WSL (Windows), every time you open a new terminal, just run:
cd my-first-dagster-project
source .venv/bin/activate
dg dev
And you're good to go! 🚀
You're now running your first Dagster pipeline! Feel free to ask if you have any questions. 🚀
Top comments (0)