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

Structured conf with parent + default-factory field does not have correct initial value (distinct from #817) #830

Closed
rsokl opened this issue Nov 30, 2021 · 1 comment · Fixed by #832
Assignees
Labels
bug Something isn't working priority_medium
Milestone

Comments

@rsokl
Copy link

rsokl commented Nov 30, 2021

Running against omegaconf hash f362b5c (latest commit on master as of posting this)

This is very similar to #817 , but the issue arises whenever the parent's attribute is anything other than MISSING

from dataclasses import field, dataclass
from typing import Any

from omegaconf import OmegaConf

@dataclass
class BasicConf:
    setup: Any = 1


@dataclass
class Config(BasicConf):
    setup: Any = field(default_factory=lambda: list(["hi"]))
>>> Config.setup
1
>>> Config().setup
['hi']
>>> OmegaConf.create(Config)
{'setup': 1}

I would expect OmegaConf.create to create the config based off of the dataclass-instance, not the dataclass-object. This led to a hard-to-find bug downstream in a Hydra application, where a mutable default value was silently being ignored.

@Jasha10
Copy link
Collaborator

Jasha10 commented Dec 2, 2021

Awesome, thanks for reporting this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority_medium
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants