You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a default list it could be helpful to reserve some config group name that can be specified on command line and used to override the main config (i.e. at _global_).
Currently this is possible by setting a package header in the config itself (# @package _global_) and then setting a default list item like - config: null. A user can then, given a file "config/userconfig.yaml", use the arg config=userconfig to import the file at the root level.
main.yaml
defaults:
- config: null
config/userconfig.yaml
# @package _global_
a: 1
cli: python main.py config=userconfig
final result:
a: 1
However, this requires user knowledge of hydra syntax and packages. It would be better if the package is instead specified in the primary config default list: - config@_global_: null, removing the need for a package header in the user config while still loading the user config at the root level.
new main.yaml
defaults:
- config@_global_: null
new, cleaner config/userconfig.yaml
a: 1
Unfortunately this causes a ConfigCompositionException complaining that the arg config=userconfig cannot be overridden and suggests an override of config@_global_. We are however again at the issue of requiring a user to have knowledge of packaging and hydra magic keywords.
The hacky workaround I found is to specify two default list items for config, one without package specification and one at the root package with interpolation to the first:
This will ultimately produce the desired result, but will redundantly include the config in two places and is of course quite hacky. If this hack does accomplish the objclective it seems that the exception above is erroneous and the attempted definition should be allowed to work.
🐛 Bug
Description
In a default list it could be helpful to reserve some config group name that can be specified on command line and used to override the main config (i.e. at
_global_
).Currently this is possible by setting a package header in the config itself (
# @package _global_
) and then setting a default list item like- config: null
. A user can then, given a file "config/userconfig.yaml", use the argconfig=userconfig
to import the file at the root level.main.yaml
config/userconfig.yaml
cli:
python main.py config=userconfig
final result:
However, this requires user knowledge of hydra syntax and packages. It would be better if the package is instead specified in the primary config default list:
- config@_global_: null
, removing the need for a package header in the user config while still loading the user config at the root level.new main.yaml
new, cleaner config/userconfig.yaml
Unfortunately this causes a ConfigCompositionException complaining that the arg
config=userconfig
cannot be overridden and suggests an override ofconfig@_global_
. We are however again at the issue of requiring a user to have knowledge of packaging and hydra magic keywords.The hacky workaround I found is to specify two default list items for
config
, one without package specification and one at the root package with interpolation to the first:new main.yaml
This will ultimately produce the desired result, but will redundantly include the config in two places and is of course quite hacky. If this hack does accomplish the objclective it seems that the exception above is erroneous and the attempted definition should be allowed to work.
Checklist
System information
The text was updated successfully, but these errors were encountered: