Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifies cells to make function handles pickleable #82

Merged

Conversation

StephenNneji
Copy link
Contributor

I missed this in the PR to make the pybind classes pickleable. The function handles cannot be pickled so this defers the creation of the handles. The script below uses the languages example to test that all 3 languages pickle correctly and run in a process

from multiprocessing import Process

def f(problem_definition, cells, limits, priors, cpp_controls):
    
    start = time.time()
    problem_definition, output_results, bayes_results = RAT.rat_core.RATMain(
    problem_definition,
    cells,
    limits,
    cpp_controls,
    priors,
    )
    end = time.time()
    print(f"Run time is: {end-start}s\n")
        

if __name__ == '__main__':

    project = setup_problem.make_example_problem()
    # project.custom_files.set_fields(0, filename="custom_bilayer.m", language="matlab", path=path)
    # project.custom_files.set_fields(0, filename="custom_bilayer.dll", function_name="customBilayer", language="cpp", path=path)
    controls = RAT.Controls()
    problem_definition, cells, limits, priors, cpp_controls = RAT.inputs.make_input(project, controls)
    
    p = Process(target=f, args=(problem_definition, cells, limits, priors, cpp_controls,))
    p.start()
    p.join()

@StephenNneji StephenNneji marked this pull request as ready for review October 3, 2024 13:06
tests/test_inputs.py Outdated Show resolved Hide resolved
@StephenNneji StephenNneji merged commit 072f954 into RascalSoftware:main Oct 4, 2024
7 checks passed
@StephenNneji StephenNneji deleted the fix_custom_file_pickle 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