-
Notifications
You must be signed in to change notification settings - Fork 663
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
H5MD fails to serialize with pickle #2890
Comments
@edisj please have a look at this issue as soon as possible as it will currently lead to all CI failing. See https://docs.mdanalysis.org/2.0.0-dev0/documentation_pages/coordinates/pickle_readers.html for notes on what needs to be done. @yuxuanzhuang please give advice where possible. |
@orbeckst looking into it now |
@orbeckst @yuxuanzhuang I've been playing around and trying to implement an Edit: reading Andrew Collette's comment here h5py/h5py#531 (comment) makes sense as to why its difficult - the information needed to pickle/unpickle is not in the |
Have a quick look, and it seems that the issue is both class H5MDPicklable(h5py.File):
def __getstate__(self):
try:
driver = self._driver
except AttributeError:
driver = None
return {
'name': self.filename,
'mode': self.mode,
'driver': driver
}
def __setstate__(self, state):
self.__init__(name=state['name'],
mode=state['mode'],
driver=state['driver'])
def __getnewargs__(self):
"""Override the h5py getnewargs to skip its error message"""
return () We also need to deal with class H5MDReader(base.ReaderBase):
...
def __getstate__(self):
state = self.__dict__.copy()
del state['_particle_group']
return state
def __setstate__(self, state):
self.__dict__ = state
self._particle_group = self._file['particles'][
list(self._file['particles'])[0]] With that the test will pass, but I am not sure it works in real life (I need to read more about H5MD). |
@edisj @yuxuanzhuang did you have a look at https://github.com/DaanVanVugt/h5pickle if they are doing something special? |
The problem I'm trying to figure out is how to actually get the
but this is not the same thing as
So I don't think the @yuxuanzhuang if I understand correctly, |
* fix #2890 * added H5PYPicklable class (works in serial but not with driver="mpio" and MPI comm) * mock h5py so that the docs build even in the absence of h5py * tests (anything related to mpi is excluded from coverage) * update CHANGELOG
* fix MDAnalysis#2890 * added H5PYPicklable class (works in serial but not with driver="mpio" and MPI comm) * mock h5py so that the docs build even in the absence of h5py * tests (anything related to mpi is excluded from coverage) * update CHANGELOG
Expected behavior
All readers can be pickled and pass the tests for MultiframeReaderTest
Actual behavior
TestH5MDReader.test_pickle_reader
fails, see https://travis-ci.com/github/MDAnalysis/mdanalysis/jobs/369892996(Note that this test failure occured becaused the H5MD PR #2787 was merged before the serialization PR and the latter did not have the H5MD PR #2723 merged into it.)
Code to reproduce the behavior
Run TestH5MDReader.test_pickle_reader
Current version of MDAnalysis
python -c "import MDAnalysis as mda; print(mda.__version__)"
) current develop at 563995cpython -V
)? anyThe text was updated successfully, but these errors were encountered: