Initializing a dg project
warning
This feature is considered in a preview stage and is under active development. It can change significantly, or be removed completely. It is not considered ready for production use.
dg
provides support for generating a special type of Python package, called a project, that defines a Dagster code location.
To initialize a new project, use the dg init
command:
dg init --project-name my-project
Creating a Dagster project at /.../my-project.
Scaffolded files for Dagster project at /.../my-project.
...
Project structure
The dg init
command creates a directory with a standard Python package structure with some additions:
tree
.
└── my-project
├── pyproject.toml
├── src
│ └── my_project
│ ├── __init__.py
│ ├── definitions.py
│ ├── defs
│ │ └── __init__.py
│ └── lib
│ └── __init__.py
├── tests
│ └── __init__.py
└── uv.lock
7 directories, 7 files
- 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.