Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Default List Packaged to Root Level Not Configurable from CLI #3034

Open
2 tasks done
shfattig opened this issue Feb 27, 2025 · 0 comments
Open
2 tasks done

[Bug] Default List Packaged to Root Level Not Configurable from CLI #3034

shfattig opened this issue Feb 27, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@shfattig
Copy link

shfattig commented Feb 27, 2025

🐛 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 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:

new main.yaml

defaults:
  - config: null
  - config@_global_: ${config}

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

  • I checked on the latest version of Hydra
  • I created a minimal repro (See this for tips).

System information

  • Hydra Version : 1.3.0
  • Python version : 3.9
  • Virtual environment type and version :
  • Operating system : Ubuntu
@shfattig shfattig added the bug Something isn't working label Feb 27, 2025
@shfattig shfattig changed the title [Bug] [Bug] Default List Packaged to Root Level Not Configurable from CLI Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant