Description
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?