Defining dataclasses to introduce schema seems like a great idea. But, sometimes we have missing values, and there is omegaconf.MISSING to express this. However:
from omegaconf import OmegaConf, MISSING
import omegaconf
from dataclasses import dataclass
@dataclass(frozen=True)
class A:
x: int = MISSING
# If we are allowed to instantiate this
a = OmegaConf.create(a)
print(a)
# ==> {'a': {'x': '???'}}
# Then we should be allowed to instantiate it again:
OmegaConf.to_container(
a,
throw_on_missing=False,
structured_config_mode = omegaconf.SCMode.INSTANTIATE
)
# ...
# MissingMandatoryValue: Structured config of type `A` has missing mandatory value: x
# full_key: x
# object_type=A
The use case is we may have partially filled objects that we want to manipulate, construct new configs out of, etc.
The problem is that this line forgets .to_container's throw_on_missing argument:
and inside this function, it could be allowed here:
It's currently hard for me logistically to contribute the simple PR, but hopefully I have identified the changes necessary sufficiently if the maintainers agree this should be supported.
Defining dataclasses to introduce schema seems like a great idea. But, sometimes we have missing values, and there is
omegaconf.MISSINGto express this. However:The use case is we may have partially filled objects that we want to manipulate, construct new configs out of, etc.
The problem is that this line forgets
.to_container'sthrow_on_missingargument:omegaconf/omegaconf/basecontainer.py
Line 289 in 7dae67e
and inside this function, it could be allowed here:
omegaconf/omegaconf/dictconfig.py
Line 741 in 7dae67e
It's currently hard for me logistically to contribute the simple PR, but hopefully I have identified the changes necessary sufficiently if the maintainers agree this should be supported.