-
Notifications
You must be signed in to change notification settings - Fork 170
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
Optionally use pickle5 (Redux) #370
Changes from all commits
a860509
ee722f1
d69ca86
6264641
dc9ba84
d5ed4d9
c44ad88
fd67f4b
9740b22
c657fe1
1f2410f
ebaf7f6
1d6abbd
fb34d27
a15782f
35e39d0
a03a1ab
cdaeec5
95fdce0
38ed5f5
5334e79
abbb978
eb536de
53111d3
9d56632
9e92413
043ff81
09d9e33
f74372a
829b919
f693401
46405e5
f57df63
df6fa9b
20a522b
3908dfe
e5deaf6
ff2baa9
13a76f9
393b312
52746b9
b531b14
e85ab4d
2a82a41
21c82b9
4fb4ca5
5909c38
2822390
d239943
8deef74
bb3436f
884ee89
3b98492
0469528
371d015
d661ce6
4de14b2
a0f8d73
ca07fce
96fe5c0
78602e2
dad2938
4dcbf3e
677a114
cd7cd1a
8eba950
bff0786
fccb9e3
0d11d66
0522cfb
149b01e
695cbb8
adc1220
71dcd2a
e4fc3a0
e41b4dd
4688643
5bfb9f3
794cd9d
b9ccea7
afec159
1dc8dd8
9502999
6530ff6
7aabd2a
4d33877
5800bb6
4e1bc25
cc5efb2
ec3468e
d588774
7b3f1a7
8178a2c
dc8bd28
8a890f5
5cdb5e1
268778b
f17b31a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import sys | ||
|
||
|
||
if sys.version_info < (3, 8): | ||
try: | ||
import pickle5 as pickle # noqa: F401 | ||
from pickle5 import Pickler # noqa: F401 | ||
except ImportError: | ||
import pickle # noqa: F401 | ||
from pickle import _Pickler as Pickler # noqa: F401 | ||
else: | ||
import pickle # noqa: F401 | ||
from _pickle import Pickler # noqa: F401 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ | |
import logging | ||
import math | ||
from operator import itemgetter, attrgetter | ||
import pickle | ||
import platform | ||
import random | ||
import shutil | ||
|
@@ -43,6 +42,7 @@ | |
tornado = None | ||
|
||
import cloudpickle | ||
from cloudpickle.compat import pickle | ||
from cloudpickle.cloudpickle import _is_importable | ||
from cloudpickle.cloudpickle import _make_empty_cell, cell_set | ||
from cloudpickle.cloudpickle import _extract_class_dict, _whichmodule | ||
|
@@ -521,7 +521,7 @@ def test_module_locals_behavior(self): | |
pickled_func_path = os.path.join(self.tmpdir, 'local_func_g.pkl') | ||
|
||
child_process_script = ''' | ||
import pickle | ||
from cloudpickle.compat import pickle | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. using |
||
import gc | ||
with open("{pickled_func_path}", 'rb') as f: | ||
func = pickle.load(f) | ||
|
@@ -606,7 +606,7 @@ def test_load_dynamic_module_in_grandchild_process(self): | |
child_process_module_file = os.path.join( | ||
self.tmpdir, 'dynamic_module_from_child_process.pkl') | ||
child_process_script = ''' | ||
import pickle | ||
from cloudpickle.compat import pickle | ||
import textwrap | ||
|
||
import cloudpickle | ||
|
@@ -626,7 +626,7 @@ def test_load_dynamic_module_in_grandchild_process(self): | |
|
||
# The script ran by the process created by the child process | ||
child_of_child_process_script = """ ''' | ||
import pickle | ||
from cloudpickle.compat import pickle | ||
with open('{child_process_module_file}','rb') as fid: | ||
mod = pickle.load(fid) | ||
''' """ | ||
|
@@ -681,7 +681,7 @@ def my_small_function(x, y): | |
assert b'math' not in b | ||
|
||
def test_module_importability(self): | ||
import pickle # decouple this test from global imports | ||
from cloudpickle.compat import pickle | ||
import os.path | ||
import distutils | ||
import distutils.ccompiler | ||
|
@@ -1008,7 +1008,8 @@ def example(): | |
|
||
# choose "subprocess" rather than "multiprocessing" because the latter | ||
# library uses fork to preserve the parent environment. | ||
command = ("import pickle, base64; " | ||
command = ("import base64; " | ||
"from cloudpickle.compat import pickle; " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In both of these test cases, we are using the highest supported protocol with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case I agree. Thanks. |
||
"pickle.loads(base64.b32decode('" + | ||
base64.b32encode(s).decode('ascii') + | ||
"'))()") | ||
|
@@ -1029,7 +1030,8 @@ def example(): | |
|
||
s = cloudpickle.dumps(example, protocol=self.protocol) | ||
|
||
command = ("import pickle, base64; " | ||
command = ("import base64; " | ||
"from cloudpickle.compat import pickle; " | ||
"pickle.loads(base64.b32decode('" + | ||
base64.b32encode(s).decode('ascii') + | ||
"'))()") | ||
|
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.
so we don't have to skip
numpy
+Python 3.5
after all? nice :)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.
Indeed :) PR ( numpy/numpy#16439 ) added Python 3.5 support