Suppose you want to benchmark your application on each of PostgreSQL and MySQL. To do this, use config groups.
A Config Group is a named group with a set of valid options.
- The config options are mutually exclusive. Only one can be selected.
- Selecting a non-existent config option generates an error message with the valid options.
To create a config group, create a directory. e.g.
db to hold a file for each database configuration option.
Since we are expecting to have multiple config groups, we will proactively move all the configuration files
The config group determines the
package of the config content inside the final config object.
In Hydra 1.1
_group_ will become the default package.
For now, add
# @package _group_ at the top of your config group files.
Learn more about packages directive here.
Since we moved all the configs into the
conf directory, we need to tell Hydra where to find them using the
config_path is a directory relative to
my_app.py without requesting a configuration will print an empty config.
You can append an item a config group to the
Defaults List is described on the next page.
Like before, you can still override individual values in the resulting config:
Config groups can be nested. For example the config group
db/mysql/storage_engine can contain
When selecting an option from a nested config group, use
This simple example also demonstrated a very powerful feature of Hydra: You can compose your configuration object from multiple configuration groups.