Makes the arguments from RAT_main and events data pickleable#74
Conversation
There was a problem hiding this comment.
looks good: can now run the following:
from concurrent.futures import ProcessPoolExecutor
import RATapi as RAT
def run(problem_definition, cells, limits, priors, cpp_controls):
problem_definition, output_results, bayes_results = RAT.rat_core.RATMain(
problem_definition,
cells,
limits,
cpp_controls,
priors,
)
results = RAT.outputs.make_results("calculate", output_results, bayes_results)
return results
pool = ProcessPoolExecutor()
project, _ = RAT.examples.DSPC_standard_layers()
c = RAT.Controls()
problem_definition, cells, limits, priors, cpp_controls = RAT.inputs.make_input(project, c)
result = pool.submit(run, problem_definition, cells, limits, priors, cpp_controls)
results = result.result()
print(results)can't quite pickle the entire Project object yet: with dill, the error I get is that RATapi.rat_core.EventBridge is not pickleable. Would it be difficult to make that pickleable too? no worries if it's a lot of trouble to pickle (or you foresee other problems), the above is definitely workable for what we need!
|
I don't fully understand why its trying to pickle the EventBridge when you try to pickle the Project class. The EventBridge manages the callback for the events so pickling this might be a pain and even when its pickled I don't think you can pass callback functions between processes at least I have never tried to |
alexhroom
left a comment
There was a problem hiding this comment.
no worries then! i don't understand either, but this should do
Addresses part of #73