You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In order to facilitating suggesting a specific backend to install (e.g., to improve error messages from opening tutorial datasets #5291), I would suggest that Xarray always registers its own backend entrypoints. Then we make the following changes to the plugin protocol:
guess_can_open() should work regardless of whether the underlying backend is installed
installed() returns a boolean reporting whether backend is installed. The default method in the base class would return True, for backwards compatibility.
open_dataset() of course should error if the backend is not installed.
This will let us leverage the existing guess_can_open() functionality to suggest specific optional dependencies to install. E.g., if you supply a netCDF3 file: Xarray cannot find a matching installed backend for this file in the installed backends ["h5netcdf"]. Consider installing one of the following backends which reports a match: ["scipy", "netcdf4"]
Me too, I was thinking about something like that to fix the error message.
Let me try to implement it. But I have really no time this week and the next one, sorry. I can do it after 23th if for you is ok.
Another advantage of "always registering" backends is that I think it will make for a better user-experience when installing a new dependency for IO via pip, because they won't have to restart their Python session: #5291 (comment)
Currently, Xarray's internal backends don't get registered unless the necessary dependencies are installed:
xarray/xarray/backends/netCDF4_.py
Lines 567 to 568 in 1305d9b
In order to facilitating suggesting a specific backend to install (e.g., to improve error messages from opening tutorial datasets #5291), I would suggest that Xarray always registers its own backend entrypoints. Then we make the following changes to the plugin protocol:
guess_can_open()
should work regardless of whether the underlying backend is installedinstalled()
returns a boolean reporting whether backend is installed. The default method in the base class would returnTrue
, for backwards compatibility.open_dataset()
of course should error if the backend is not installed.This will let us leverage the existing
guess_can_open()
functionality to suggest specific optional dependencies to install. E.g., if you supply a netCDF3 file:Xarray cannot find a matching installed backend for this file in the installed backends ["h5netcdf"]. Consider installing one of the following backends which reports a match: ["scipy", "netcdf4"]
Does this reasonable and worthwhile?
CC @aurghs @alexamici
The text was updated successfully, but these errors were encountered: