Open bencwallace opened 2 years ago
Interesting. Yes, this is indeed an inconsistency. Thanks for bringing it up :)
You can work around this inconsistency by creating an empty file in the fruits
group and including it in your defaults list:
# conf/config.yaml
defaults:
- fruits/emptyfruit
- fruits:
- banana
Here's the empty file:
# conf/fruits/emptyfruit.yaml
At the command line:
$ python main.py 'fruits=[]'
0
🐛 Bug
Description
When selecting
n
configs from a groupgroup_name
, I would expect the resultingDictConfig
corresponding to thegroup_name
key in the composed config to have lengthn
. This seems to be true except in the casen = 0
, where thegroup_name
key cannot be found in the composed config at all.Checklist
To reproduce
Minimal Code/Config snippet to reproduce
Here's an element of the
fruits
config group:Here's the main config:
Here's a Python script:
Running this with
python main.py
orpython main.py fruits=[banana]
produces the output1
, as expected. However, running it asHYDRA_FULL_ERROR=1 python main.py fruits=[]
produces the following error:Stack trace/error message
Expected Behavior
I would expect running the last command to produce the output
0
.System information
Additional context
This isn't that much of a problem when the
fruits
is only expected by Python code, where input validation can be used. However, it's more of a problem when the key is expected by other parts of the Hydra config, e.g. suppose we had the following somewhere else in the config:Then we need to remove the
fruits
sub-key entirely from thebasket
key if the basket doesn't contain any fruits. This might need to be duplicated elsewhere if other keys rely on thefruits
key as well.