Skip to content
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

Add xarray.backends.NoMatchingEngineError #5351

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shoyer
Copy link
Member

@shoyer shoyer commented May 19, 2021

@alexamici
Copy link
Collaborator

alexamici commented May 21, 2021

@shoyer I have two suggestions:

  1. I would very much prefer to have the exception in the top level module in order to allow:
import xarray as xr
try:
    ds = xr.open_dataset(...)
except xr.NoMatchingEngineError:
    ... 
  1. I feel that the error message is very clear, but the name of the exception seems slightly confusing as it appears to imply that no engine can open the dataset when it is only that we couldn't autodetect which engine to use just inspecting at the filename_or_obj. I would prefer something along the lines of EngineAutodetectionError. But I don't feel too strong about it.

@shoyer
Copy link
Member Author

shoyer commented May 26, 2021

@alexamici good points! I will revise this soon :)

@mgunyho
Copy link
Contributor

mgunyho commented Feb 9, 2022

Hi,

I see this was ready to merge, but I would like to still comment on the error message a bit.

IMO, it should be emphasized a bit more that the file might not exist, which I suspect happens much more often than a backend missing. I came across this PR after me and a colleague struggled with opening a netCDF file for twenty minutes, trying to install different backends and such, until we realized that there was a typo in the filename we were trying to open.

The error message could be something like:

Error opening {store_spec}: The file does not exist or is not supported by any of xarray's currently installed IO backends {installed}. Consider explicitly ...

It's a small change, but in the current version there is a risk that a beginner who knows nothing about storage backends gets stuck on "did not find a match in any of the installed backends" and goes on a wild goose chase installing packages like we did.

@headtr1ck
Copy link
Collaborator

How about inheriting from FileNotFoundError, this Exception type would be the first guess of people.
And while at it, you could inherit from ValueError to keep it backwards compatible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

xarray 0.18.0 raises ValueError, not FileNotFoundError, when opening a non-existent file
5 participants