-
Notifications
You must be signed in to change notification settings - Fork 19
Description
NB This issue is mainly an aide-mémoire for @ns-rse and doesn't need to be specifically address in and of itself.
Whilst working through #1102 I've found that I would like to save and subsequently load different stages of processing
to .topostats
files so that tests don't require lots of pre-processing (viz. disordered tracing required before
nodestats, nodestats required before ordered tracing, ordered tracing required beofre splining and splining required
before curvature).
Unforutnately because we are adopting/migrating to dataclass
es we are unable to pickle such classes as we hit...
outfile = RESOURCES / "tracing" / "ordered_tracing" / "minicircle_post_nodestats.pkl"
with outfile.open("wb") as f:
> pkl.dump(topostats_object, f)
E TypeError: cannot pickle 'property' object
This is a problem that we will have to solve in some manner because whilst we have methods to convert the classes to
dictionary (see various *_to_dict()
methods in topostats.classes
) which helps when writing objects to HDF5 we need
to also be able to read HDF5 back into Python and recreate the classes (i.e. TopoStats
, GrainCrop
Nodes
etc.).
There is probably a laborious/manual way of doing this but the "Pythonic" way of doing seems to be to use the duneder
methods __getstate__()
and __setstate()__
as detailed in pickle — Python object serialization — Python 3.13.7
documentation (see also
thread).
Its quite possible I'm looking up the wrong avenue for a solution but I think this might be the approach to take so am
noting it here so I don't forget.