Makes the arguments from RAT_main and events data pickleable by StephenNneji · Pull Request #74 · RascalSoftware/python-RAT · GitHub
Skip to content

Makes the arguments from RAT_main and events data pickleable - #74

Merged
StephenNneji merged 1 commit into
RascalSoftware:mainfrom
StephenNneji:make_class_pickleable
Sep 4, 2024
Merged

Makes the arguments from RAT_main and events data pickleable#74
StephenNneji merged 1 commit into
RascalSoftware:mainfrom
StephenNneji:make_class_pickleable

Conversation

@StephenNneji

Copy link
Copy Markdown
Contributor

Addresses part of #73

@alexhroom alexhroom left a comment

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
Contributor Author

@alexhroom alexhroom left a comment

Copy link
Copy Markdown
Collaborator

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