Skip to content

Conversation

@StephenNneji
Copy link
Contributor

Addresses part of #73

Copy link
Collaborator

@alexhroom alexhroom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@StephenNneji
Copy link
Contributor Author

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

Copy link
Collaborator

@alexhroom alexhroom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no worries then! i don't understand either, but this should do

@StephenNneji StephenNneji merged commit fe0a45e into RascalSoftware:main Sep 4, 2024
@StephenNneji StephenNneji deleted the make_class_pickleable branch December 2, 2024 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants