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
Describe the bug
The OmegaConf.update method throws an AssertionError when the key argument passed to OmegaConf.update points inside of a DictConfig instance whose _content is None.
To Reproduce
fromdataclassesimportdataclassfromtypingimportOptionalfromomegaconfimportOmegaConffrompytestimportraises@dataclassclassChild:
x: int=123y: int=456@dataclassclassParent:
child: Optional[Child] =Nonecfg=OmegaConf.structured(Parent)
withraises(AssertionError, match="Unexpected type for root: NoneType"):
OmegaConf.update(cfg=cfg, key="child.x", value=789)
Expected behavior
I think OmegaConf should fail gracefully (or maybe not fail at all) in this situation rather than throwing an AssertionError.
Additional context
OmegaConf version: 2.2.3
Python version: 3.9.12
Operating system: ubuntu 20.04
Please provide a minimal repro
Edit:
Here is the full traceback:
$ OC_CAUSE=1 python repro2.py
Traceback (most recent call last):
File "/home/homestar/dev/mrepo/pysc/repro2.py", line 17, in <module>
OmegaConf.update(cfg=cfg, key="child.x", value=789)
File "/home/homestar/miniconda3/envs/pysc/lib/python3.10/site-packages/omegaconf/omegaconf.py", line 709, in update
assert isinstance(
AssertionError: Unexpected type for root: NoneType
The text was updated successfully, but these errors were encountered:
I feel that OmegaConf.update's behavior should be consistent with that of OmegaConf.merge: calling update should result in a node out.child that is a non-None structured config backed the Child class.
I feel that OmegaConf.update's behavior should be consistent with that of OmegaConf.merge: calling update should result in a node out.child that is a non-None structured config backed the Child class.
Describe the bug
The
OmegaConf.update
method throws anAssertionError
when thekey
argument passed toOmegaConf.update
points inside of aDictConfig
instance whose_content
isNone
.To Reproduce
Expected behavior
I think OmegaConf should fail gracefully (or maybe not fail at all) in this situation rather than throwing an AssertionError.
Additional context
Edit:
Here is the full traceback:
The text was updated successfully, but these errors were encountered: