In Hydra config YAML files, I have the following structure in the file inner.yaml:
key_a:
- entry_a_1: xxxx
entry_a_2: xxxxx
- entry_a_3: xxxx
entry_a_4: xxxxx
What I want is to be able to override the entry_a_M from another YAML file, for example at the file outer.yaml:
defaults:
- inner_config@outer_inner_config: inner
outter_inner_config:
entry_a_1: YYYY
I have tried with key_a.0.entry_a_1: WWWW and other combinations but it doesn't work.
Please note:
- I don't want to override it from the CLI
- If there are keys in each list item, e.g.
- key: [entry_a_1...]then it can be done, as shown in question here. But it is not my case and it would not work with having that key in the list entry, in my case.
Any answers on that?
This is not supported directly. Lists are replaced by
OmegaConf.merge(), which is what Hydra is using to merge the config objects.My recommendation is to convert your list to a dictionary. This will allow you to override it by the key. If your code needs to access the values as a list, you can use the built in OmegaConf resolver oc.dict.values.
From the docs:
This can be utilized with
instantiateby placing the source dictionary outside of the object being instantiated, e.g:To complete the solution, you can use the pattern described here to select multiple configs from the same config group. Refactoring the objects in the config above into two separate config files and using the defaults list:
objects/obj1.yaml:
objects/obj2.yaml:
config.yaml: