-
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 initializing from a Structured Config with incorrect type #559
Improve error message when initializing from a Structured Config with incorrect type #559
Conversation
a3a2a0e
to
11dd051
Compare
Can you add a test when the error is in a deeper level to see the resulting error message is reasonable? maybe something like: create=lambda: OmegaConf.structured(
ConcretePlugin(params=ConcretePlugin.FoobarParams(foo="x")) # type: ignore
), |
3f40dbb
to
2610a53
Compare
omegaconf/_utils.py
Outdated
parent=dummy_parent, | ||
) | ||
except ValidationError as ex: | ||
dummy_parent._format_and_raise(key=name, value=value, cause=ex) |
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.
can you try to use format_and_raise()
directly instead of through the dummy parent?
it can probably make things a bit cleaner when testing this.
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.
In f2a1bfd I've switched from dummy_parent._format_and_raise(...)
to format_and_raise(node=None, ...)
.
The disadvantage of this change is that we no longer have object_type
information in the error message (as dummy_parent
was providing the object_type
).
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.
Besides the object_type
issue, the error messages are also not reporting full_key
accurately. I think that reporting on full_key
would be easiest if we pass a parent_node
into the get_structured_config_data
function (so that full_key
could be computed using the parent config). This change would require some plumbing of the methods that call get_structured_config_data
. I can give it a try if you're interested...
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.
I think this will trivially easier once we have the structured_ir diff baked and ready.
for now this is good enough.
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.
looking better.
make a pass to cleanup left overs from previous attempt.
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.
awesome :)
Can you add a news fragment file? feel free to squash and merge in once you do. |
… incorrect type (omry#559) * test error message * use format_and_raise() directly * add 435.bugfix news fragment
Closes #435.
Based on http://paste.ubuntu.com/p/d7zKBpG9rg/