-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Pickling functions using the ROOT module with cloudpickle breaks #6764
Copy link
Copy link
Closed
Description
cloudpickle is the pickling package, which is used in dask and PySpark to serialize and distribute the work, e.g., functions or lambdas. The following reproducer breaks with cloudpickle (but is fine with the standard pickle) and throws the error TypeError: cannot pickle 'ROOTFacade' object, which is highly confusing.
import ROOT
import cloudpickle
def foo():
ROOT.TH1F()
return 42
import cloudpickle as pickle # breaks with cloudpickle
#import pickle # works fine with the standard pickle
with open('f.pkl', 'wb') as f:
pickle.dump(foo, f)A workaround is moving the import ROOT line inside the function foo, which seems to omit the underlying issue in cloudpickle. We have submitted a bug report to the cloudpickle repository, see cloudpipe/cloudpickle#397.
Reactions are currently unavailable