Feature request: raise more informative error message for `xr.open_dataset(list_of_paths)`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
Is your feature request related to a problem?
I sometimes use xr.open_dataset instead of xr.open_mfdataset on multiple paths. I propose to raise a more informative error message than ValueError: did not find a match in any of xarray's currently installed IO backends ['netcdf4', 'h5netcdf', 'scipy', 'cfgrib']. Consider explicitly selecting one of the installed engines via the ``engine`` parameter, or installing additional IO dependencies, see:
https://docs.xarray.dev/en/stable/getting-started-guide/installing.html
https://docs.xarray.dev/en/stable/user-guide/io.html.
import xarray as xr
xr.__version__ # '2022.3.0'
ds = xr.tutorial.load_dataset("air_temperature")
ds.isel(time=slice(None,1500)).to_netcdf("file1.nc")
ds.isel(time=slice(1500,None)).to_netcdf("file2.nc")
xr.open_mfdataset(["file1.nc","file2.nc"]) # works
xr.open_mfdataset("file?.nc") # works
# I understand what I need to do here
xr.open_dataset("file?.nc") # fails FileNotFoundError: No such file or directory: b'/dir/file?.nc'
# I dont here; I also first try to check whether one of these files is corrupt
xr.open_dataset(["file1.nc","file2.nc"]) # fails ValueError: did not find a match in any of xarray's currently installed IO backends ['netcdf4', 'h5netcdf', 'scipy', 'cfgrib']. Consider explicitly selecting one of the installed engines via the ``engine`` parameter, or installing additional IO dependencies, see: links
Describe the solution you'd like
directing the user towards the solution, i.e. "found path as list, please use open_mfdataset"
Describe alternatives you've considered
No response
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the open_dataset and open_mfdataset entry points using the reproducer in the issue. Check how a list of paths is handled and how the current backend error is raised. Done means a list passed to open_dataset produces a clear message directing the user to open_mfdataset, with tests covering the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100