-
-
Notifications
You must be signed in to change notification settings - Fork 404
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
Added DataError for irrecoverable data interface initialization errors #2041
Conversation
@jlstevens this is one PR that does need your review. If you agree this is a decent approach and can't think of any more errors to improve this is ready to merge. |
9782c38
to
50f4516
Compare
@@ -162,6 +166,8 @@ def initialize(cls, eltype, data, kdims, vdims, datatype=None): | |||
try: | |||
(data, dims, extra_kws) = interface.init(eltype, data, kdims, vdims) | |||
break | |||
except DataError: | |||
raise |
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.
Isn't something similar needed in the try/except where all the data interfaces are tried, one by one?
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'm confused, that's exactly where this is.
I agree this is important issue to address and adding a custom exception like this makes a lot of sense to me. Just some ideas about possible names:
I think next to |
This doesn't make much sense to me, if you look where this is mostly used it's in cases where a particular interface identifies a specific error condition and can raise it directly. Adding extra indirection makes little sense when the original place where the error is raised already has all that information. Might be good if @jbednar chimes in here as well. |
|
Maybe I didn't consider your proposal correctly. I wouldn't mind if the DataError automatically adds a bit about the interfaces and adds a bit that points to the docs section that describes the allowed data types, e.g. to Gridded Data, Tabular Data or Geometry Data (once that user guide exists). |
In other words whatever raises the error provides a specific error message and the error then adds a more generic bit about data interfaces and points to the docs. |
To make that a bit more concrete, it might look something like this:
The second half would be auto-generated based on the Interface type. |
Right. That is the sort of thing I was think of! Edit: Minor point but I would format it so the core message is separate from the extra help. i.e
|
Okay here are some samples from what I've implemented now:
and:
and:
and:
and:
I'll update the last one once there is a user guide for geometry (path, contour, polygon) data. |
@jlstevens If the tests pass this is ready to merge. I think this is going to be a huge improvement, but I imagine we'll be adding more specific errors over time. We should collect uninformative "None of the available storage backends were able to support the supplied data format." somewhere and aim to ensure that a user always gets a more specific error. |
Agreed!
Also a good idea. If you are happy with this, go ahead and merge once the tests pass. |
Great, tests are now passing. I'll go ahead and merge. |
#2041) * Added DataError for irrecoverable data interface init errors * Added additional interface info to DataError * Fixed DataArray vdim error * Added DataError for missing xarray coords * Fixed error for GriddedInterface shape mismatch * Updated MultiInterface error tests
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
We really need to do something about Interface data errors, particularly those that can provide clear and unambiguous exception message when the data is definitely incorrectly defined. In this PR I introduce a
DataError
, which prevents the Interface from trying to fall back to other data types and therefore allows raising a proper exception message. This approach is much simpler than what I outlined in #1986 and makes the process of raising specific exceptions quite simple.Addresses:
#1762
#1867