The contents of a config file can be relocated, or replicated, within the config, via package overrides.
Overriding the package in a file via a package directive
@package directive specifies a common package for all nodes in the config file.
It must be placed at the top of each
config group file.
A package directive with a literal
A package directive with
Overriding the package via the defaults list
The following example adds the
mysql config in the packages
Overriding the package via the command line
Overriding the package for
db specified in the defaults list from
Overriding the package of a config group option not in the defaults list:
For more details, see the Command line overrides page.
History and future of the package directive
The primary config, named in
@hydra.main() should not have a package directive.
For config files in config groups the default depends on the version:
- In Hydra 0.11, there was an implicit default of
- Hydra 1.0 the default is
A warning is issued for each config group file without a
- In Hydra 1.1 the default for config group files will become
By adding an explicit
@package to your configs files, you guarantee that they
will not break when you upgrade to Hydra 1.1.