Commit 1452cb4b authored by Gregory Ashton's avatar Gregory Ashton

Adds a check prior to pickling to convert callable functions to strings

Limited scope to only check kwargs. These are only stored for future
reference so it shouldn't cause issues of wanting to recreate the
functions when loading results in from disc.
parent 6cd93370
Pipeline #33002 passed with stage
in 3 minutes and 8 seconds
......@@ -196,6 +196,12 @@ class Result(dict):
if dictionary.get('priors', False):
dictionary['priors'] = {key: str(self.priors[key]) for key in self.priors}
# Convert callable kwargs to strings to avoid pickling issues
if hasattr(self, 'kwargs'):
for key in self.kwargs:
if hasattr(self.kwargs[key], '__call__'):
self.kwargs[key] = str(self.kwargs[key])
try:
deepdish.io.save(file_name, dictionary)
except Exception as e:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment