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

Patch upstream omegaconf issue #830 #172

Merged
merged 5 commits into from
Dec 3, 2021
Merged

Conversation

rsokl
Copy link
Contributor

@rsokl rsokl commented Dec 3, 2021

Closes #170

For users using omegaconf 2.1.1 or earlier, we provide a patch of an upstream bug.

Before:

# bug from omegaconf
>>> A = make_config(x=1)
>>> B = make_config(x=[1, 2], bases=(A,))
>>> instantiate(B)
{'x': 1}

After:

# hydra-zen 0.4.0 circumvents bug
>>> A = make_config(x=1)
>>> B = make_config(x=[1, 2], bases=(A,))
>>> instantiate(B)
{'x': [1, 2]}

We achieve this by detecting the particular conditions for which this bug occurs:

  • The user is not using a newer version of omegaconf, where this bug is fixed
  • and.. the config sets a mutable default value via default-value factory
  • and.. the config inherits from one or more parent dataclasses
  • and.. the parent also provides a field of the same name
  • and.. the parent's field is not a default-value factory

and only under these circumstances will we automatically transform

make_config(x=[1, 2], bases=(A,))

to

make_config(x=builds(list, [1, 2]), bases=(A,))

which ensures that the resulting config will instantiate as-expected.

We provide this automatic support for all use-cases of make_config and builds. We cannot provide this automatic support for hydrated_dataclass, however we do still detect the conditions and raise a HydraZenValidationError in such circumstances.

@rsokl rsokl added bug Something isn't working hydra/omegaconf Tied to behavior of hydra/omegaconf labels Dec 3, 2021
@rsokl rsokl added this to the hydra-zen 0.4.0 milestone Dec 3, 2021
@rsokl rsokl changed the title Patch upstream omegaconf #830 Patch upstream omegaconf issue #830 Dec 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hydra/omegaconf Tied to behavior of hydra/omegaconf
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bypassing omegaconf issue that leads to unexpected results/bug
1 participant