We have seen how to use Structured Configs as configuration, but they can also be used as a schema (i.e. validating configuration files).
When Hydra loads a config file, it looks in the
ConfigStore for a Structured Config with a matching name and group.
If found, it is used as the schema for the newly loaded config.
This page shows how to validate
db/postgresql.yaml files against a pre-defined schema.
Given the config directory structure:
We can add Structured Configs for
postgresql.yaml, providing a schema for validating them.
The Structured Configs below are stored as
db/postgresql. They will be used as schema
when we load their corresponding config files.
db/postgresql.yaml are loaded, the corresponding configs from the
ConfigStore are used automatically.
This can be used to validate that both the configuration files (
postgresql.yaml) and the command line overrides are conforming to the schema.
Unlike the example in the previous page, the Defaults List here is
config.yaml and not in the