-
Notifications
You must be signed in to change notification settings - Fork 116
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
Merging configs unnecessarily tries to access base config interpolation #598
Comments
This is a feature. In [9]: OmegaConf.merge({"a" :"${b}", "b": {"a": 1}}, {"a": {"c": 3}})
Out[9]: {'a': {'a': 1, 'c': 3}, 'b': {'a': 1}} |
Your config is also broken. a node should not interpolate to itself. |
I guess I just gave the most minimal example I could think of. Here is one that doesn't involve any broken configs:
|
This kind of merge where you are merging things in different levels is a bad idea and is guaranteed to give you issues in various cases. As I said, resolving the interpolation during merge is an intentional behavior. Can you give some context on what you are trying to achieve here? |
Looking at your second example, you are merging {'a': '${a}', 'b': '${a}'} on {'a': '', 'b': '${a}'} and you are getting {'a': '${a}', 'b': '${a}'} This looks like a perfect interpretation to me. Closing as invalid, feel free to follow up with more context. |
I now noticed that the version you tested against is 2.0.6. $ ipython
Python 3.8.5 (default, Sep 4 2020, 07:30:14)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.19.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from omegaconf import *
In [2]: __version__
Out[2]: '2.1.0dev21'
In [3]: base = OmegaConf.create({'a': '', 'b': '${a}'})
...: override = OmegaConf.create({'a': 'foo', 'nested': {'a': '${a}', 'b': '${a}'}})
...: OmegaConf.merge(base, override.nested)
Out[3]: {'a': '${a}', 'b': '${a}'} |
as a side note, your config is still broken because the result contains self interpolation. |
Thanks, the 2.1.0 dev release works! |
If you happen to know off the top of your head, just curious what changed that lets the merging succeed in the newer version despite the interpolation being invalid? In [3]: base = OmegaConf.create({'a': '', 'b': '${a}'})
...: override = OmegaConf.create({'a': 'foo', 'nested': {'a': '${a}', 'b': '${a}'}})
...: OmegaConf.merge(base, override.nested)
Out[3]: {'a': '${a}', 'b': '${a}'} |
Many bugs have been fixed. Many of which are around the merge functionality. |
Describe the bug
When merging configs, OmegaConf seems to attempt to access interpolated values in the base config.
To Reproduce
This produces the behavior:
Expected behavior
The expected behavior is to produce the merged config
{'a': ''}
. I understand that the input configbase
may be considered as invalid, but it would be great if that did not stop the merging from working correctly.Additional context
The text was updated successfully, but these errors were encountered: