You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When _is_dynamic checks a module, it only looks for the __spec__ and __file__ of the module being checked, and if that is not defined, it looks for the __path__ on the module above. For a PyBind11 module with a submodule, the __file__ is defined on the main module, but not submodules, and there is no __path__. So things in submodules cannot be cloudpickled.
I think the function should be recursively checking up the the module path, and shouldn't try to access parent.__path__ without a check or try.
Ref: scikit-hep/boost-histogram#342 . There, boost_histogram._core.hist is a submodule in boost_histogram/_core.so. Since hist is a submodule, it checks boost_histogram._core.__path__ which does not exist, though boost_histogram._core.__file__ does. (though you may need to go up further if this is a nested submodule).
Thanks for reporting. I'll work on a fix ASAP. If you know of a good way to fix this, feel free to submit a PR. I'm not an expert of the Python import machinery.
I don't want to break dynamic modules. Can a dynamic module be nested inside a normal one? If not, this is an easy fix. And what's an example of a dynamic module?
We have tests that should cover the pickling of dynamic modules, so if your fix breaks the picking of dynamic module, the CI will let us know. I’m not quite sure what you mean by “nested dynamic modules”. Feel free to add any unit test that you think is relevant alongside your fix :)
Activity
henryiii commentedon Mar 26, 2020
Ref: scikit-hep/boost-histogram#342 . There,
boost_histogram._core.histis a submodule inboost_histogram/_core.so. Since hist is a submodule, it checksboost_histogram._core.__path__which does not exist, thoughboost_histogram._core.__file__does. (though you may need to go up further if this is a nested submodule).henryiii commentedon Mar 26, 2020
(It might be that PyBind11 should setNevermind, setting this in C++ causes a segfault.__file__on submodules)pierreglaser commentedon Mar 26, 2020
Thanks for reporting. I'll work on a fix ASAP. If you know of a good way to fix this, feel free to submit a PR. I'm not an expert of the Python import machinery.
henryiii commentedon Mar 28, 2020
I don't want to break dynamic modules. Can a dynamic module be nested inside a normal one? If not, this is an easy fix. And what's an example of a dynamic module?
pierreglaser commentedon Mar 28, 2020
We have tests that should cover the pickling of dynamic modules, so if your fix breaks the picking of dynamic module, the CI will let us know. I’m not quite sure what you mean by “nested dynamic modules”. Feel free to add any unit test that you think is relevant alongside your fix :)
pierreglaser commentedon Mar 31, 2020
Out of curiosity, are you using the C/Python API to do such an operation?
henryiii commentedon Mar 31, 2020
Yes; the PyBind11 API which is just a wrapper around the CPython API. Not sure where the crash came from,
__file__might not have been set yet.py-cloudpickle: updated to 2.0.0