-
Notifications
You must be signed in to change notification settings - Fork 123
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
Resolving nested structured config of Lists with interpolation raises ValidationError #1005
Comments
Are there any updates on whether this is planned to be fixed? I think it is important to handle nested interpolations. |
I believe there is as typo in the original repro. from dataclasses import dataclass, field
from typing import List
from omegaconf import MISSING, OmegaConf
@dataclass
class User:
name: str = MISSING
@dataclass
class Config:
user: User = User("John")
admins: List[User] = field(default_factory=lambda: ["${user}"])
cfg: Config = OmegaConf.structured(Config)
OmegaConf.resolve(cfg) # this raises ValidationError
Here's the full backtrace:
|
@binkjakub the OmegaConf team is currently volunteer-run and lacking in bandwidth. I cannot make a promise as to when this will be fixed. Edit: I've submitted PR #1139 to fix this. |
This PR closes omry#1005, fixing a bug where a validation error was raised when an interpolation points to a structured config from within a typed list. ```python from dataclasses import dataclass, field from omegaconf import MISSING, OmegaConf @DataClass class User: name: str = MISSING @DataClass class Config: user: User = User("John") users: list[User] = field(default_factory=lambda: ["${user}"]) print(OmegaConf.structured(Config)) ``` BEFORE ------ ```text $ python repro.py $ python repro.py Traceback (most recent call last): ... omegaconf.errors.ValidationError: Invalid type assigned: str is not a subclass of User. value: ${user} full_key: users[0] reference_type=List[User] object_type=list ``` AFTER ----- ```text $ python repro.py {'user': {'name': 'John'}, 'users': [{'name': 'John'}]} ```
This PR closes omry#1005, fixing a bug where a validation error was raised when an interpolation points to a structured config from within a typed list. ```python from dataclasses import dataclass, field from omegaconf import MISSING, OmegaConf @DataClass class User: name: str = MISSING @DataClass class Config: user: User = User("John") users: list[User] = field(default_factory=lambda: ["${user}"]) cfg = OmegaConf.structured(Config) OmegaConf.resolve(cfg) print(cfg) ``` BEFORE ------ ```text $ python repro.py $ python repro.py Traceback (most recent call last): ... omegaconf.errors.ValidationError: Invalid type assigned: str is not a subclass of User. value: ${user} full_key: users[0] reference_type=List[User] object_type=list ``` AFTER ----- ```text $ python repro.py {'user': {'name': 'John'}, 'users': [{'name': 'John'}]} ```
Describe the bug
This is a follow up to #847; OmegaConf raises a ValidationError when trying to use an interpolation inside a structured ListConfig.
To Reproduce
Expected behavior
I expect this resolution to not fail.
Additional context
The text was updated successfully, but these errors were encountered: