-
Notifications
You must be signed in to change notification settings - Fork 116
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
Deprecate subclassing Dict #663
Comments
Migration SuggestionsFor those who use are currently using this feature, here are a few ways to migrate away from subclassing Use a
|
I can't find a good workaround for this situation: @dataclass
class Config1(Dict[str, Any]):
x: int = 0
@dataclass
class Config2(Dict[str, Any]):
y: int = 0
cfg = OmegaConf.merge(Config1, Config2) I wish the following would work (currently it doesn't): @dataclass
class Config1:
x: int = 0
@dataclass
class Config2:
y: int = 0
cfg = OmegaConf.structured(Config1)
with open_dict(cfg):
cfg = OmegaConf.merge(cfg, Config2) |
When I try to run the code above, I get this error: Traceback (most recent call last):
...
omegaconf.errors.ValidationError: Merge error: Config2 is not a subclass of Config1. value: {'y': 0}
full_key:
object_type=Config1 Is this a bug? I feel that it makes sense to allow merging different structured configs in the context of |
@odelalleau, you can merge a dict like config onto a Structured Config, or another Structured Config of the same type or of a subclass. @Jasha10, I dunno - this has nothing to do with struct mode. What are you expecting the resulting underlying type to be? |
Good point. |
Moving the discussion to #721 to avoid polluting this issue |
It is proposed to deprecate and then remove support for subclassing
Dict
in structured configs.The motivations are:
OmegaConf.to_object
: Instantiate structured configs #502 on handling extra fields when converting from DictConfig to dataclass/attrs class).This is related to #657, which proposes to remove support for subclassing
Dict[Any, ...]
and only allow subclassingDict[str, ...]
.The text was updated successfully, but these errors were encountered: