Prepare transition to let cloudpickle.Pickler point to CloudPickler#372
Prepare transition to let cloudpickle.Pickler point to CloudPickler#372twoertwein wants to merge 1 commit intocloudpipe:masterfrom twoertwein:master
Conversation
Codecov Report
@@ Coverage Diff @@
## master #372 +/- ##
==========================================
- Coverage 92.95% 86.40% -6.56%
==========================================
Files 2 2
Lines 809 809
Branches 164 164
==========================================
- Hits 752 699 -53
- Misses 29 78 +49
- Partials 28 32 +4
Continue to review full report at Codecov.
|
ogrisel
left a comment
There was a problem hiding this comment.
Could you please add a test that checks that the warning is raised and that the cloudpickle.Pickler attribute is the same as pickle._Pickler for the time being?
Also it seems to not work as expected at the moment:
>>> from cloudpickle import Pickler
Traceback (most recent call last):
File "<ipython-input-3-9a7c65e34d9c>", line 1, in <module>
from cloudpickle import Pickler
ImportError: cannot import name 'Pickler' from 'cloudpickle' (/home/ogrisel/code/cloudpickle/cloudpickle/__init__.py)|
thank you for testing! I will add this test and avoid the f-string for older python versions. It seems that this code probably only works for python >=3.7 [1]. It works for me on 3.8, which python version are you using? There might be some 'ugly' tricks to get something like that working on <3.7 " Typical workarounds are assigning |
|
We could raise the |
|
I don't understand why the test case fails for python >= 3.7 |
|
The tests are failing because you added a As for the compatibility issue with In [15]: import warnings
...: import types
...: class CustomModuleType(types.ModuleType):
...: def __getattr__(self, name):
...: if name == 'Pickler':
...: warnings.warn('Pickler will point to Cloudpickler in two releases')
...: return self._Pickler
...: else:
...: raise AttributeError
...: import cloudpickle.cloudpickle as cp
...: cp.__class__ = CustomModuleTypegives: In [15]: cp.Pickler
/home/pierreglaser/.virtualenvs/cloudpickle_py37/bin/ipython:6: UserWarning: Pickler will point to Cloudpickler in two releases
Out[15]: pickle._PicklerI'd rather not have |
|
@pierreglaser thank you! I was importing cloudpickle while being in the ./cloudpickle folder. The warnings are raised now and I can import Pickler :) but |
|
Ah indeed, def __reduce__(self):
return __import__, ("cloudpickle.cloudpickle",)Should be enough, although I have not checked. |
|
@pierreglaser it seems that the |
Probably because we forgot to define |
Warn users of a future change that
cloudpickle.Pickler(currently pointing topickle._Pickler) will point tocloudpickle.CloudPickler.See #366
Replaces #235