Can't call open_mfdataset without creating chunked dask arrays
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
What happened?
Passing chunks=None to xr.open_dataset/open_mfdataset is supposed to avoid using dask at all, returning lazily-indexed numpy arrays even if dask is installed. However chunks=None doesn't currently work for xr.open_mfdataset as it gets silently coerced internally to chunks={}, which creates dask chunks aligned with the on-disk files.
Offending line of code:
https://github.com/pydata/xarray/blob/12123be8608f3a90c6a6d8a1cdc4845126492364/xarray/backends/api.py#L1040
What did you expect to happen?
Passing chunks=None to open_mfdataset should return lazily-indexed numpy arrays, like open_dataset does.
Minimal Complete Verifiable Example
ds = xr.tutorial.open_dataset("air_temperature")
ds1 = ds.isel(time=slice(None, 1000))
ds2 = ds.isel(time=slice(1000, None))
ds1.to_netcdf('air1.nc')
ds2.to_netcdf('air2.nc')
combined = xr.open_mfdataset(['air1.nc', 'air2.nc'], chunks=None)
print(type(combined['air'].data))
MVCE confirmation
- Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
- Complete example — the example is self-contained, including all data and the text of any traceback.
- Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
- New issue — a search of GitHub Issues suggests this is not a duplicate.
- Recent environment — the issue occurs with the latest version of xarray and its dependencies.
Relevant log output
dask.array.core.Array
Anything else we need to know?
As the default is None, changing this without changing the default would be a breaking change. But the current behaviour is also not intended.
Environment
main
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 at xarray/backends/api.py line 1040 and compare open_mfdataset's chunks handling with open_dataset; reproduce the provided MVCE and inspect the resulting data type. Done when chunks=None yields lazily-indexed numpy arrays without dask-backed chunks, while preserving the existing default behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100