Creating a project with dg
dg
and Dagster Components are under active development. You may encounter feature gaps, and the APIs may change. To report issues or give feedback, please join the #dg-components channel in the Dagster Community Slack.
dg
allows you to create a special type of Python package, called a project, that defines a Dagster code location.
Dagster projects created with dg
are compatible with Dagster Components. For more information, see the Dagster Components documentation.
Prerequisites
Before creating a project with dg
, you must install dg
.
Creating a project
- uv
- pip
bash dg init my-project
bash dg init my-project
Project structure
The dg init
command creates a directory with a standard Python package structure with some additions:
- uv
- pip
tree
.
├── pyproject.toml
├── src
│ └── jaffle_platform
│ ├── __init__.py
│ ├── definitions.py
│ ├── defs
│ │ └── __init__.py
│ └── lib
│ └── __init__.py
├── tests
│ └── __init__.py
└── uv.lock
6 directories, 7 files
tree
.
├── pyproject.toml
├── src
│ └── jaffle_platform
│ ├── __init__.py
│ ├── definitions.py
│ ├── defs
│ │ └── __init__.py
│ └── lib
│ └── __init__.py
└── tests
└── __init__.py
6 directories, 6 files
To use tree
, install it with brew install tree
(Mac), or follow the installation instructions.
- The Python package
my-project
lives insrc/my-project
and contains the deployable code that defines your Dagster pipelines. my-project/defs
will contain your Dagster definitions.my-project/lib
is where you will define custom component types, and optionally other code you wish to share across Dagster definitions.my-project/definitions.py
is the entry point that Dagster will load when deploying your code location. It is configured to load all definitions frommy-project/defs
. You should not need to modify this file.tests
is a separate Python package defined at the top level (outsidesrc
). It should contain tests for themy-project
package.pyproject.toml
is a standard Python package configuration file. In addition to the regular Python package metadata, it contains atool.dg
section fordg
-specific settings.uv.lock
is the lockfile for the Python package manageruv
.dg
projects useuv
by default. For more information, seeuv
integration.