Skip to content

Avoid use of deprecated get= parameter in tests #2500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions asv_bench/benchmarks/dataset_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def time_load_dataset_netcdf4_with_block_chunks_vindexing(self):
ds = ds.isel(**self.vinds).load()

def time_load_dataset_netcdf4_with_block_chunks_multiprocessing(self):
with dask.set_options(get=dask.multiprocessing.get):
with dask.config.set(scheduler="multiprocessing"):
xr.open_dataset(self.filepath, engine='netcdf4',
chunks=self.block_chunks).load()

Expand All @@ -177,7 +177,7 @@ def time_load_dataset_netcdf4_with_time_chunks(self):
chunks=self.time_chunks).load()

def time_load_dataset_netcdf4_with_time_chunks_multiprocessing(self):
with dask.set_options(get=dask.multiprocessing.get):
with dask.config.set(scheduler="multiprocessing"):
xr.open_dataset(self.filepath, engine='netcdf4',
chunks=self.time_chunks).load()

Expand All @@ -194,7 +194,7 @@ def setup(self):
self.ds.to_netcdf(self.filepath, format=self.format)

def time_load_dataset_scipy_with_block_chunks(self):
with dask.set_options(get=dask.multiprocessing.get):
with dask.config.set(scheduler="multiprocessing"):
xr.open_dataset(self.filepath, engine='scipy',
chunks=self.block_chunks).load()

Expand All @@ -209,7 +209,7 @@ def time_load_dataset_scipy_with_block_chunks_vindexing(self):
ds = ds.isel(**self.vinds).load()

def time_load_dataset_scipy_with_time_chunks(self):
with dask.set_options(get=dask.multiprocessing.get):
with dask.config.set(scheduler="multiprocessing"):
xr.open_dataset(self.filepath, engine='scipy',
chunks=self.time_chunks).load()

Expand Down Expand Up @@ -349,7 +349,7 @@ def time_load_dataset_netcdf4_with_block_chunks(self):
chunks=self.block_chunks).load()

def time_load_dataset_netcdf4_with_block_chunks_multiprocessing(self):
with dask.set_options(get=dask.multiprocessing.get):
with dask.config.set(scheduler="multiprocessing"):
xr.open_mfdataset(self.filenames_list, engine='netcdf4',
chunks=self.block_chunks).load()

Expand All @@ -358,7 +358,7 @@ def time_load_dataset_netcdf4_with_time_chunks(self):
chunks=self.time_chunks).load()

def time_load_dataset_netcdf4_with_time_chunks_multiprocessing(self):
with dask.set_options(get=dask.multiprocessing.get):
with dask.config.set(scheduler="multiprocessing"):
xr.open_mfdataset(self.filenames_list, engine='netcdf4',
chunks=self.time_chunks).load()

Expand All @@ -367,7 +367,7 @@ def time_open_dataset_netcdf4_with_block_chunks(self):
chunks=self.block_chunks)

def time_open_dataset_netcdf4_with_block_chunks_multiprocessing(self):
with dask.set_options(get=dask.multiprocessing.get):
with dask.config.set(scheduler="multiprocessing"):
xr.open_mfdataset(self.filenames_list, engine='netcdf4',
chunks=self.block_chunks)

Expand All @@ -376,7 +376,7 @@ def time_open_dataset_netcdf4_with_time_chunks(self):
chunks=self.time_chunks)

def time_open_dataset_netcdf4_with_time_chunks_multiprocessing(self):
with dask.set_options(get=dask.multiprocessing.get):
with dask.config.set(scheduler="multiprocessing"):
xr.open_mfdataset(self.filenames_list, engine='netcdf4',
chunks=self.time_chunks)

Expand All @@ -392,22 +392,22 @@ def setup(self):
format=self.format)

def time_load_dataset_scipy_with_block_chunks(self):
with dask.set_options(get=dask.multiprocessing.get):
with dask.config.set(scheduler="multiprocessing"):
xr.open_mfdataset(self.filenames_list, engine='scipy',
chunks=self.block_chunks).load()

def time_load_dataset_scipy_with_time_chunks(self):
with dask.set_options(get=dask.multiprocessing.get):
with dask.config.set(scheduler="multiprocessing"):
xr.open_mfdataset(self.filenames_list, engine='scipy',
chunks=self.time_chunks).load()

def time_open_dataset_scipy_with_block_chunks(self):
with dask.set_options(get=dask.multiprocessing.get):
with dask.config.set(scheduler="multiprocessing"):
xr.open_mfdataset(self.filenames_list, engine='scipy',
chunks=self.block_chunks)

def time_open_dataset_scipy_with_time_chunks(self):
with dask.set_options(get=dask.multiprocessing.get):
with dask.config.set(scheduler="multiprocessing"):
xr.open_mfdataset(self.filenames_list, engine='scipy',
chunks=self.time_chunks)

Expand Down
4 changes: 3 additions & 1 deletion doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ Bug fixes
(:issue:`2484`). By `Spencer Clark <https://github.com/spencerkclark>`_.
- Adding a TimedeltaIndex to, or subtracting a TimedeltaIndex from a
CFTimeIndex is now allowed (:issue:`2484`).
By `Spencer Clark <https://github.com/spencerkclark>`_.
By `Spencer Clark <https://github.com/spencerkclark>`_.
- Avoid use of Dask's deprecated ``get=`` parameter in tests
by `Matthew Rocklin <https://github.com/mrocklin/>`_.

.. _whats-new.0.10.9:

Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def LooseVersion(vstring):
if LooseVersion(dask.__version__) < '0.18':
dask.set_options(get=dask.get)
else:
dask.config.set(scheduler='sync')
dask.config.set(scheduler='single-threaded')
try:
import_seaborn()
has_seaborn = True
Expand Down
12 changes: 9 additions & 3 deletions xarray/tests/test_dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
class DaskTestCase(object):
def assertLazyAnd(self, expected, actual, test):

with (dask.config.set(get=dask.get)
with (dask.config.set(scheduler='single-threaded')
if LooseVersion(dask.__version__) >= LooseVersion('0.18.0')
else dask.set_options(get=dask.get)):
test(actual, expected)
Expand Down Expand Up @@ -456,7 +456,11 @@ def counting_get(*args, **kwargs):
count[0] += 1
return dask.get(*args, **kwargs)

ds.load(get=counting_get)
if dask.__version__ < '0.19.4':
ds.load(get=counting_get)
else:
ds.load(scheduler=counting_get)

assert count[0] == 1

def test_stack(self):
Expand Down Expand Up @@ -831,7 +835,9 @@ def test_basic_compute():
dask.multiprocessing.get,
dask.local.get_sync,
None]:
with (dask.config.set(get=get)
with (dask.config.set(scheduler=get)
if LooseVersion(dask.__version__) >= LooseVersion('0.19.4')
else dask.config.set(scheduler=get)
if LooseVersion(dask.__version__) >= LooseVersion('0.18.0')
else dask.set_options(get=get)):
ds.compute()
Expand Down