Closed tfunatomi closed 1 year ago
Hi!
I'm not familiar with joblib but for storing data we have example: https://github.com/K3D-tools/K3D-jupyter/blob/main/examples/snapshots.ipynb
plot = get_plot()
plot.display()
data = plot.get_binary_snapshot()
with open('binary_snapshot.k3d', 'wb') as f:
f.write(data)
and loading:
plot2 = k3d.plot()
with open('binary_snapshot.k3d', 'rb') as f:
plot2.load_binary_snapshot(f.read())
plot2.display()
That use internal binary format of k3d - without any overhead
@artur-trzesiok Thank you for your advice!
So, it might be easy to support joblib.dump()
by just defining Plot.__getstate__()
and Plot.__setstate__(state)
to call get_binary_snapshot()
and load_binary_snapshot(data)
.
https://docs.python.org/3/library/pickle.html#pickle-inst
On my environment, just adding the following lines in k3d.Plot
seems working.
def __getstate__(self):
return self.get_binary_snapshot()
def __setstate__(self,data):
self.__init__()
self.load_binary_snapshot(data)
Great finding and solution!
Hi! Please check a 2.15.3 version of k3d. It is already available :)
Description
I'm a big fan of this great module. I appreciate your efforts.
I tried to use
joblib.dump()
to store the current object, but it failed.I know that snapshot can store as a static HTML, but is there any way to store the object that can be loadable from another program?
What I Did
I used
joblib.dump()
as follows:It crashed as follows: