Skip to content

Commit a4f632f

Browse files
authored
[MRG] Update joblib to 0.10.2 (scikit-learn#7290)
* Update joblib to 0.10.2 * Exclude sklearn/externals from diff for flake8
2 parents f0862f7 + 03e3012 commit a4f632f

File tree

8 files changed

+35
-15
lines changed

8 files changed

+35
-15
lines changed

build_tools/travis/flake8_diff.sh

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# turn-around
1515

1616
set -e
17+
# pipefail is necessary to propagate exit codes
18+
set -o pipefail
1719

1820
PROJECT=scikit-learn/scikit-learn
1921
PROJECT_URL=https://github.com/$PROJECT.git
@@ -79,7 +81,20 @@ echo -e '\nRunning flake8 on the diff in the range'\
7981
"($(git rev-list $COMMIT.. | wc -l) commit(s)):"
8082
echo '--------------------------------------------------------------------------------'
8183

82-
# Conservative approach: diff without context so that code that was
83-
# not changed does not create failures
84-
git diff --unified=0 $COMMIT | flake8 --diff --show-source
84+
# We ignore files from sklearn/externals. Unfortunately there is no
85+
# way to do it with flake8 directly (the --exclude does not seem to
86+
# work with --diff). We could use the exclude magic in the git pathspec
87+
# ':!sklearn/externals' but it is only available on git 1.9 and Travis
88+
# uses git 1.8.
89+
# We need the following command to exit with 0 hence the echo in case
90+
# there is no match
91+
MODIFIED_FILES=$(git diff --name-only $COMMIT | grep -v 'sklearn/externals' || echo "no_match")
92+
93+
if [[ "$MODIFIED_FILES" == "no_match" ]]; then
94+
echo "No file outside sklearn/externals has been modified"
95+
else
96+
# Conservative approach: diff without context so that code that
97+
# was not changed does not create failures
98+
git diff --unified=0 $COMMIT -- $MODIFIED_FILES | flake8 --diff --show-source
99+
fi
85100
echo -e "No problem detected by flake8\n"

sklearn/externals/joblib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
# Dev branch marker is: 'X.Y.dev' or 'X.Y.devN' where N is an integer.
116116
# 'X.Y.dev0' is the canonical version of 'X.Y.dev'
117117
#
118-
__version__ = '0.10.0'
118+
__version__ = '0.10.2'
119119

120120

121121
from .memory import Memory, MemorizedResult

sklearn/externals/joblib/_memory_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,4 @@ def open_py_source(filename):
102102
buffer.seek(0)
103103
text = TextIOWrapper(buffer, encoding, line_buffering=True)
104104
text.mode = 'r'
105-
return text
105+
return text

sklearn/externals/joblib/_parallel_backends.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ class ParallelBackendBase(with_metaclass(ABCMeta)):
2525
def effective_n_jobs(self, n_jobs):
2626
"""Determine the number of jobs that can actually run in parallel
2727
28-
n_jobs is the is the number of workers requested by the callers.
29-
Passing n_jobs=-1 means requesting all available workers for instance
30-
matching the number of CPU cores on the worker host(s).
28+
n_jobs is the number of workers requested by the callers. Passing
29+
n_jobs=-1 means requesting all available workers for instance matching
30+
the number of CPU cores on the worker host(s).
3131
3232
This method should return a guesstimate of the number of workers that
3333
can actually perform work concurrently. The primary use case is to make

sklearn/externals/joblib/format_stack.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,10 @@ def linereader(file=file, lnum=[lnum], getline=linecache.getline):
273273
# enclosing scope.
274274
for token in generate_tokens(linereader):
275275
tokeneater(*token)
276-
except (IndexError, UnicodeDecodeError):
276+
except (IndexError, UnicodeDecodeError, SyntaxError):
277277
# signals exit of tokenizer
278+
# SyntaxError can happen when trying to tokenize
279+
# a compiled (e.g. .so or .pyd) extension
278280
pass
279281
except tokenize.TokenError as msg:
280282
_m = ("An unexpected error occurred while tokenizing input file %s\n"

sklearn/externals/joblib/func_inspect.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ def get_func_code(func):
5050
line_no = 1
5151
if source_file.startswith('<doctest '):
5252
source_file, line_no = re.match(
53-
'\<doctest (.*\.rst)\[(.*)\]\>',
54-
source_file).groups()
53+
'\<doctest (.*\.rst)\[(.*)\]\>', source_file).groups()
5554
line_no = int(line_no)
5655
source_file = '<doctest %s>' % source_file
5756
return source_code, source_file, line_no
@@ -312,7 +311,7 @@ def filter_args(func, ignore_lst, args=(), kwargs=dict()):
312311
"function %s"
313312
% (item,
314313
_signature_str(name, arg_spec))
315-
)
314+
)
316315
# XXX: Return a sorted list of pairs?
317316
return arg_dict
318317

@@ -352,4 +351,4 @@ def format_call(func, args, kwargs, object_name="Memory"):
352351
path, signature)
353352
return msg
354353
# XXX: Not using logging framework
355-
#self.debug(msg)
354+
# self.debug(msg)

sklearn/externals/joblib/numpy_pickle_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import contextlib
1515
from contextlib import closing
1616

17-
from ._compat import PY3_OR_LATER, PY26, PY27
17+
from ._compat import PY3_OR_LATER, PY26, PY27, _basestring
1818

1919
try:
2020
from threading import RLock
@@ -299,7 +299,7 @@ def __init__(self, filename, mode="rb", compresslevel=9):
299299
else:
300300
raise ValueError("Invalid mode: %r" % (mode,))
301301

302-
if isinstance(filename, (str, bytes)):
302+
if isinstance(filename, _basestring):
303303
self._fp = open(filename, mode)
304304
self._closefp = True
305305
self._mode = mode_code

sklearn/externals/joblib/parallel.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
from ._compat import _basestring
3333
from .func_inspect import getfullargspec
3434

35+
# Make sure that those two classes are part of the public joblib.parallel API
36+
# so that 3rd party backend implementers can import them from here.
37+
from ._parallel_backends import AutoBatchingMixin # noqa
38+
from ._parallel_backends import ParallelBackendBase # noqa
3539

3640
BACKENDS = {
3741
'multiprocessing': MultiprocessingBackend,

0 commit comments

Comments
 (0)