Skip to content

release.hooks

What a framework adds to the release of a model package.

The release of sbmlsim builds a release repository of every project: the models, the simulations, the reports of the adopted fits and the assessment of the credibility, the release notes and the pages of the site. A framework on top of sbmlsim, e.g. one of pharmacokinetic models, adds the content of its domain through a ReleaseHook, which ReleaseSettings.hook names (sbmlsim.project.Project.release_hook):

  • templates: directories of templates which are searched before the ones of sbmlsim (sbmlsim/resources/release): a template of the same path replaces the one of sbmlsim, another one adds to them, e.g. a page of the site or a part which a template of sbmlsim includes when it exists. The page of the credibility includes, in the section of every context of use (context the context), docs/credibility-acceptance.md.j2 right after its acceptance table (e.g. the tables of the rules of an extension), docs/credibility-uncertainty.md.j2 between its parameter uncertainty and its variability (e.g. the inputs of the simulations) and docs/credibility-context.md.j2 at its end, and docs/credibility-sections.md.j2 after its sections of the core, see CREDIBILITY_PARTS.
  • pages: pages of the site of its own, docs/<page>.md.j2 of its templates, with their titles in the navigation, before the release notes.
  • values: further values of the pages of the site and of the README.
  • credibility: the data of the page of the credibility, e.g. the evidence of the evidence extensions of the framework, see sbmlsim.credibility.extensions.
  • data_study: the study a file of the data of the package belongs to, which the release notes list as added, removed or changed.
  • notes_sections: sections of markdown at the end of the release notes.

Every method has a default, so a hook overrides only what it adds. The module imports nothing of the release at runtime.

ReleaseHook

What a framework adds to the release of a model package, see the module.

The base class adds nothing; a framework derives from it and overrides what it adds.

templates

templates()

Get the directories of the templates of the hook.

Returns:

Type Description
Sequence[Path | Traversable]

The directories, searched in their order before the templates of

Sequence[Path | Traversable]

sbmlsim; e.g. `importlib.resources.files("framework") /

Sequence[Path | Traversable]

"resources/release"`.

pages

pages(context)

Get the pages the hook adds to the site.

Parameters:

Name Type Description Default
context ProjectContext

the project context of the release.

required

Returns:

Type Description
Sequence[tuple[str, str]]

The pages as (page, title), the template of a page

Sequence[tuple[str, str]]

docs/<page>.md.j2 of the templates of the hook; they come before

Sequence[tuple[str, str]]

the release notes in the navigation.

values

values(context, release_path)

Get further values of the templates of the site and of the README.

Parameters:

Name Type Description Default
context ProjectContext

the project context of the release.

required
release_path Path

the built release repository.

required

Returns:

Type Description
Mapping[str, Any]

The values by their name; a value of the release of the same name

Mapping[str, Any]

is replaced.

credibility

credibility(assessment, data)

Get the data of the page of the credibility.

Parameters:

Name Type Description Default
assessment CredibilityAssessment

the assessment of the contexts of use of the release.

required
data dict[str, Any]

the data of the page as sbmlsim shows it, see sbmlsim.release.docs; the context of use i is data["contexts"][i] and assessment.contexts[i].

required

Returns:

Type Description
dict[str, Any]

The data of the page, e.g. data with the evidence of the

dict[str, Any]

extensions of the framework.

data_study

data_study(data_dir, path)

Get the study which a file of the data of the package belongs to.

The release notes key the files by their path in the release repository, so files of two data folders belong to one study only if this method gives them one name.

Parameters:

Name Type Description Default
data_dir PurePosixPath

the data folder of the file relative to the root of the package, one of the data paths of the project (sbmlsim.project.Project.data_path), e.g. data.

required
path PurePosixPath

the path of the file relative to data_dir.

required

Returns:

Type Description
str | None

The study, by default the folder of the file relative to the root

str | None

of the package, e.g. data/drug/Study2000; None for a file which

str | None

belongs to no study, by default a file at the top of the data

str | None

folder.

notes_sections

notes_sections(context, release, runner)

Get the sections of the release notes the hook adds.

Parameters:

Name Type Description Default
context ProjectContext

the project context of the release.

required
release ReleaseRepo

the release repository with the new build in its working tree and the previous release as last_tag.

required
runner Runner

runs git.

required

Returns:

Type Description
Sequence[str]

The sections as markdown, each starting with its heading of the

Sequence[str]

second level, at the end of the release notes.