-
Notifications
You must be signed in to change notification settings - Fork 112
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
ConfigKeyError for interpolation keys when merging configs #442
Comments
Hi. Can you clean up your repro a bit?
Finally, can you also try against master? |
Hi, thanks for reply. Here is a minimal script to get the error (tried against master & v2.0.5): from omegaconf import OmegaConf
base_conf_source = {
"key_a": "large_object_a",
"key_b": "large_object_b",
"key_c": "large_object_c",
"list": [
"${key_a}",
"${key_b}",
"${key_c}",
]
}
base_conf = OmegaConf.create(base_conf_source)
# client_y wants only "large_object_a" and "large_object_c" in list
client_y_override_source = {
"list": [
"${key_a}",
"${key_c}",
]
}
client_y_override = OmegaConf.create(client_y_override_source)
# I believe that we should not get error here
# since interpolations are evaluated lazily on access
client_y_conf = OmegaConf.merge(base_conf, client_y_override)
# expected result
"""
key_a: large_object_a
key_b: large_object_b
key_c: large_object_c
list:
- ${key_a}
- ${key_c}
""" error:
|
Yup, now I understand. Thanks for reporting. |
As a workaround, I suggest that you leave the list empty and allow every case to populate it. base_conf_source = {
"key_a": "large_object_a",
"key_b": "large_object_b",
"key_c": "large_object_c",
"list": "???" # missing value, will raise an exception if accessed before overriden.
} |
Thanks, it worked. Unfortunately, I can't leave the list empty, as most clients use the default list. It leads to more config duplication for my case. |
Feel free to try to solve it master and sending a PR. |
Description of the bug
When merging configurations, if the secondary config contains an interpolation key that refers to the primary (base/default) config, omegaconf fails to merge and raises
omegaconf.errors.ConfigKeyError: str interpolation key 'foo' not found
error.Assume that there is a default config for all clients. In this config, there is a list with large objects and they are defined separately for reusability. Some clients need to modify this list in the following ways:
To Reproduce
Client Y and Z have errors.
Expected behavior
This operations can be done if omegaconf does not try to resolve interpolations when merging configurations. Actually the documentation says "interpolations are evaluated lazily on access". See the
expected result
parts in the script.Additional context
Note: I would like to open a PR to fix this issue, but before that I want to hear your opinions and suggestions about the problem.
The text was updated successfully, but these errors were encountered: