-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
more friendly error message in case no chunk manager is available #9676
base: main
Are you sure you want to change the base?
Conversation
Much better! |
Thanks - I had a PR on this but don't mind closing mine in favor of this one. There is also #7963 which seems related. |
wow, I don't know how I missed two open PRs that aim to do something similar in different ways. Which one do we take? If we merge this one your PR might still be valuable since it also changes the error message if there are chunk managers but not the one that was requested. |
Shall we merge? |
Sorry for dropping the ball on reviewing / merging these guys 😞 Let's merge this one.
This change would also be useful but is much less likely to come up. |
Co-authored-by: Tom Nicholas <[email protected]>
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.
While this could be further improved in cases like cubed being installed but dask not (when there would not be 0 chunkmanagers installed), this PR on it's own addresses the confusing error that 99% of users are encountering so should be merged asap.
If you change the other ValueError to ImportError on line 109 of parallelcompat.py the failing test should pass. |
def test_fail_on_nonexistent_chunkmanager( | ||
self, register_dummy_chunkmanager | ||
) -> None: | ||
with pytest.raises(ImportError, match="unrecognized chunk manager foo"): |
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.
there might be two reasons why this fails: one, there's a typo, in which case I'd say it would be better to raise a ValueError
(the issue is the caller's input), while the second reason is indeed that the library that provides the requested chunk manager was not installed or fails to import.
In the case when there's no chunk manager at all, we know that the user needs to install a library and I can understand using a ImportError
. However, in the case where there's at least one chunk manager I don't think we can figure out whether the issue was a user error or a missing library (at least, without maintaining a list of known chunk managers and suggesting sufficiently "close" names), so I think this should still be expecting a ValueError
:
with pytest.raises(ImportError, match="unrecognized chunk manager foo"): | |
with pytest.raises(ValueError, match="unrecognized chunk manager foo"): |
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.
You raise a good point about ambiguity, but I also think we could reasonably just say (imprecisely) "with this user input were unable to import a necessary library, so there's still an ImportError
underneath", which then has the advantage of consistency of error types for users.
The current error message when trying to use a chunked-array related method without actually having a chunk manager available is:
That's pretty confusing, so this catches the case where no chunk manager is available and raises an error with guidance on how to fix that.
whats-new.rst