Skip to content

run

Running the simulation experiments of a model and collecting their figures.

This is the helpers.run_experiments and the run_simulation_experiments of simulations.py which every model of pkdb_models had as a copy: the experiments run with the simulator settings of the model, the figures are drawn with its figure settings, the HTML report is written, and run_simulation_experiments copies the figures into _figures.

Every experiment runs, also after another one failed: sbmlsim logs a failure with its traceback and records it. Once the report (and the collected figures) are written, a run with a failure raises ExperimentRunError, whose failures name every failed experiment and figure.

create_simulator

create_simulator(settings)

Get the simulator of sbmlsim with the settings of a model.

Parameters:

Name Type Description Default
settings SimulatorSettings

the tolerances and the processes of the simulations.

required

Returns:

Type Description
Simulator

The simulator.

run_experiments

run_experiments(
    model,
    experiment_classes,
    output_dir,
    *,
    save_results=None,
    show_report=False,
    figure_formats=None,
    simulator=None,
)

Run simulation experiments of a model and create their report.

sbmlsim does not configure logging, so the messages of the package are shown on the rich console explicitly.

Parameters:

Name Type Description Default
model PKPDModel

the model whose experiments run.

required
experiment_classes type[SimulationExperiment] | Sequence[type[SimulationExperiment]]

the experiment class or classes to run.

required
output_dir str | Path

directory of the results; a relative directory is below the simulation results of the model (model.simulation_dir).

required
save_results bool | None

store the results of the simulations, model.save_results by default.

None
show_report bool

open the report in a web browser.

False
figure_formats Sequence[str] | None

the formats of the figures, those of the model by default; an empty sequence falls back to the formats of the model as well.

None
simulator SimulatorSettings | None

the settings of the simulator, those of the model by default, e.g. with more processes.

None

Returns:

Type Description
Path

The directory the results were written to.

Raises:

Type Description
TypeError

if figure_formats is a single string.

ExperimentRunError

after the report is written, if an experiment or a figure failed; its failures name them, the log of the run has the tracebacks.

run_simulation_experiments

run_simulation_experiments(
    model,
    experiment_classes,
    output_dir,
    *,
    show_report=False,
    figure_formats=None,
    simulator=None,
)

Run simulation experiments and collect their figures.

The static figures of all experiments (COLLECTED_FORMATS) are copied into _figures of the output directory, also those of a run with failures.

Parameters:

Name Type Description Default
model PKPDModel

the model whose experiments run.

required
experiment_classes Sequence[type[SimulationExperiment]]

the experiments to run.

required
output_dir str | Path

directory of the results, see run_experiments.

required
show_report bool

open the report in a web browser.

False
figure_formats Sequence[str] | None

the formats of the figures, those of the model by default.

None
simulator SimulatorSettings | None

the settings of the simulator, those of the model by default.

None

Returns:

Type Description
Path

The directory of the collected figures.

Raises:

Type Description
ExperimentRunError

after the figures are collected, if an experiment or a figure failed.