Skip to content
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

Use pickle protocol format version 2. #633

Conversation

nuclearsandwich
Copy link
Contributor

@nuclearsandwich nuclearsandwich commented Sep 30, 2018

Proposed as a fix for #379.

So far this only #worksonmymachine. Following the queues from @NikolausDemmel in this comment I read through the docs and tried to use the cache created in python3 from python2 without the fix_imports flag and was successful so I did not apply it.

I have not added any tests of the unpickling. I'm not sure how effective such a test would be with a static blob and I don't know if we want to install python3 separately in all of the python2 environments.

@codecov-io
Copy link

codecov-io commented Sep 30, 2018

Codecov Report

Merging #633 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #633   +/-   ##
=======================================
  Coverage   75.29%   75.29%           
=======================================
  Files          30       30           
  Lines        2882     2882           
=======================================
  Hits         2170     2170           
  Misses        712      712
Impacted Files Coverage Δ
src/rosdep2/sources_list.py 87.17% <100%> (ø) ⬆️

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 dc3c601...4cc9b12. Read the comment docs.

@NikolausDemmel
Copy link
Contributor

Cool, thanks for looking into this.

The patch looks reasonable. Also, fix_imports seems to be True by default, so we are using it.

Have you also tried reading a dump created with python 2 in python 3? One thing I could see going wrong is that after loading in python 3 strings are now bytes instead, but maybe not.

Some sort of test would be great for future regressions. A test that could run in just the current version that is being tested (be it pyhton 2 or 3):

  • write small cache and compare blob to checked in reference blob (I'm assuming the binary representation is not changing, which would have to be verified).
  • load from the checked in blob and do simple query

Except for testing aspect, +1 on this PR

@cottsay
Copy link
Member

cottsay commented Oct 1, 2018

Relevant documentation for observers: https://docs.python.org/3/library/pickle.html#pickle.dump

Looks like the correct and least disruptive fix to me. It's nice that the docs specifically call out Python2 compatibility.

Adds two test fixture files, a rosdep cache sample generated from
python2 and one generated from python3 and makes sure that they both
unpickle to the same data structure.
@NikolausDemmel
Copy link
Contributor

I tested this branch in both directions (updating with py2, reading with py3 and vice versa), and it seems to work fine, where master fails if py2 tries to read a py3 created cache.

+1 for merging as is.

@nuclearsandwich
Copy link
Contributor Author

@NikolausDemmel I have a branch that tests unpickling a file created with this branch in python2 and python3 produces equivalent data structures I just have to find time to get it cleaned up and pushed.

Copy link
Contributor

@wjwwood wjwwood left a comment

Choose a reason for hiding this comment

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

lgtm

@wjwwood
Copy link
Contributor

wjwwood commented Nov 1, 2018

Looks like the only failure is related to new warnings from flake8, so this should be ok to merge. It would be nice to fix those in a different pr.

@NikolausDemmel
Copy link
Contributor

Looks like the only failure is related to new warnings from flake8, so this should be ok to merge. It would be nice to fix those in a different pr.

There is already #636 ;-)

@wjwwood
Copy link
Contributor

wjwwood commented Nov 1, 2018

There is already #636 ;-)

Fair enough :)

Sorry I just haven't had the bandwidth to do anything here in a while.

@NikolausDemmel
Copy link
Contributor

No worries, I can relate. Thanks for merging. :-)

@nuclearsandwich nuclearsandwich merged commit c54bcf4 into ros-infrastructure:master Nov 6, 2018
@nuclearsandwich nuclearsandwich deleted the pickle-protocol-party branch November 6, 2018 15:01
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.

5 participants