Skip to content

[MRG] FIX: issue with py27 when lz4 is not installed#740

Merged
ogrisel merged 11 commits intojoblib:masterfrom
aabadie:py27_lz4
Aug 22, 2018
Merged

[MRG] FIX: issue with py27 when lz4 is not installed#740
ogrisel merged 11 commits intojoblib:masterfrom
aabadie:py27_lz4

Conversation

@aabadie
Copy link
Copy Markdown
Contributor

@aabadie aabadie commented Aug 8, 2018

When finished, this PR intends to fix #739.

For the moment, I'm trying to trigger the same issue in the CI.

The problem is that the lz4 package is always installed with python 2.7 in Travis. This hides the case raised in #739.
Note that lz4 is available in python2.7 but it doesn't work with file-like object the way they are used in joblib.

@codecov
Copy link
Copy Markdown

codecov bot commented Aug 9, 2018

Codecov Report

Merging #740 into master will increase coverage by 0.21%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #740      +/-   ##
==========================================
+ Coverage   95.23%   95.45%   +0.21%     
==========================================
  Files          42       42              
  Lines        6128     6138      +10     
==========================================
+ Hits         5836     5859      +23     
+ Misses        292      279      -13
Impacted Files Coverage Δ
joblib/test/test_numpy_pickle.py 98.35% <100%> (+0.52%) ⬆️
joblib/numpy_pickle.py 98.52% <100%> (ø) ⬆️
joblib/test/test_parallel.py 97.03% <0%> (+0.29%) ⬆️
joblib/compressor.py 93.52% <0%> (+0.32%) ⬆️
joblib/test/test_memory.py 97.84% <0%> (+0.35%) ⬆️
joblib/_parallel_backends.py 97.2% <0%> (+0.4%) ⬆️
joblib/_store_backends.py 91% <0%> (+0.52%) ⬆️
joblib/memory.py 95.95% <0%> (+0.57%) ⬆️
joblib/backports.py 95.83% <0%> (+2.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ec4f1ca...f4e788f. Read the comment docs.

elif cmethod == 'lz4' and with_lz4.args[0]:
# Skip the test if lz4 is not installed. We here use the with_lz4
# skipif fixture whose argument is True when lz4 is not installed
raise SkipTest("lz4 is not installed.")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this is right. With with_lz4, you will skip all compressors in _COMPRESSORS whereas we just want to skip cmethod=='lz4'.
Why do you need to change this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was testing different things. But you are right and I reverted this change.

@aabadie aabadie changed the title FIX: issue with py27 when lz4 is not installed (WIP) [MRG] FIX: issue with py27 when lz4 is not installed Aug 9, 2018
@aabadie
Copy link
Copy Markdown
Contributor Author

aabadie commented Aug 9, 2018

@tomMoral, I think this time the problem is correctly fixed. There was a problem in numpy_pickle.py. In the meantime, I added a test data compressed with lz4. This way the tests check that some data compressed with lz4 cannot be read if lz4 is not installed (and raise the right reason). Tell me if you think we should keep this and if you disagree, I can remove it.

@aabadie aabadie changed the title [MRG] FIX: issue with py27 when lz4 is not installed [MRG] FIX: issue with test with py27 when lz4 is not installed Aug 9, 2018
@aabadie aabadie changed the title [MRG] FIX: issue with test with py27 when lz4 is not installed [MRG] FIX: issue with py27 when lz4 is not installed Aug 9, 2018
Copy link
Copy Markdown
Contributor

@tomMoral tomMoral left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with some small questions.

# Run scikit-learn tests as integration / non-regression tests
- SKIP_TESTS="true" SKLEARN_TESTS="true" PYTHON_VERSION="3.6" NUMPY_VERSION="1.14"
- PYTHON_VERSION="2.7" NUMPY_VERSION="1.6"
- PYTHON_VERSION="2.7" NUMPY_VERSION="1.6" NO_LZ4="true" COVERAGE="true"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you add coverage?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To cover this line

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

# LZ4 compression is only supported and installation checked with
# python 3+.
if compress_method == 'lz4' and lz4 is None and PY3_OR_LATER:
raise ValueError(LZ4_NOT_INSTALLED_ERROR)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels weird to have different exception here. Can't we raise NotImplementedError?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NotImplementedError would work for lzma in python2 because it's not part of the standard lib in this version of python.
Here we consider the user wants to dump using lz4 compression, without the package installed, so it's a value error. Python2 is skipped because the "not supported error" will be raised by the compressor wrapper when trying to write/read the data (see here).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification.
All good to me then.

@aabadie
Copy link
Copy Markdown
Contributor Author

aabadie commented Aug 22, 2018

@lesteve, do you think we could merge this one ?

@ogrisel ogrisel merged commit 74c357a into joblib:master Aug 22, 2018
yarikoptic added a commit to yarikoptic/joblib that referenced this pull request Sep 4, 2018
* tag '0.12.3': (23 commits)
  Release 0.12.3
  Loky 2.2.1 (joblib#760)
  FIX: FileSystemStoreBackend string representation only returning location (path) (joblib#765)
  Add optional dependency on psutil
  MAINT remove brittle time based assertion in test (joblib#761)
  Fix a bug in nesting level computation with FallbackToBackend(SequentialBackend()) (joblib#759)
  Make docstring more consistent with project style
  Improved performance of call_and_shelve (joblib#757)
  Better test name
  Fix default context handling (joblib#754)
  cloudpickle 0.5.5 (joblib#756)
  Fixed error where filter args was consuming kwargs (joblib#750)
  FIX pickle roundtrip for Memory and related classes. (joblib#746)
  test that passes but timeout appveyor because of unclosed semaphore tracker (joblib#676)
  DOC: fine tune compressor example dataset size for ReadTheDocs (joblib#753)
  FIX: MemorizedResult not picklable (joblib#752)
  [MRG] Better message with py27 when lz4 is not installed (joblib#740)
  MNT remove mutable default value for backend_options parameter (joblib#748)
  MNT create test file for _store_backends module (joblib#749)
  DOC consistently use memory rather than mem in memory.rst (joblib#744)
  ...
yarikoptic added a commit to yarikoptic/joblib that referenced this pull request Sep 4, 2018
* releases: (23 commits)
  Release 0.12.3
  Loky 2.2.1 (joblib#760)
  FIX: FileSystemStoreBackend string representation only returning location (path) (joblib#765)
  Add optional dependency on psutil
  MAINT remove brittle time based assertion in test (joblib#761)
  Fix a bug in nesting level computation with FallbackToBackend(SequentialBackend()) (joblib#759)
  Make docstring more consistent with project style
  Improved performance of call_and_shelve (joblib#757)
  Better test name
  Fix default context handling (joblib#754)
  cloudpickle 0.5.5 (joblib#756)
  Fixed error where filter args was consuming kwargs (joblib#750)
  FIX pickle roundtrip for Memory and related classes. (joblib#746)
  test that passes but timeout appveyor because of unclosed semaphore tracker (joblib#676)
  DOC: fine tune compressor example dataset size for ReadTheDocs (joblib#753)
  FIX: MemorizedResult not picklable (joblib#752)
  [MRG] Better message with py27 when lz4 is not installed (joblib#740)
  MNT remove mutable default value for backend_options parameter (joblib#748)
  MNT create test file for _store_backends module (joblib#749)
  DOC consistently use memory rather than mem in memory.rst (joblib#744)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

python 2.7: test_lz4_compression_without_IO LZ4_NOT_INSTALLED_ERROR

3 participants