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

Unexpected behavior when setting field to itself #449

Closed
4 tasks done
1matthewli opened this issue Dec 7, 2020 · 1 comment · Fixed by #466
Closed
4 tasks done

Unexpected behavior when setting field to itself #449

1matthewli opened this issue Dec 7, 2020 · 1 comment · Fixed by #466
Labels
bug Something isn't working
Milestone

Comments

@1matthewli
Copy link

1matthewli commented Dec 7, 2020

Describe the bug
Under certain conditions, setting an entry of config to itself ends up clearing the entry entirely.

To Reproduce

cfg1 = OmegaConf.create({'a': 10})
cfg2 = OmegaConf.create({'b': 20})
cfg1["c"] = cfg2
print(cfg1["c"])
cfg1["c"] = cfg1["c"]
print(cfg1["c"])

The first print will be as expected, and the second print will be empty dictionary.
One workaround I have figured out is to set cfg2.__dict__['_metadata'].ref_type = typing.Any right after creating it, and it works as expected.

Expected behavior
It is expected for both prints to be the same, potentially with some interpolation resolution happening on access.

Additional context

  • OmegaConf version: 2.0.4
  • Python version: 3.7.9
  • Operating system : Ubuntu 16.04.7 LTS
  • Please provide a minimal repro
@1matthewli 1matthewli added the bug Something isn't working label Dec 7, 2020
@omry
Copy link
Owner

omry commented Dec 7, 2020

Thanks for reporting.

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.

2 participants