project_checks¶
The checks of a project as functions: the registry, the experiments, the fits.
A model package, or a repository of model packages, calls them from its own
tests, so a package which is exported into a repository of its own keeps them
(check_model checks that the project belongs to its package):
# not executed
@pytest.mark.parametrize("project", PROJECTS)
def test_experiments_registered(project: Project) -> None:
project_checks.check_registry(project)
The known exceptions of the checks (experiments which are not registered on
purpose, modules which do not import, the reason to run the experiments one
at a time, the checks of a battery which fail) are the checks of the
project, sbmlsim.project.CheckSettings, each with its reason.
The functions raise AssertionError with a message which names every problem,
also for experiments which fail to initialize or to run.
import sbmlsim does not import this module; it imports the experiments and
the fits when a check runs.
BatteryResult
¶
Bases: Protocol
The result of a check of a battery, see check_battery.
Attributes:
| Name | Type | Description |
|---|---|---|
check |
object
|
the check, its name as its |
passed |
bool | None
|
whether the check passed, |
status |
object
|
the status of the check, as its |
problems |
Sequence[str]
|
the problems of a failed check, one line each. |
Battery
¶
Bases: Protocol
A battery of checks of the models of a project, see check_battery.
experiment_modules
¶
Import the modules of the experiments of a project.
The module is CheckSettings.experiment_modules below the package of the
project, a package whose modules are imported with it, or a module. The
modules in CheckSettings.not_importable are skipped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
Project
|
the project. |
required |
Returns:
| Type | Description |
|---|---|
list[ModuleType]
|
The imported modules and the traceback of every module which does not |
dict[str, str]
|
import, by its name relative to the package of the project. |
Raises:
| Type | Description |
|---|---|
AssertionError
|
for a project without a package. |
defined_experiments
¶
Get the experiments defined in modules, without the base experiments.
A base experiment is a class from which another of the found classes derives.
registered_experiments
¶
Get the experiments of the group all of a project.
check_registry
¶
Check that every experiment a project defines is one of its experiments.
Every module of the experiments imports (experiment_modules), every
experiment is in the group all once, and the known exceptions of
project.checks are still exceptions (a listed class is defined and not
registered, a listed module exists).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
Project
|
the project. |
required |
Raises:
| Type | Description |
|---|---|
AssertionError
|
naming every problem. |
check_model
¶
Check that a project belongs to its package and its references hold.
A slip in package or root of a project resolves the references of
another project, or names the paths wrongly, without an error otherwise.
With a package, the package imports, has the project as an attribute,
its directory is root, and the name of the project is the last
component of the package (or the component ends with _<name>). The
variants, the directory of the factory, the directory of the fit records
and the file of the adopted fits lie below root, the variants and the
data paths exist, the references (the factory, the experiments, the fits,
the credibility declaration, the release hook, the actions) resolve and
the release hook is one, every action takes the
arguments of its call, the experiments load
(Project.load_experiments), the fits of a reference are not empty, and
every parameter of an adopted fit has its value and a distribution in
every variant (sbmlsim.experiment.draws.check_fit_parameters).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
Project
|
the project. |
required |
Raises:
| Type | Description |
|---|---|
AssertionError
|
naming every problem. |
initialize_experiments
¶
Initialize the experiments with their data, figures, mappings.
Every experiment is initialized, also after one which cannot be.
Returns:
| Type | Description |
|---|---|
dict[str, SimulationExperiment]
|
The experiments by name. |
Raises:
| Type | Description |
|---|---|
AssertionError
|
naming every experiment which cannot be initialized with its error; the tracebacks are in the log of sbmlsim. |
run_all_experiments
¶
Run the experiments of a project, as the kind simulate does.
Every experiment runs, also after one which failed, with the settings of
the simulator and the figures of the project
(Project.run_experiments, the implementation of Project).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
Project
|
the project. |
required |
output_dir
|
Path
|
the directory of the results. With
|
required |
n_workers
|
int | None
|
the processes of the run, serial by default, since the tests of a package run in processes of their own. |
1
|
Raises:
| Type | Description |
|---|---|
AssertionError
|
naming every failed experiment and figure, and every run which wrote no report. |
check_battery
¶
Run a battery of the checks of the models of a project.
A failed check is a problem unless the project knows it
(CheckSettings.battery); a known failure whose check passes or does not
apply no longer applies and is a problem as well.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
Project
|
the project. |
required |
run
|
Callable[[Project], B]
|
runs the battery of the project, e.g. the battery of a framework with its settings. |
required |
Returns:
| Type | Description |
|---|---|
B
|
The battery. |
Raises:
| Type | Description |
|---|---|
AssertionError
|
naming every problem. |
start_fits
¶
Start a fit of every fit problem: one start with a few evaluations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
Project
|
the project. |
required |
output_dir
|
Path
|
the directory of the results of the fits. |
required |
max_nfev
|
int
|
evaluations of the cost per start. |
2
|
Returns:
| Type | Description |
|---|---|
dict[str, dict[str, FitRun]]
|
The runs of every fit problem by its subset. |
Raises:
| Type | Description |
|---|---|
AssertionError
|
if a fit did not run. |