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

Segfault in basico when simulating BIOMD0000000516 after BIOMD0000000513. #10

Closed
CiaranWelsh opened this issue Jan 24, 2022 · 10 comments
Closed
Assignees

Comments

@CiaranWelsh
Copy link

Hello, I've been trying to load and simulate the curated section of biomodels using basico. It seems there is a segfault when trying to simulate model 516 after 513 has already been loaded/simulated. Here's the code:

from basico import *
import os
import glob
import time
try:
    from roadrunner.tests.download_biomodels import download_biomodels
except ImportError:
    raise ImportError("Do a `pip install libroadrunner==2.2.0`")

biomodels_folder = os.path.join(os.path.dirname(__file__), "biomodels")

if not os.path.isdir(biomodels_folder):
    biomodels_folder = download_biomodels(os.path.dirname(__file__))

if not os.path.isdir(biomodels_folder):
    raise NotADirectoryError(biomodels_folder)

biomodels_files = glob.glob(os.path.join(biomodels_folder, "*.xml"))

print(len(biomodels_files))

start = time.time()
for model_file in [biomodels_files[512], biomodels_files[515]]:
    try:
        print(model_file)
        model = load_model(model_file)
        result = run_time_course(duration=100)
    except Exception:
        print(f"Model {model_file} failed")

end = time.time() - start

output:

1036
D:\roadrunner\roadrunner\docs\source\parallel\roadrunner_map\biomodels\BIOMD0000000513.xml
D:\roadrunner\roadrunner\docs\source\parallel\roadrunner_map\biomodels\BIOMD0000000516.xml

Process finished with exit code -1073740791 (0xC0000409)

@fbergmann fbergmann self-assigned this Jan 24, 2022
@fbergmann
Copy link
Member

thanks for letting us know, i will see what the issue would be.

@fbergmann
Copy link
Member

Sorry for the inconvenience, for now please use the workaround:


for model_file in [biomodels_files[512], biomodels_files[515]]:
    try:
        print(model_file)
        model = load_model(model_file)
        result = run_time_course(duration=100)
        remove_datamodel(model)
        remove_user_defined_functions()
    except Exception:
        print(f"Model {model_file} failed")

until we can release a new COPASI version to fix this issue.

@CiaranWelsh
Copy link
Author

Thanks Frank, that works now. As an FYI, basico/coapsi loaded and simulated all the models in biomodels (ignoring failures as above) in around 160 seconds. RoadRunner v2.2.0 did it in around 135, though I was able to get about 3 times performance improvement with multithreading (RoadRunnerMap). Do you know if basico/copasi will work with the multithreading module in Python, or will I run into pickling issues? Thanks

@fbergmann
Copy link
Member

I have an example of using the multiprocessing module with basico here:

https://github.com/copasi/basico/blob/master/examples/parallel_scan.py

If you do encounter issues, please let me know.

@CiaranWelsh
Copy link
Author

Cool. Thanks

@CiaranWelsh
Copy link
Author

Sometimes the result = run_time_course(duration=100) line encounters numerical instability. Is there any way to detect this programatically so that I can count the failures?

@fbergmann
Copy link
Member

currently, if an error is found, it is logged in the error category, so assuming you use this in test functions, you could use any of the test fixtures for logging:

https://testfixtures.readthedocs.io/en/latest/logging.html

i could add an option to throw an exception instead of logging.

@CiaranWelsh
Copy link
Author

Would there be a way to retroactively check the number of errors logged? The following fails to count all models that have failed to load or simulate.

    start = time.time()
    failures = 0
    for model_file in biomodels_files:
        try:
            model = load_model(model_file)
            result = run_time_course(duration=100)
            remove_datamodel(model)
            remove_user_defined_functions()
        except Exception:
            failures += 1
            print(f"Model {model_file} failed")

    end = time.time() - start

    print(f"Took {end} seconds")
    print(f"failures: {failures}")

@CiaranWelsh
Copy link
Author

Okay I see what you meant now. LogCapture works, thanks.

@fbergmann
Copy link
Member

a version of the python-copasi package has been released that avoids the original segfault. closing this issue.

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

No branches or pull requests

2 participants