-
Notifications
You must be signed in to change notification settings - Fork 171
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
Pickled Functions seem to be incompatible between python3.5 and python3.6+ even when using pickle.DEFAULT_PROTOCOL #293
Comments
See my compatibility analysis: cloudpipe/cloudpickle#293
I've introduced code pickling to capture dependencies in kubeflow#1372 Later I've discovered that there is a serious opcode incompatibility between python versions 3.5 and 3.6+. See my analysis of the issue: cloudpipe/cloudpickle#293 Dues to this issue I decided to switch back to using source code copying by default and to continue improving it. Until we stop supporting python 3.5 (kubeflow#668) it's too dangerous to use code pickling by default. Code pickling can be enabled by specifying `pickle_code=True` when calling `func_to_container_op`
Have you tried changing the protocol to lower version like 0? |
This isn't going to be solved by changing the protocol version. To serialize arbitrary lambdas we need to be able to send the bytecode from one machine to another. Python bytecode can change pretty radically between minor versions, and instructions could be added or removed with no clear translation making it impossible to convert between versions. I think the best we can do is strengthen the claim in the readme/docs to say, "Cloudpickle can only be used to send objects between the exact same version of Python." |
…hon versions As suggested in #293 (comment) And also add a security notice. This is not specific to cloudpickle as `load` / `loads` come from the Python standard library but it's better to be explicit that loading pickle payloads from untrusted sources is a security vulnerability.
Done in #294. I also added a security notice. Let me know what you think. |
Sounds good. |
Is there any place I can read more about those breaking changes? Do you know some other python code format (e.g. pre-compiled code) that's more stable? Something similar to .Net's CIL which has pretty good backwards compatibility. |
The generated byte code is an implementation detail of CPython. It's not part of the public API in anyway as far as I know. It's possible to grep "bytecode" in the changelog though: https://docs.python.org/3/whatsnew/changelog.html
Python is not compiled so there is nothing. Saving the source code would be an optional but that would render cloudpickle much more brittle and less efficient IMO. |
I've introduced code pickling to capture dependencies in kubeflow#1372 Later I've discovered that there is a serious opcode incompatibility between python versions 3.5 and 3.6+. See my analysis of the issue: cloudpipe/cloudpickle#293 Dues to this issue I decided to switch back to using source code copying by default and to continue improving it. Until we stop supporting python 3.5 (kubeflow#668) it's too dangerous to use code pickling by default. Code pickling can be enabled by specifying `pickle_code=True` when calling `func_to_container_op`
I've introduced code pickling to capture dependencies in kubeflow#1372 Later I've discovered that there is a serious opcode incompatibility between python versions 3.5 and 3.6+. See my analysis of the issue: cloudpipe/cloudpickle#293 Dues to this issue I decided to switch back to using source code copying by default and to continue improving it. Until we stop supporting python 3.5 (kubeflow#668) it's too dangerous to use code pickling by default. Code pickling can be enabled by specifying `pickle_code=True` when calling `func_to_container_op`
I've introduced code pickling to capture dependencies in kubeflow#1372 Later I've discovered that there is a serious opcode incompatibility between python versions 3.5 and 3.6+. See my analysis of the issue: cloudpipe/cloudpickle#293 Dues to this issue I decided to switch back to using source code copying by default and to continue improving it. Until we stop supporting python 3.5 (kubeflow#668) it's too dangerous to use code pickling by default. Code pickling can be enabled by specifying `pickle_code=True` when calling `func_to_container_op`
See my compatibility analysis: cloudpipe/cloudpickle#293
See my compatibility analysis: cloudpipe/cloudpickle#293
I've introduced code pickling to capture dependencies in #1372 Later I've discovered that there is a serious opcode incompatibility between python versions 3.5 and 3.6+. See my analysis of the issue: cloudpipe/cloudpickle#293 Dues to this issue I decided to switch back to using source code copying by default and to continue improving it. Until we stop supporting python 3.5 (#668) it's too dangerous to use code pickling by default. Code pickling can be enabled by specifying `pickle_code=True` when calling `func_to_container_op`
* SDK - Refactored the code in kfp.components._python_op._capture_function_code_using_cloudpickle * SDK/Lightweight - Added python version compatibility checks See my compatibility analysis: cloudpipe/cloudpickle#293
is it possible to store the python version with the pickled file and check it at load time? I was hoping to implement this application side but it would necessitate a metadata file which I was hoping to avoid |
Even an empty function has different 3-byte code representation in python3.5 and python3.6+.
This causes either "SystemError: unknown opcode" when going up or "Segmentation fault" when going down.
I understand that the support for this is not implied, but I think the incompatibility should be stated explicitly. "cloudpickle uses pickle.HIGHEST_PROTOCOL by default: it is meant to send objects between processes running the same version of Python." is not explicit here since it only talks about "cloudpickle useing pickle.HIGHEST_PROTOCOL by default". Which implies that using the more compatible protocol allows passing objects between different python versions.
Summary of my results:
PoC demonstrating code difference:
Pickle structure diff: https://www.diffchecker.com/aC5PuVHy
Testing code:
The text was updated successfully, but these errors were encountered: