Running Dagster locally
In this guide, we'll walk you through how to run Dagster on your local machine using the dagster dev
command. The dagster dev
command launches the Dagster UI and the Dagster daemon, allowing you to start a full deployment of Dagster from the command line.
dagster dev
is intended for local development only. If you want to run Dagster for production use cases, see our Deployment guides.
Locating your code
Before starting local development, you need to tell Dagster how to find the Python code containing your assets and jobs.
For a refresher on how to set up a Dagster project, follow our Recommended Dagster Project Structure guide.
- From a module
- Without command line arguments
- From a file
Dagster can load Python modules as code locations.
Loading...
We can use the -m
argument to supply the name of the module to start a Dagster instance loaded with our definitions:
dagster dev -m my_module
To load definitions from a module without supplying the -m
command line argument, you can use a pyproject.toml
file. This file, included in all Dagster example projects, contains a tool.dagster
section where you can supply the module_name
:
Loading...
Dagster can load a file directly as a code location.
Loading...
Given the preceding file, we can use the -f
argument to supply the name of the file to start a Dagster instance loaded with our definitions:
dagster dev -f defs.py
We don't recommend using the -f
argument for production deployments, to avoid a whole class of Python import errors.
Creating a persistent instance
Running dagster dev
without any additional configuration starts an ephemeral instance in a temporary directory. You may see log output indicating as such:
Using temporary directory /Users/rhendricks/tmpqs_fk8_5 for storage.
This indicates that any runs or materialized assets created during your session won't be persisted once the session ends.
To designate a more permanent home for your runs and assets, you can set the DAGSTER_HOME
environment variable to a folder on your filesystem. Dagster will then use the specified folder for storage on all subsequent runs of dagster dev
.
mkdir -p ~/.dagster_home
export DAGSTER_HOME=~/.dagster_home
dagster dev
Configuring your instance
To configure your Dagster instance, you can create a dagster.yaml
file in your $DAGSTER_HOME
folder.
For example, to have your local instance limit the number of concurrent runs, you could configure the following dagster.yaml
:
Loading...
For the full list of options that can be set in the dagster.yaml
file, refer to the Dagster instance documentation.