From bb449791b1cfd7bd60719b144e8dc3da89170785 Mon Sep 17 00:00:00 2001 From: Rhys Doyle <48983334+rdoyle45@users.noreply.github.com> Date: Thu, 17 Oct 2019 10:55:14 +0100 Subject: [PATCH 1/5] Revert #3358 --- xarray/backends/locks.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xarray/backends/locks.py b/xarray/backends/locks.py index d0bf790f074..551dffad38e 100644 --- a/xarray/backends/locks.py +++ b/xarray/backends/locks.py @@ -86,9 +86,10 @@ def _get_scheduler(get=None, collection=None): except (ImportError, AttributeError): pass - if actual_get is dask.multiprocessing.get: - return "multiprocessing" - else: + try: + if actual_get is dask.multiprocessing.get: + return "multiprocessing" + except (AttributeError): return "threaded" From 5bd1c573b04a92fbc334548a7229c687e5c79017 Mon Sep 17 00:00:00 2001 From: Rhys Doyle <48983334+rdoyle45@users.noreply.github.com> Date: Thu, 17 Oct 2019 11:16:24 +0100 Subject: [PATCH 2/5] Revision --- xarray/backends/locks.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xarray/backends/locks.py b/xarray/backends/locks.py index 551dffad38e..6722ced1353 100644 --- a/xarray/backends/locks.py +++ b/xarray/backends/locks.py @@ -89,6 +89,8 @@ def _get_scheduler(get=None, collection=None): try: if actual_get is dask.multiprocessing.get: return "multiprocessing" + else: + return "threaded" except (AttributeError): return "threaded" From 7b7230b434419c0f06af7fb22434e9428893d2ab Mon Sep 17 00:00:00 2001 From: Guido Imperiale Date: Sun, 20 Oct 2019 10:48:20 +0100 Subject: [PATCH 3/5] Code review --- doc/whats-new.rst | 6 ++++++ xarray/backends/locks.py | 13 +++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 2202c91408b..bf2959fba71 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -18,6 +18,11 @@ What's New v0.14.1 (unreleased) -------------------- +Bug fixes +~~~~~~~~~ +- Fix regression introduced in v0.14.0 that would cause a crash if dask is installed + but cloudpickle isn't (:issue:`3401`) by `Rhys Doyle `_ + Documentation ~~~~~~~~~~~~~ @@ -26,6 +31,7 @@ Documentation datetime-like dimension is required. (:pull:`3400`) By `Justus Magin `_. + .. _whats-new.0.14.0: v0.14.0 (14 Oct 2019) diff --git a/xarray/backends/locks.py b/xarray/backends/locks.py index 6722ced1353..4b4edebf28c 100644 --- a/xarray/backends/locks.py +++ b/xarray/backends/locks.py @@ -1,7 +1,7 @@ import multiprocessing import threading import weakref -from typing import Any, MutableMapping +from typing import Any, MutableMapping, Optional try: from dask.utils import SerializableLock @@ -62,7 +62,7 @@ def _get_lock_maker(scheduler=None): return _LOCK_MAKERS[scheduler] -def _get_scheduler(get=None, collection=None): +def _get_scheduler(get=None, collection=None) -> Optional[str]: """Determine the dask scheduler that is being used. None is returned if no dask scheduler is active. @@ -87,12 +87,13 @@ def _get_scheduler(get=None, collection=None): pass try: + # dask.multiprocessing requires cloudpickle to be installed if actual_get is dask.multiprocessing.get: return "multiprocessing" - else: - return "threaded" - except (AttributeError): - return "threaded" + except AttributeError: + pass + + return "threaded" def get_write_lock(key): From f9616858f7b39ac63951e9d230583ec659df1d52 Mon Sep 17 00:00:00 2001 From: Guido Imperiale Date: Sun, 20 Oct 2019 10:49:14 +0100 Subject: [PATCH 4/5] Merge from master --- doc/whats-new.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index f64102c94d0..ab9a0adc101 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -18,10 +18,6 @@ What's New v0.14.1 (unreleased) -------------------- -Bug fixes -~~~~~~~~~ -- Fix regression introduced in v0.14.0 that would cause a crash if dask is installed - but cloudpickle isn't (:issue:`3401`) by `Rhys Doyle `_ New Features ~~~~~~~~~~~~ - Added integration tests against `pint `_. @@ -35,6 +31,11 @@ New Features ``pip install git+https://github.com/andrewgsavage/pint.git@refs/pull/6/head)``. Even with it, interaction with non-numpy array libraries, e.g. dask or sparse, is broken. +Bug fixes +~~~~~~~~~ +- Fix regression introduced in v0.14.0 that would cause a crash if dask is installed + but cloudpickle isn't (:issue:`3401`) by `Rhys Doyle `_ + Documentation ~~~~~~~~~~~~~ From df7bd893963d546ed7349b3a7409065b99c1adb9 Mon Sep 17 00:00:00 2001 From: Guido Imperiale Date: Sun, 20 Oct 2019 23:47:27 +0100 Subject: [PATCH 5/5] Obsolescence note --- xarray/backends/locks.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xarray/backends/locks.py b/xarray/backends/locks.py index 4b4edebf28c..435690f2079 100644 --- a/xarray/backends/locks.py +++ b/xarray/backends/locks.py @@ -87,7 +87,8 @@ def _get_scheduler(get=None, collection=None) -> Optional[str]: pass try: - # dask.multiprocessing requires cloudpickle to be installed + # As of dask=2.6, dask.multiprocessing requires cloudpickle to be installed + # Dependency removed in https://github.com/dask/dask/pull/5511 if actual_get is dask.multiprocessing.get: return "multiprocessing" except AttributeError: