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 #431

Closed
alexeib opened this issue Nov 5, 2020 · 2 comments · Fixed by #432
Closed

[Bug] omegaconf is doing interpolation during merges when it shouldnt #431

alexeib opened this issue Nov 5, 2020 · 2 comments · Fixed by #432
Labels
bug Something isn't working

Comments

@alexeib
Copy link

alexeib commented Nov 5, 2020

copied from hydra issue here:
facebookresearch/hydra#1125

repro:

from omegaconf import OmegaConf
from dataclasses import dataclass
from typing import List
@dataclass
class test_class:
    x: List[float] = "${optimization.lr}"

a = OmegaConf.structured(test_class())
b = OmegaConf.create({"x": [0.1]})
OmegaConf.merge(a,b)

Exception:

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]}
@alexeib alexeib added the bug Something isn't working label Nov 5, 2020
@omry
Copy link
Owner

omry commented Nov 5, 2020

@pereman2, can you take a look?
This should not resolve the interpolation.

I would like this fixed for 2.0 as well.

@pereman2
Copy link
Contributor

pereman2 commented Nov 5, 2020

Sure

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

Successfully merging a pull request may close this issue.

3 participants