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.
You can create additional projects later by running 'dg scaffold 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
7 directories, 6 files
- The Python package
my_projectlives insrc/my_projectand contains the deployable code that defines your Dagster pipelines. my_project/defswill contain your Dagster definitions.my_project/libis where you will define custom component types, and optionally other code you wish to share across Dagster definitions.my_project/definitions.pyis 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.testsis a separate Python package defined at the top level (outsidesrc). It should contain tests for themy_projectpackage.pyproject.tomlis a standard Python package configuration file. In addition to the regular Python package metadata, it contains atool.dgsection fordg-specific settings.uv.lockis the lockfile for the Python package manageruv.dgprojects useuvby default. For more information, seeuvintegration.