Configuration

Run Config

Several dimensions of pipeline execution can be determined at execution time through configuration. We call this set of chosen values run config. The run config is passed as a dictionary in the python api or as a yaml document when using dagit or the CLI. The following top level keys in the run config allow you to configure different aspects:

  • execution: Determine and configure the Executor to be used to control execution of the pipeline.

  • storage: Determine and configure the SystemStorageDefinition to be used to control how data is persisted as it is handed off from solid to solid.

  • loggers : Determine and configure the LoggerDefinition to be used when logging.

  • solids : Configure solids that belong to the pipeline. In addition to providing values for solid specific configuration, inputs may also be configured here, when dependencies on upstream solids outputs have not been set in the pipeline.

  • resources : Configure resources that belong to the pipeline that have defined configuration schema.

Configuration Schema

The Dagster library includes a system for defining the schema that configuration values must abide by. The most common objects to specify ConfigSchema for are SolidDefinition and ResourceDefinition.

The following simple example shows how config_schema can be used on a solid to control its behavior:

from dagster import Field, execute_pipeline, pipeline, solid


@solid(
    config_schema={
        # can just use the expected type as short hand
        "iterations": int,
        # otherwise use Field for optionality, defaults, and descriptions
        "word": Field(str, is_required=False, default_value="hello"),
    }
)
def config_example_solid(context):
    for _ in range(context.solid_config["iterations"]):
        context.log.info(context.solid_config["word"])


@pipeline
def config_example_pipeline():
    config_example_solid()


def run_bad_example():
    # This run will fail to start since there is required config not provided
    return execute_pipeline(config_example_pipeline, run_config={})


def run_other_bad_example():
    # This will also fail to start since iterations is the wrong type
    execute_pipeline(
        config_example_pipeline,
        run_config={"solids": {"config_example_solid": {"config": {"iterations": "banana"}}}},
    )


def run_good_example():
    return execute_pipeline(
        config_example_pipeline,
        run_config={"solids": {"config_example_solid": {"config": {"iterations": 1}}}},
    )

While the example above uses simple scalar config values, the config system supports strucutred types allowing for complex configuration. These are documented in the API section with examples.

Notable entries include:

  • Field - the basic building block
  • Shape - for well defined dictionaries
  • Permissive - for allowing untyped dictionaries
  • Selector - to allow choosing one of N
  • StringSource - to allow loading from environment variables