Skip to content

Commit bc92331

Browse files
authored
Fix gen_cluster failures; dask_version tweaks (#5610)
* gen_cluster no longer accepts timeout=None * dask_version tweaks * pep8 * [test-upstream]
1 parent 8539b29 commit bc92331

File tree

6 files changed

+12
-61
lines changed

6 files changed

+12
-61
lines changed

doc/getting-started-guide/installing.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ dependencies:
9696
- **setuptools:** 42 months (but no older than 40.4)
9797
- **numpy:** 18 months
9898
(`NEP-29 <https://numpy.org/neps/nep-0029-deprecation_policy.html>`_)
99-
- **dask and dask.distributed:** 12 months (but no older than 2.9)
99+
- **dask and dask.distributed:** 12 months
100100
- **sparse, pint** and other libraries that rely on
101101
`NEP-18 <https://numpy.org/neps/nep-0018-array-function-protocol.html>`_
102102
for integration: very latest available versions only, until the technology will have

xarray/tests/test_backends.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,8 @@
8787
try:
8888
import dask
8989
import dask.array as da
90-
91-
dask_version = dask.__version__
9290
except ImportError:
93-
# needed for xfailed tests when dask < 2.4.0
94-
# remove when min dask > 2.4.0
95-
dask_version = "10.0"
91+
pass
9692

9793
ON_WINDOWS = sys.platform == "win32"
9894
default_value = object()
@@ -1961,7 +1957,6 @@ def test_hidden_zarr_keys(self):
19611957
with xr.decode_cf(store):
19621958
pass
19631959

1964-
@pytest.mark.skipif(LooseVersion(dask_version) < "2.4", reason="dask GH5334")
19651960
@pytest.mark.parametrize("group", [None, "group1"])
19661961
def test_write_persistence_modes(self, group):
19671962
original = create_test_data()
@@ -2039,7 +2034,6 @@ def test_encoding_kwarg_fixed_width_string(self):
20392034
def test_dataset_caching(self):
20402035
super().test_dataset_caching()
20412036

2042-
@pytest.mark.skipif(LooseVersion(dask_version) < "2.4", reason="dask GH5334")
20432037
def test_append_write(self):
20442038
super().test_append_write()
20452039

@@ -2122,7 +2116,6 @@ def test_check_encoding_is_consistent_after_append(self):
21222116
xr.concat([ds, ds_to_append], dim="time"),
21232117
)
21242118

2125-
@pytest.mark.skipif(LooseVersion(dask_version) < "2.4", reason="dask GH5334")
21262119
def test_append_with_new_variable(self):
21272120

21282121
ds, ds_to_append, ds_with_new_var = create_append_test_data()

xarray/tests/test_computation.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import functools
22
import operator
33
import pickle
4-
from distutils.version import LooseVersion
54

65
import numpy as np
76
import pandas as pd
@@ -21,6 +20,7 @@
2120
result_name,
2221
unified_dim_sizes,
2322
)
23+
from xarray.core.pycompat import dask_version
2424

2525
from . import has_dask, raise_if_dask_computes, requires_dask
2626

@@ -1307,7 +1307,7 @@ def test_vectorize_dask_dtype_without_output_dtypes(data_array):
13071307

13081308

13091309
@pytest.mark.skipif(
1310-
LooseVersion(dask.__version__) > "2021.06",
1310+
dask_version > "2021.06",
13111311
reason="dask/dask#7669: can no longer pass output_dtypes and meta",
13121312
)
13131313
@requires_dask

xarray/tests/test_dask.py

+4-30
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import pickle
33
import sys
44
from contextlib import suppress
5-
from distutils.version import LooseVersion
65
from textwrap import dedent
76

87
import numpy as np
@@ -13,6 +12,7 @@
1312
import xarray.ufuncs as xu
1413
from xarray import DataArray, Dataset, Variable
1514
from xarray.core import duck_array_ops
15+
from xarray.core.pycompat import dask_version
1616
from xarray.testing import assert_chunks_equal
1717
from xarray.tests import mock
1818

@@ -111,10 +111,7 @@ def test_indexing(self):
111111
self.assertLazyAndIdentical(u[:1], v[:1])
112112
self.assertLazyAndIdentical(u[[0, 1], [0, 1, 2]], v[[0, 1], [0, 1, 2]])
113113

114-
@pytest.mark.skipif(
115-
LooseVersion(dask.__version__) < LooseVersion("2021.04.1"),
116-
reason="Requires dask v2021.04.1 or later",
117-
)
114+
@pytest.mark.skipif(dask_version < "2021.04.1", reason="Requires dask >= 2021.04.1")
118115
@pytest.mark.parametrize(
119116
"expected_data, index",
120117
[
@@ -133,10 +130,7 @@ def test_setitem_dask_array(self, expected_data, index):
133130
arr[index] = 99
134131
assert_identical(arr, expected)
135132

136-
@pytest.mark.skipif(
137-
LooseVersion(dask.__version__) >= LooseVersion("2021.04.1"),
138-
reason="Requires dask v2021.04.0 or earlier",
139-
)
133+
@pytest.mark.skipif(dask_version >= "2021.04.1", reason="Requires dask < 2021.04.1")
140134
def test_setitem_dask_array_error(self):
141135
with pytest.raises(TypeError, match=r"stored in a dask array"):
142136
v = self.lazy_var
@@ -612,25 +606,6 @@ def test_dot(self):
612606
lazy = self.lazy_array.dot(self.lazy_array[0])
613607
self.assertLazyAndAllClose(eager, lazy)
614608

615-
@pytest.mark.skipif(LooseVersion(dask.__version__) >= "2.0", reason="no meta")
616-
def test_dataarray_repr_legacy(self):
617-
data = build_dask_array("data")
618-
nonindex_coord = build_dask_array("coord")
619-
a = DataArray(data, dims=["x"], coords={"y": ("x", nonindex_coord)})
620-
expected = dedent(
621-
"""\
622-
<xarray.DataArray 'data' (x: 1)>
623-
{!r}
624-
Coordinates:
625-
y (x) int64 dask.array<chunksize=(1,), meta=np.ndarray>
626-
Dimensions without coordinates: x""".format(
627-
data
628-
)
629-
)
630-
assert expected == repr(a)
631-
assert kernel_call_count == 0 # should not evaluate dask array
632-
633-
@pytest.mark.skipif(LooseVersion(dask.__version__) < "2.0", reason="needs meta")
634609
def test_dataarray_repr(self):
635610
data = build_dask_array("data")
636611
nonindex_coord = build_dask_array("coord")
@@ -648,7 +623,6 @@ def test_dataarray_repr(self):
648623
assert expected == repr(a)
649624
assert kernel_call_count == 0 # should not evaluate dask array
650625

651-
@pytest.mark.skipif(LooseVersion(dask.__version__) < "2.0", reason="needs meta")
652626
def test_dataset_repr(self):
653627
data = build_dask_array("data")
654628
nonindex_coord = build_dask_array("coord")
@@ -1645,7 +1619,7 @@ def test_optimize():
16451619

16461620
# The graph_manipulation module is in dask since 2021.2 but it became usable with
16471621
# xarray only since 2021.3
1648-
@pytest.mark.skipif(LooseVersion(dask.__version__) <= "2021.02.0", reason="new module")
1622+
@pytest.mark.skipif(dask_version <= "2021.02.0", reason="new module")
16491623
def test_graph_manipulation():
16501624
"""dask.graph_manipulation passes an optional parameter, "rename", to the rebuilder
16511625
function returned by __dask_postperist__; also, the dsk passed to the rebuilder is

xarray/tests/test_distributed.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,7 @@ def test_dask_distributed_cfgrib_integration_test(loop):
184184
assert_allclose(actual, expected)
185185

186186

187-
@pytest.mark.skipif(
188-
distributed.__version__ <= "1.19.3",
189-
reason="Need recent distributed version to clean up get",
190-
)
191-
@gen_cluster(client=True, timeout=None)
187+
@gen_cluster(client=True)
192188
async def test_async(c, s, a, b):
193189
x = create_test_data()
194190
assert not dask.is_dask_collection(x)

xarray/tests/test_formatting_html.py

+3-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from distutils.version import LooseVersion
2-
31
import numpy as np
42
import pandas as pd
53
import pytest
@@ -57,19 +55,9 @@ def test_short_data_repr_html_non_str_keys(dataset):
5755

5856

5957
def test_short_data_repr_html_dask(dask_dataarray):
60-
import dask
61-
62-
if LooseVersion(dask.__version__) < "2.0.0":
63-
assert not hasattr(dask_dataarray.data, "_repr_html_")
64-
data_repr = fh.short_data_repr_html(dask_dataarray)
65-
assert (
66-
data_repr
67-
== "dask.array&lt;xarray-&lt;this-array&gt;, shape=(4, 6), dtype=float64, chunksize=(4, 6)&gt;"
68-
)
69-
else:
70-
assert hasattr(dask_dataarray.data, "_repr_html_")
71-
data_repr = fh.short_data_repr_html(dask_dataarray)
72-
assert data_repr == dask_dataarray.data._repr_html_()
58+
assert hasattr(dask_dataarray.data, "_repr_html_")
59+
data_repr = fh.short_data_repr_html(dask_dataarray)
60+
assert data_repr == dask_dataarray.data._repr_html_()
7361

7462

7563
def test_format_dims_no_dims():

0 commit comments

Comments
 (0)