Hydra plugins usually comes with sensible defaults which works with minimal configuration. There are two primary ways to customize the configuration of a plugin:
- Overriding it directly in your primary config
- Extending the config and using it from your primary config.
The first method is the simpler, but it makes it harder to switch to a different plugin configuration. The second method is a bit more complicated, but makes it easier to switch between different plugin configurations.
The following methods apply to all Hydra plugins. In the following examples, we will configure a imaginary Launcher plugin
MoonLauncher. The Launcher has two modes:
falcon9, which actually launches the application to the Moon and
sim which simulates a launch.
The config schema for MoonLauncher looks like:
We can directly override Launcher config in primary config.
This approach makes the assumption that the Launcher used has all the fields we are overriding.
If we wanted to override a field that exists in the Simulation Launcher but not in the Falcon9 Launcher,
window_size.width, we would no longer be able to use the Falcon9 Launcher! The next section solves this problem.
This section assumes that you are familiar with the contents of Common Patterns/Extending Configs.
Extending plugin default config has several advantages:
- Separate configuration concerns, keep primary config clean.
- Easier to switch between different plugin configurations.
- Provides flexibility when a Plugin has different modes that requires different schema.
Say that we want to override certain values for different Launcher mode:
We can easily user command-line overrides to get the configuration needed: