Skip to main content
Version: 1.3

Introduction to Structured Configs

This is an advanced tutorial that assumes that you are comfortable with the concepts introduced in the Basic Tutorial. The examples in this tutorial are available here.

Structured Configs use Python dataclasses to describe your configuration structure and types. They enable:

  • Runtime type checking as you compose or mutate your config
  • Static type checking when using static type checkers (mypy, PyCharm, etc.)

Structured Configs supports:​

  • Primitive types (int, bool, float, str, Enums, bytes, pathlib.Path)
  • Nesting of Structured Configs
  • Containers (List and Dict) containing primitives, Structured Configs, or other lists/dicts
  • Optional fields

Structured Configs Limitations:​

See the OmegaConf docs on Structured Configs for more details.

There are two primary patterns for using Structured configs with Hydra​

  • As a config, in place of configuration files (often a starting place)
  • As a config schema validating configuration files (better for complex use cases)

With both patterns, you still get everything Hydra has to offer (config composition, Command line overrides etc). This tutorial covers both. *Read it in order*.

Hydra supports OmegaConf's Structured Configs via the ConfigStore API. This tutorial does not assume any knowledge of them. It is recommended that you visit the OmegaConf Structured Configs page to learn more later.