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

Alias CloudPickler in the cloudpickle namespace as Pickler #235

Closed
wants to merge 2 commits into from

Conversation

dbczumar
Copy link

@dbczumar dbczumar commented Jan 23, 2019

Currently, the Pickler class in the cloudpickle namespace refers to pickle.Pickler. Certain libraries, such as PyTorch, leverage the Pickler class of a specified pickling module to serialize objects (see https://github.com/pytorch/pytorch/blob/fc5b79cd1c6020c20640128e43bac43fd636121e/torch/serialization.py#L290). When these libraries attempt reference the cloudpickle.Pickler, they obtain the pickle.Pickler class instead of cloudpickle.CloudPickler.

Working under the assumption that users referring to cloudpickle.Pickler desire/expect a reference to cloudpickle.CloudPickler, this PR aliases cloudpickle.CloudPickler as cloudpickle.Pickler and imports pickle.Pickler as _Pickler to avoid a naming conflict.

@codecov-io
Copy link

codecov-io commented Jan 23, 2019

Codecov Report

Merging #235 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #235      +/-   ##
==========================================
+ Coverage   85.12%   85.15%   +0.02%     
==========================================
  Files           1        1              
  Lines         585      586       +1     
  Branches      117      117              
==========================================
+ Hits          498      499       +1     
  Misses         63       63              
  Partials       24       24
Impacted Files Coverage Δ
cloudpickle/cloudpickle.py 85.15% <100%> (+0.02%) ⬆️

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 be70ffe...71897dd. Read the comment docs.

@dbczumar
Copy link
Author

@ogrisel Can you take a look at this? Thanks!

@ogrisel
Copy link
Contributor

ogrisel commented Jan 24, 2019

I am fine with this. Please add a changelog entry targeting the 0.8.0 release.

Before merging I would like to have the opinion of other developers / downstream users of cloudpickle. Pseudo-random ping:

@rgbkrk @pitrou @HyukjinKwon @mrocklin ...

@mrocklin
Copy link
Contributor

mrocklin commented Jan 24, 2019 via email

@pitrou
Copy link
Member

pitrou commented Jan 24, 2019

I don't think we should change the public API of the cloudpickle module; this will become confusing, especially as the different behaviour between two cloudpickle versions might not be immediately obvious.

OTOH you could object that cloudpickle has always been experimental and subject to change without notice.

Certain libraries, such as PyTorch, leverage the Pickler class of a specified pickling module to serialize objects

Well PyTorch should perhaps be more flexible. I don't understand the concept of making the module name configurable, rather than the actual serialization functions (or classes).

@ogrisel
Copy link
Contributor

ogrisel commented Jan 24, 2019

+1 for using a FutureWarning when instantiating cloudpickle.Pickler now and schedule to do the switch in cloudpickle 1.0 then.

@@ -64,7 +64,7 @@


if sys.version < '3':
from pickle import Pickler
from pickle import Pickler as _Pickler
Copy link
Member

@rgbkrk rgbkrk Jan 24, 2019

Choose a reason for hiding this comment

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

If we go with this, we better leave a comment as to why we're using _Pickler here as some future contributor & maintainer may not know the context and end up breaking this use case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Very good point.

Copy link
Member

Choose a reason for hiding this comment

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

@dbczumar -- could you add the context around this PR to the import(s) to help our future selves?

@ogrisel
Copy link
Contributor

ogrisel commented Oct 12, 2023

This was done in #366.

Furthermore #517 will re-alias the other way around: cloudpickle.CloudPickler will become an alias to cloudpickle.Pickler which will become the main class.

@ogrisel ogrisel closed this Oct 12, 2023
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.

6 participants