Skip to content

Cloudpickle fails on boost-histogram #342

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

Closed
paulgessinger opened this issue Mar 26, 2020 · 4 comments · Fixed by #343
Closed

Cloudpickle fails on boost-histogram #342

paulgessinger opened this issue Mar 26, 2020 · 4 comments · Fixed by #343

Comments

@paulgessinger
Copy link

paulgessinger commented Mar 26, 2020

I'm using boost histograms inside Coffea accumulators. I ran into the issue now that boost histograms appear not to be pickleable by cloudpickle (anymore? I think this used to work).

When running something like this:

import cloudpickle
h = bh.Histogram(bh.axis.Regular(50, 0, 20))
h.fill([1 ,2 , 3, 4, 5])
cloudpickle.dumps(h)

I get an error like

AttributeError: module 'boost_histogram._core' has no attribute '__path__'

Should that even work? If so, any pointers how I can resolve or circumvent this issue? This is especially unfortunate since standard pickle appears to work fine, but Coffea uses cloudpickle.

@henryiii
Copy link
Member

This should be doable, as long as you can cloudpickle numpy arrays and things like that. I thought cloudpickle was supposed to simply pickle any normally picklable objects. I'll check, and maybe see if I can add it to the tests.

@paulgessinger
Copy link
Author

I think it's failing while trying to figure out if the module is a dynamic one or not, where cloudpickle advertises being able to also serialize dynamic ones.

@henryiii
Copy link
Member

henryiii commented Mar 26, 2020

The following workaround solves this for now:

bh._core.hist.__file__ = bh._core.__file__

I think PyBind11 should probably do this by default. Manually doing this at the C++ level seems to cause a segfault.

@paulgessinger
Copy link
Author

The workaround does fix it it for me! Thanks for the help!

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 a pull request may close this issue.

2 participants