You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If we merge a MISSING field, with an attrs class structured config that uses default factory (e.g., for specifying defaults list in hydra), this expand call
and since it is given a class, it will use attrs.Attribute's attribute.default value as the values to set attributes. This normally works, but however, if the attribute uses default factory, the attribute.default is an attrs.Factory object! Then OmegaConf errors out.
To Reproduce
[skipping long stack frames]
The text was updated successfully, but these errors were encountered:
In a sense this is due to that OmegaConf infers types from values rather than type annotations. I wonder if there can be a way to use type annotations instead (which would also address the structure configs inheritance issue described in facebookresearch/hydra#2227 )
I ran into this bug as well just now. However, I have found it does work correctly with the stdlib dataclasses. This can serve as a possible workaround for others who run into this, and may aid in tracking down the source of the problem.
For reference, here's a minimalistic dataclasses example that works correctly for which the equivalent attrs version throws the exception described in the original report:
If we merge a
MISSING
field, with anattrs
class structured config that uses default factory (e.g., for specifying defaults list in hydra), thisexpand
callomegaconf/omegaconf/basecontainer.py
Lines 327 to 342 in 6a4fd51
will call
node._set_value(attrs_class)
, which callsget_attr_data(attrs_class)
.omegaconf/omegaconf/_utils.py
Lines 313 to 334 in 6a4fd51
and since it is given a class, it will use
attrs.Attribute
'sattribute.default
value as the values to set attributes. This normally works, but however, if the attribute uses default factory, theattribute.default
is anattrs.Factory
object! Then OmegaConf errors out.To Reproduce
[skipping long stack frames]
The text was updated successfully, but these errors were encountered: