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

_pickle.PicklingError: Can't pickle typing.Union[str, NoneType]: it's not the same object as typing.Union #428

Closed
omry opened this issue Feb 20, 2020 · 7 comments
Labels
bug Something isn't working

Comments

@omry
Copy link
Collaborator

omry commented Feb 20, 2020

Opening a dedicated issue to discuss an error from CloudPickle on 3.6 (spinoff from #421).
Will look into it in more details after #415 lands:
That PR is adding a method for users to define their configuration.
As a part of the PR, I am porting the joblib plugin configuration to the new method and this is where I saw the issue on 3.6.
I am many users to follow this pattern in the next version of Hydra.

In fact I already ran into the same issue while working on OmegaConf with the unit tests for regular Pickle and I worked around it somehow.
I am not sure this is a cloudpickle issue (unclear what is the relation between the standard pickle and cloudpickle).

Context:

Unrelated to the joblib issue on 3.6, I ran into a new issue in a branch I will land now that will give me another reason to block 3.6 for this plugin.
This is probably a week or so from landing. If you start seeing errors about:
_pickle.PicklingError: Can't pickle typing.Union[str, NoneType]: it's not the same object as typing.Union

This might be related to this bug that was just fixed in master by @pierreglaser: cloudpipe/cloudpickle#347

This is about silently dropping type annotations on dynamic classes in Python 3.6. If you really need to pickle type annotations on dynamic functions or classes (without silent drop), then there is this PR but it's quite complex and I don't have time to review it at the moment.

@omry omry added the bug Something isn't working label Feb 20, 2020
@omry
Copy link
Collaborator Author

omry commented Feb 20, 2020

@ogrisel opening another issue to keep the dicussion of the joblib segfault focused.
cloudpipe/cloudpickle#348 definitely sound related.

Actually OmegaConf is going to make runtime use of Python annotations, so dropping them is suboptimal.
See the structured configs in the docs for the next version

@ogrisel
Copy link

ogrisel commented Feb 26, 2020

Please let us know if the solution implemented in cloudpipe/cloudpickle#318 fixes the problem for you.

Note that joblib still vendors cloudpickle and loky in the joblib/externals subfolder so you have to copy the files there. You can use the helper script to do so:

pip install -e joblib
cd joblib/externals
bash vendor_cloudpickle.sh /path/to/cloudpicke_checkout_folder_with_the_right_branch

@omry
Copy link
Collaborator Author

omry commented Feb 27, 2020

My joblib plugin tests are passing with it on 3.6 so looks like it is solving the problem.

@omry
Copy link
Collaborator Author

omry commented Feb 27, 2020

@ogrisel, Is that fix fully serializing the type information or does it strip some down?

@ogrisel
Copy link

ogrisel commented Feb 27, 2020

I haven't had the time to review cloudpipe/cloudpickle#318 yet but I believe it should preserve all the type info.

@omry
Copy link
Collaborator Author

omry commented May 13, 2020

Issue fixed in cloudpickle.

@skylie-xtj
Copy link

python 3.7 is ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants