-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add a dummy ProjectHDFio class for generic to_dict() #1178
Conversation
This is code copied over from tinybase. Originally my plan was to stabilize |
DummyHDFio implements a minimal subset of methods of ProjectHDFio to allow any object implementing HasHDF or the to_hdf/from_hdf convention to write itself into it. Afterwards a plain dict of everything stored to "HDF" can be obtained by DummyHDFio.to_hdf(). >>> hdf = DummyHDFio(Project(...), '/', {}) >>> obj = MyFancyObject() >>> obj.to_hdf(hdf) >>> hdf.to_dict() {...}
Last two commit also added support for hdf = DummyHDFio(pr, '/')
cu = pr.create.structure.bulk('Cu')
cu.to_hdf(hdf, 'my_copper')
hdf['my_copper'].to_object() == cu or maybe more interestingly hdf = DummyHDFio(pr, '/')
cu = pr.create.structure.bulk('Cu')
cu.to_hdf(hdf, 'my_copper')
cu_dict = hdf.to_dict()
# transfer cu_dict to another machine via some executor or channel
cu == DummyHDFio(pr, '/', cu_dict)['my_copper'].to_object() |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
DummyHDFio implements a minimal subset of methods of ProjectHDFio to allow any object implementing HasHDF or the to_hdf/from_hdf convention to write itself into it. Afterwards a plain dict of everything stored to "HDF" can be obtained by DummyHDFio.to_hdf().