-
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
improve error message when creating a DictConfig from a bad dataclass #701
Conversation
Could you paste what the new error message looks like? |
from dataclasses import dataclass
from omegaconf import OmegaConf
@dataclass
class ConnectConf:
# The root cause is the equals sign in ``default=``
api_key: str = "${oc.env:API_KEY, default=abc123}"
@dataclass
class TasksConf:
connect: ConnectConf = ConnectConf()
OmegaConf.structured(TasksConf) Output:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Looks like a good improvement. $ cat tmp658.py
from typing import Tuple
from dataclasses import dataclass
from omegaconf import OmegaConf
@dataclass
class TopLvlConf:
foo: Tuple[str] = 123
OmegaConf.create(TopLvlConf) $ python tmp658.py
Traceback (most recent call last):
...
omegaconf.errors.ValidationError: Invalid value assigned: int is not a ListConfig, list or tuple.
full_key:
object_type=None |
I am working on a diff that will close #658. |
I've pushed a commit to patch #658. $ python tmp658.py
Traceback (most recent call last):
...
omegaconf.errors.ValidationError: Invalid value assigned: int is not a ListConfig, list or tuple.
full_key: foo
object_type=None |
Good catch Jasha, and thanks for the patch. |
Closes #697
Closes #658
This is not really fixing it completely, but the error message is more helpful.
It does indicate the offending type. and the key inside it instead of the full key in the config object. (providing the full key will be handled as a part of #514.