We have seen that if the name of the config file matches the name of a configs stored in the
ConfigStore it will be used to validate the config file automatically.
This is useful if there is a one-to-one mapping between the Structured Configs and the YAML files.
Such convenient mapping does not exist when we have many config files and just one schema.
If the config has a static structure, You can define it using Structured Configs. Any config merged into this config structure will be validated against the schema you define.
driver: str = MISSING
host: str = MISSING
user: str = MISSING
password: str = MISSING
db: DBConfig = MISSING
cs = ConfigStore.instance()
def my_app(cfg: Config) -> None:
if __name__ == "__main__":
- db: staging
# @package _group_
In the above example, the 3 yaml files has the structure compatible with the
You can have as many such configs as you want.
$ python my_app.py db=prod