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] omegaconf is doing interpolation during merges when it shouldnt #1125

Closed
alexeib opened this issue Nov 5, 2020 · 0 comments
Closed
Labels
bug Something isn't working
Milestone

Comments

@alexeib
Copy link

alexeib commented Nov 5, 2020

repro:

>>> from dataclasses import dataclass
>>> from typing import List
>>> @dataclass
... class test_class:
...     x: List[float] = "${optimization.lr}"
...
>>> dc = test_class()
>>> a = DictConfig(dc)
>>> b = DictConfig({"x": [0.1]})
>>> OmegaConf.merge(a,b)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/private/home/abaevski/.conda/envs/fairseq-fp16-20200821/lib/python3.6/site-packages/omegaconf/omegaconf.py", line 321, in merge
    target.merge_with(*others[1:])
  File "/private/home/abaevski/.conda/envs/fairseq-fp16-20200821/lib/python3.6/site-packages/omegaconf/basecontainer.py", line 327, in merge_with
    self._format_and_raise(key=None, value=None, cause=e)
  File "/private/home/abaevski/.conda/envs/fairseq-fp16-20200821/lib/python3.6/site-packages/omegaconf/base.py", line 101, in _format_and_raise
    type_override=type_override,
  File "/private/home/abaevski/.conda/envs/fairseq-fp16-20200821/lib/python3.6/site-packages/omegaconf/_utils.py", line 675, in format_and_raise
    _raise(ex, cause)
  File "/private/home/abaevski/.conda/envs/fairseq-fp16-20200821/lib/python3.6/site-packages/omegaconf/_utils.py", line 591, in _raise
    raise ex  # set end OC_CAUSE=1 for full backtrace
omegaconf.errors.ConfigKeyError: str interpolation key 'optimization.lr' not found
	full_key:
	reference_type=Any
	object_type=test_class

if instead you set a to be DictConfig initialized from a dict, everything works

>>> a = DictConfig({'x': '${optimization.lr}'})
>>> OmegaConf.merge(a,b)
{'x': [0.1]}
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

2 participants