-
Notifications
You must be signed in to change notification settings - Fork 184
Restore compatibility with functions pickled with 0.4.0 #128
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
Restore compatibility with functions pickled with 0.4.0 #128
Conversation
Release 0.4.1 introduced a change to arguments of _fill_function which meant that functions pickled before that couldn't be unpickled anymore. Addresses cloudpipe#126
I'm getting this error when unpickling with Python 3 (no stacktrace): ``` TypeError: an integer is required (got type str) ```
Codecov Report
@@ Coverage Diff @@
## master #128 +/- ##
==========================================
+ Coverage 83.94% 84.09% +0.15%
==========================================
Files 2 2
Lines 517 522 +5
Branches 90 91 +1
==========================================
+ Hits 434 439 +5
Misses 62 62
Partials 21 21
Continue to review full report at Codecov.
|
|
I'm not very happy I had to skip the tests for Python 3. My pickle/Python 3 knowledge is not deep, gladly taking suggestions for handling this better. Worst case, I could add separate set of tests for Python 3. |
|
LGTM as it is. In the long run we should probably setup a folder of sample pickle files to check version compat for the latest 2 consecutive versions but I would rather not delay 0.4.2 for this. |
|
Actually, this does not address @pitrou's comment in #126 (comment): something pickled in 0.4.2 won't be loadable in 0.4.0. But I don't see how it can be fixed. |
|
Agreed, I don't think there's any way to restore forward compatibility now. Like I said elsewhere, ultimately I think you need to carry around a protocol version marker somewhere. Then you can at least give an explicit error if you get a pickle of a version that you can't support. |
|
Actually, I take that back - there are ways to restore forward compatibility but they may be quite hacky. Basically, the |
|
@nikhaldi or we bite the bullet and transform |
|
@pitrou yeah, obviously at some point you have to redesign Ok, here's a fix which actually makes pickles compatible with 0.4.0 again: https://github.com/nikhaldi/cloudpickle/compare/feat/function_pickle_compat...nikhaldi:feat/function_pickle_forward_compat?expand=1 It works but it's a hack. I could be convinced to include this or not, I don't have strong feelings either way. |
Then let's redesign it now. Since we just broke compatibility, we might as well break it soon again than wait for next year.
I'd rather avoid this :-) |
| updated_args = args[:-1] + (None, args[-1],) | ||
| return _fill_function_internal(*updated_args) | ||
| else: | ||
| return _fill_function_internal(*args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't even need the else here:
if len(args) == 5:
# [...]
return _fill_function_internal(*updated_args)
return _fill_function_internal(*args)😊
|
I currently agree with merging this as is, with the caveat that we should remove the workaround at some point in the future. |
|
Whoops, accidentally closed and reopened, retriggering Travis. |
|
Ok merging this as it to release 0.4.2. |
|
Hum I had not read @pitrou's comment in #128 (comment). I will try to address it now. |
|
@ogrisel Maybe an issue should be opened to revert this fix in future versions? |
|
Thank you guys for fixing this .. |
## What changes were proposed in this pull request? The version of cloudpickle in PySpark was close to version 0.4.0 with some additional backported fixes and some minor additions for Spark related things. This update removes Spark related changes and matches cloudpickle [v0.4.3](https://github.com/cloudpipe/cloudpickle/releases/tag/v0.4.3): Changes by updating to 0.4.3 include: * Fix pickling of named tuples cloudpipe/cloudpickle#113 * Built in type constructors for PyPy compatibility [here](cloudpipe/cloudpickle@d84980c) * Fix memoryview support cloudpipe/cloudpickle#122 * Improved compatibility with other cloudpickle versions cloudpipe/cloudpickle#128 * Several cleanups cloudpipe/cloudpickle#121 and [here](cloudpipe/cloudpickle@c91aaf1) * [MRG] Regression on pickling classes from the __main__ module cloudpipe/cloudpickle#149 * BUG: Handle instance methods of builtin types cloudpipe/cloudpickle#154 * Fix <span>#</span>129 : do not silence RuntimeError in dump() cloudpipe/cloudpickle#153 ## How was this patch tested? Existing pyspark.tests using python 2.7.14, 3.5.2, 3.6.3 Author: Bryan Cutler <cutlerb@gmail.com> Closes apache#20373 from BryanCutler/pyspark-update-cloudpickle-42-SPARK-23159.
Release 0.4.1 introduced a change to arguments of _fill_function
which meant that functions pickled before that couldn't be
unpickled anymore.
Addresses #126