-
Notifications
You must be signed in to change notification settings - Fork 122
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
struct config is not behaving as dict. when calling get #425
Labels
bug
Something isn't working
Milestone
Comments
Thanks for reporting, this does seem like a bug.
|
I observed the same behavior with To reproduce from dataclasses import dataclass
from enum import Enum
from omegaconf import OmegaConf
from typing import Dict
class Color(Enum):
RED = "red"
GREEN = "green"
BLUE = "blue"
@dataclass
class ColorConf:
colors: Dict[Color, float] = None
from omegaconf import OmegaConf
from dataclasses import dataclass
from enum import Enum
from typing import Dict
class Color(Enum):
RED = "red"
GREEN = "green"
BLUE = "blue"
@dataclass
class ColorConf:
colors: Dict[Color, float] = None
config = OmegaConf.structured(ColorConf({Color.RED: 0.1}))
print(config.colors.pop(Color.RED, None)) # 0.1
print(config.colors.pop(Color.BLUE, None)) # None
config.colors.pop("blue", None) # Errors with any key that is not Enum which raises omegaconf.errors.KeyValidationError: Key 'blue' is incompatible with the enum type 'Color', valid: [RED, GREEN, BLUE]
full_key: colors.blue
reference_type=Dict[Color, float]
object_type=dict Even though this is unexpected, it might be the intended behavior. |
@guillaumegenthial , at a glance, it looks like a different problem. can you file another issue? |
sure. EDIT: #471 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
struct config is not behaving as dict.
in python
DictConfig is expected to behave the same
currently struct DictConfg is throwing a exception
To Reproduce
Expected behavior
The text was updated successfully, but these errors were encountered: