10000 Bugfix release of joblib that also restores PyPy support · scikit-learn/scikit-learn@71de5c9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 71de5c9

Browse files
committed
Bugfix release of joblib that also restores PyPy support
1 parent c40726e commit 71de5c9

23 files changed

+1004
-760
lines changed

sklearn/externals/copy_joblib.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ else
1111
JOBLIB=$1
1212
fi
1313

14-
pip install $JOBLIB --target $INSTALL_FOLDER
14+
pip install --no-cache $JOBLIB --target $INSTALL_FOLDER
1515
cp -r $INSTALL_FOLDER/joblib joblib
1616
rm -rf $INSTALL_FOLDER
1717

sklearn/externals/joblib/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
1414
==================== ===============================================
15-
**Documentation:** http://pythonhosted.org/joblib
15+
**Documentation:** https://joblib.readthedocs.io
1616
1717
**Download:** http://pypi.python.org/pypi/joblib#downloads
1818
@@ -106,7 +106,7 @@
106106
# Dev branch marker is: 'X.Y.dev' or 'X.Y.devN' where N is an integer.
107107
# 'X.Y.dev0' is the canonical version of 'X.Y.dev'
108108
#
109-
__version__ = '0.12.2'
109+
__version__ = '0.12.4'
110110

111111

112112
from .memory import Memory, MemorizedResult, register_store_backend

sklearn/externals/joblib/_multiprocessing_helpers.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
circular dependencies (for instance for the assert_spawning name).
55
"""
66
import os
7+
import sys
78
import warnings
89

910

@@ -21,7 +22,16 @@
2122
# issue a warning if not
2223
if mp is not None:
2324
try:
24-
_sem = mp.Semaphore()
25+
# Use the spawn context
26+
if sys.version_info < (3, 3):
27+
Semaphore = mp.Semaphore
28+
else:
29+
# Using mp.Semaphore has a border effect and set the default
30+
# backend for multiprocessing. To avoid that, we use the 'spawn'
31+
# context which is available on all supported platforms.
32+
ctx = mp.get_context('spawn')
33+
Semaphore = ctx.Semaphore
34+
_sem = Semaphore()
2535
del _sem # cleanup
2636
except (ImportError, OSError) as e:
2737
mp = None

sklearn/externals/joblib/_parallel_backends.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ def get_nested_backend(self):
130130
else:
131131
return ThreadingBackend(nesting_level=nesting_level)
132132

133-
134133
@contextlib.contextmanager
135134
def retrieval_context(self):
136135
"""Context manager to manage an execution context.
@@ -348,7 +347,8 @@ def configure(self, n_jobs=1, parallel=None, **backend_args):
348347
n_jobs = self.effective_n_jobs(n_jobs)
349348
if n_jobs == 1:
350349
# Avoid unnecessary overhead and use sequential backend instead.
351-
raise FallbackToBackend(SequentialBackend())
350+
raise FallbackToBackend(
351+
SequentialBackend(nesting_level=self.nesting_level))
352352
self.parallel = parallel
353353
self._n_jobs = n_jobs
354354
return n_jobs
@@ -421,7 +421,8 @@ def configure(self, n_jobs=1, parallel=None, prefer=None, require=None,
421421
"""Build a process or thread pool and return the number of workers"""
422422
n_jobs = self.effective_n_jobs(n_jobs)
423423
if n_jobs == 1:
424-
raise FallbackToBackend(SequentialBackend())
424+
raise FallbackToBackend(
425+
SequentialBackend(nesting_level=self.nesting_level))
425426

426427
already_forked = int(os.environ.get(self.JOBLIB_SPAWNED_PROCESS, 0))
427428
if already_forked:
@@ -462,7 +463,8 @@ def configure(self, n_jobs=1, parallel=None, prefer=None, require=None,
462463
"""Build a process executor and return the number of workers"""
463464
n_jobs = self.effective_n_jobs(n_jobs)
464465
if n_jobs == 1:
465-
raise FallbackToBackend(SequentialBackend())
466+
raise FallbackToBackend(
467+
SequentialBackend(nesting_level=self.nesting_level))
466468

467469
self._workers = get_memmapping_executor(
468470
n_jobs, timeout=idle_worker_timeout,

sklearn/externals/joblib/_store_backends.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class StoreBackendBase(with_metaclass(ABCMeta)):
3535
"""Helper Abstract Base Class which defines all methods that
3636
a StorageBackend must implement."""
3737

38+
location = None
39+
3840
@abstractmethod
3941
def _open_item(self, f, mode):
4042
"""Opens an item on the store and return a file-like object.
@@ -327,7 +329,8 @@ def _concurrency_safe_write(self, to_write, filename, write_func):
327329

328330
def __repr__(self):
329331
"""Printable representation of the store location."""
330-
return self.location
33 10000 2+
return '{class_name}(location="{location}")'.format(
333+
class_name=self.__class__.__name__, location=self.location)
331334

332335

333336
class FileSystemStoreBackend(StoreBackendBase, StoreBackendMixin):
@@ -384,29 +387,29 @@ def get_items(self):
384387

385388
return items
386389

387-
def configure(self, location, verbose=1, backend_options={}):
390+
def configure(self, location, verbose=1, backend_options=None):
388391
"""Configure the store backend.
389392
390393
For this backend, valid store options are 'compress' and 'mmap_mode'
391394
"""
395+
if backend_options is None:
396+
backend_options = {}
392397

393398
# setup location directory
394399
self.location = location
395400
if not os.path.exists(self.location):
396401
mkdirp(self.location)
397402

398403
# item can be stored compressed for faster I/O
399-
self.compress = backend_options['compress']
404+
self.compress = backend_options.get('compress', False)
400405

401406
# FileSystemStoreBackend can be used with mmap_mode options under
402407
# certain conditions.
403-
mmap_mode = None
404-
if 'mmap_mode' in backend_options:
405-
mmap_mode = backend_options['mmap_mode']
406-
if self.compress and mmap_mode is not None:
407-
warnings.warn('Compressed items cannot be memmapped in a '
408-
'filesystem store. Option will be ignored.',
409-
stacklevel=2)
408+
mmap_mode = backend_options.get('mmap_mode')
409+
if self.compress and mmap_mode is not None:
410+
warnings.warn('Compressed items cannot be memmapped in a '
411+
'filesystem store. Option will be ignored.',
412+
stacklevel=2)
410413

411414
self.mmap_mode = mmap_mode
412415
self.verbose = verbose

sklearn/externals/joblib/externals/cloudpickle/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
from .cloudpickle import *
44

5-
__version__ = '0.5.2'
5+
__version__ = '0.5.5'

0 commit comments

Comments
 (0)
0