Creating a new Dagster project
The easiest way to start building a Dagster project is by using the create-dagster
CLI. This CLI tool allows you to create a special type of Python package, called a project, that defines a Dagster code location.
- Python 3.9+
- If using
uv
as your package manager, you will need to installuv
(Recommended). - If using
pip
as your package manager, you will need to install thecreate-dagster
CLI with Homebrew,curl
, orpip
.
For detailed instructions, see the Installation guide.
Step 1. Scaffold a new Dagster project
- uv
- pip
-
Open your terminal and scaffold a new Dagster project. You can replace
my-project
with a different project name if you wish:uvx -U create-dagster project my-project
-
Respond
y
to the prompt to runuv sync
after scaffolding -
Change to the project directory:
cd my-project
-
Activate the virtual environment:
- MacOS/Unix
- Windows
source .venv/bin/activate
.venv\Scripts\activate
-
Open your terminal and scaffold a new Dagster project. You can replace
my-project
with a different project name if you wish:create-dagster project my-project
-
Change to the project directory:
cd my-project
-
Create and activate a virtual environment:
- MacOS/Unix
- Windows
python -m venv .venv
source .venv/bin/activate
python -m venv .venv
.venv\Scripts\activate
-
Install your project as an editable package:
pip install --editable .
Your new Dagster project should have the following structure:
- uv
- pip
.
└── my-project
├── pyproject.toml
├── src
│ └── my_project
│ ├── __init__.py
│ ├── definitions.py
│ └── defs
│ └── __init__.py
├── tests
│ └── __init__.py
└── uv.lock
.
└── my-project
├── pyproject.toml
├── src
│ └── my_project
│ ├── __init__.py
│ ├── definitions.py
│ └── defs
│ └── __init__.py
└── tests
└── __init__.py
The create-dagster project
command creates a directory with a standard Python package structure with some additions. For more information on the files and directories in a Dagster project, see the Dagster project file reference.
Step 2. Add assets
Assets are the core abstraction in Dagster and can represent logical units of data such as tables, datasets, or machine learning models. Assets can have dependencies on other assets, forming the data lineage for your pipelines. To add assets to your project, see Defining assets.
Step 3: View assets in the UI
To start the Dagster UI, run:
dg dev
To see your assets, navigate to http://localhost:3000.
Step 4: Continue development
- Add new Python dependencies
- Add integrations
- Use environment variables and secrets
- Add and run unit tests
Add new Python dependencies
You can specify new Python dependencies in pyproject.toml
.
Add integrations
See the Integrations docs for a full list of Dagster-supported and community-supported integrations.
Use environment variables and secrets
Environment variables, which are key-value pairs configured outside your source code, allow you to dynamically modify application behavior depending on environment.
Using environment variables, you can define various configuration options for your Dagster application and securely set up secrets. For example, instead of hard-coding database credentials - which is bad practice and cumbersome for development - you can use environment variables to supply user details. This allows you to parameterize your pipeline without modifying code or insecurely storing sensitive data.
For more information and examples, see Using environment variables and secrets.
Add and run unit tests
Tests can be added to the tests
directory and run using pytest
:
pytest tests
For more information on testing, see the following docs:
- The Testing guides have guidance on asset checks, data freshness checks, unit testing assets and ops, and testing partitioned config and jobs.
- Testing component definitions contains testing best practices for definitions scaffolded existing components.
- Testing your component has best practices for testing custom components.
Next steps
- Add integrations to your project
- Create your own Dagster Components to share with your team
- Deploy your project to Dagster+ or your own infrastructure