Skip to content

Commit 8a1c933

Browse files
authored
add a CI that tests xarray with all optional dependencies but dask (#3919)
* add a new ci that does not install dask * remove iris since it depends on dask * rename the new CI to py38-all-but-dask * decorate the some of the failing tests with requires_dask * decorate the zarr tests using dask or obj.chunk with requires_dask * don't chunk if dask is not available * pass an indexer instead of a tuple to _arrayize_vectorized_indexer * xfail the remaining tests if dask is not available * update whats-new.rst
1 parent 9b5140e commit 8a1c933

File tree

6 files changed

+75
-1
lines changed

6 files changed

+75
-1
lines changed

azure-pipelines.yml

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020
conda_env: py37
2121
py38:
2222
conda_env: py38
23+
py38-all-but-dask:
24+
conda_env: py38-all-but-dask
2325
py38-upstream-dev:
2426
conda_env: py38
2527
upstream_dev: true

ci/requirements/py38-all-but-dask.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: xarray-tests
2+
channels:
3+
- conda-forge
4+
dependencies:
5+
- python=3.8
6+
- black
7+
- boto3
8+
- bottleneck
9+
- cartopy
10+
- cdms2
11+
- cfgrib
12+
- cftime
13+
- coveralls
14+
- flake8
15+
- h5netcdf
16+
- h5py
17+
- hdf5
18+
- hypothesis
19+
- isort
20+
- lxml # Optional dep of pydap
21+
- matplotlib
22+
- mypy=0.761 # Must match .pre-commit-config.yaml
23+
- nc-time-axis
24+
- netcdf4
25+
- numba
26+
- numpy
27+
- pandas
28+
- pint
29+
- pip
30+
- pseudonetcdf
31+
- pydap
32+
- pynio
33+
- pytest
34+
- pytest-cov
35+
- pytest-env
36+
- rasterio
37+
- scipy
38+
- seaborn
39+
- setuptools
40+
- sparse
41+
- toolz
42+
- zarr
43+
- pip:
44+
- numbagg

doc/whats-new.rst

+3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ Internal Changes
7171
- Run the ``isort`` pre-commit hook only on python source files
7272
and update the ``flake8`` version. (:issue:`3750`, :pull:`3711`)
7373
By `Justus Magin <https://github.com/keewis>`_.
74+
- Add a CI job that runs the tests with every optional dependency
75+
except ``dask``. (:issue:`3794`, :pull:`3919`)
76+
By `Justus Magin <https://github.com/keewis>`_.
7477

7578

7679
.. _whats-new.0.15.1:

xarray/backends/zarr.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def __getitem__(self, key):
5656
return array[key.tuple]
5757
elif isinstance(key, indexing.VectorizedIndexer):
5858
return array.vindex[
59-
indexing._arrayize_vectorized_indexer(key.tuple, self.shape).tuple
59+
indexing._arrayize_vectorized_indexer(key, self.shape).tuple
6060
]
6161
else:
6262
assert isinstance(key, indexing.OuterIndexer)
@@ -586,6 +586,12 @@ def open_zarr(
586586
"Instead found %s. " % chunks
587587
)
588588

589+
if chunks == "auto":
590+
try:
591+
import dask.array # noqa
592+
except ImportError:
593+
chunks = None
594+
589595
if not decode_cf:
590596
mask_and_scale = False
591597
decode_times = False

xarray/tests/test_backends.py

+18
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,10 @@ def test_orthogonal_indexing(self):
581581
actual = on_disk.isel(**indexers)
582582
assert_identical(expected, actual)
583583

584+
@pytest.mark.xfail(
585+
not has_dask,
586+
reason="the code for indexing without dask handles negative steps in slices incorrectly",
587+
)
584588
def test_vectorized_indexing(self):
585589
in_memory = create_test_data()
586590
with self.roundtrip(in_memory) as on_disk:
@@ -1539,6 +1543,7 @@ def test_roundtrip_consolidated(self):
15391543
self.check_dtypes_roundtripped(expected, actual)
15401544
assert_identical(expected, actual)
15411545

1546+
@requires_dask
15421547
def test_auto_chunk(self):
15431548
original = create_test_data().chunk()
15441549

@@ -1556,6 +1561,7 @@ def test_auto_chunk(self):
15561561
# chunk size should be the same as original
15571562
assert v.chunks == original[k].chunks
15581563

1564+
@requires_dask
15591565
@pytest.mark.filterwarnings("ignore:Specified Dask chunks")
15601566
def test_manual_chunk(self):
15611567
original = create_test_data().chunk({"dim1": 3, "dim2": 4, "dim3": 3})
@@ -1598,6 +1604,7 @@ def test_manual_chunk(self):
15981604
assert_identical(actual, auto)
15991605
assert_identical(actual.load(), auto.load())
16001606

1607+
@requires_dask
16011608
def test_warning_on_bad_chunks(self):
16021609
original = create_test_data().chunk({"dim1": 4, "dim2": 3, "dim3": 5})
16031610

@@ -1620,6 +1627,7 @@ def test_warning_on_bad_chunks(self):
16201627
assert v._in_memory == (k in actual.dims)
16211628
assert len(record) == 0
16221629

1630+
@requires_dask
16231631
def test_deprecate_auto_chunk(self):
16241632
original = create_test_data().chunk()
16251633
with pytest.warns(FutureWarning):
@@ -1638,6 +1646,7 @@ def test_deprecate_auto_chunk(self):
16381646
# there should be no chunks
16391647
assert v.chunks is None
16401648

1649+
@requires_dask
16411650
def test_write_uneven_dask_chunks(self):
16421651
# regression for GH#2225
16431652
original = create_test_data().chunk({"dim1": 3, "dim2": 4, "dim3": 3})
@@ -1662,6 +1671,7 @@ def test_chunk_encoding(self):
16621671
with self.roundtrip(data) as actual:
16631672
pass
16641673

1674+
@requires_dask
16651675
def test_chunk_encoding_with_dask(self):
16661676
# These datasets DO have dask chunks. Need to check for various
16671677
# interactions between dask and zarr chunks
@@ -1896,6 +1906,7 @@ def test_append_with_new_variable(self):
18961906
combined["new_var"] = ds_with_new_var["new_var"]
18971907
assert_identical(combined, xr.open_zarr(store_target))
18981908

1909+
@requires_dask
18991910
def test_to_zarr_compute_false_roundtrip(self):
19001911
from dask.delayed import Delayed
19011912

@@ -1915,6 +1926,7 @@ def test_to_zarr_compute_false_roundtrip(self):
19151926
with self.open(store) as actual:
19161927
assert_identical(original, actual)
19171928

1929+
@requires_dask
19181930
def test_to_zarr_append_compute_false_roundtrip(self):
19191931
from dask.delayed import Delayed
19201932

@@ -1951,6 +1963,7 @@ def test_to_zarr_append_compute_false_roundtrip(self):
19511963
with self.open(store) as actual:
19521964
assert_identical(xr.concat([ds, ds_to_append], dim="time"), actual)
19531965

1966+
@requires_dask
19541967
def test_encoding_chunksizes(self):
19551968
# regression test for GH2278
19561969
# see also test_encoding_chunksizes_unlimited
@@ -3513,6 +3526,7 @@ def test_uamiv_format_read(self):
35133526
assert_allclose(expected, actual)
35143527
camxfile.close()
35153528

3529+
@requires_dask
35163530
def test_uamiv_format_mfread(self):
35173531
"""
35183532
Open a CAMx file and test data variables
@@ -3939,6 +3953,9 @@ def test_chunks(self):
39393953
ex = expected.sel(band=1).mean(dim="x")
39403954
assert_allclose(ac, ex)
39413955

3956+
@pytest.mark.xfail(
3957+
not has_dask, reason="without dask, a non-serializable lock is used"
3958+
)
39423959
def test_pickle_rasterio(self):
39433960
# regression test for https://github.com/pydata/xarray/issues/2121
39443961
with create_tmp_geotiff() as (tmp_file, expected):
@@ -4012,6 +4029,7 @@ def test_geotiff_tags(self):
40124029
with xr.open_rasterio(tmp_file) as rioda:
40134030
assert isinstance(rioda.attrs["AREA_OR_POINT"], str)
40144031

4032+
@requires_dask
40154033
def test_no_mftime(self):
40164034
# rasterio can accept "filename" urguments that are actually urls,
40174035
# including paths to remote files.

xarray/tests/test_sparse.py

+1
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,7 @@ def test_sparse_coords(self):
837837
)
838838

839839

840+
@requires_dask
840841
def test_chunk():
841842
s = sparse.COO.from_numpy(np.array([0, 0, 1, 2]))
842843
a = DataArray(s)

0 commit comments

Comments
 (0)