Skip to content

physiome.models

Access to the Physiome Model Repository: exposures, workspaces, selection.

The repository (https://models.physiomeproject.org) publishes a model as an exposure, a fixed commit of the workspace which holds its files. Every endpoint of the site answers with JSON for the media type of its webservice, which gives the title, the commit and the files of an exposure; the files themselves come from the workspace, a git repository which is cloned into the cache, so that a model which imports another file of its workspace has them all on disk.

The models are CellML 1.0 and 1.1 documents for the most part, which libcellml reads in permissive mode (sbml2cellml.cellml.read_model).

PhysiomeError

Bases: RuntimeError

A request to the repository failed or a workspace cannot be cloned.

Exposure dataclass

Exposure(id, title, workspace, commit, path)

One exposure of the repository, the published version of a model.

Selection dataclass

Selection(date, source, models)

A snapshot of the exposures of the check, physiome/models.json.

physiome_cache

physiome_cache(cache=None)

Cache directory of the workspaces.

Parameters:

Name Type Description Default
cache Path | None

cache root, sbml2cellml.testsuite.cases.cache_dir() by default.

None

Returns:

Type Description
Path

<cache>/physiome.

exposure_urls

exposure_urls()

Urls of every exposure of the repository.

Returns:

Type Description
list[str]

The urls of the listing, in the order of the repository.

Raises:

Type Description
PhysiomeError

if the listing cannot be fetched.

exposure

exposure(url)

The exposure of a url, None when it publishes no CellML file.

Parameters:

Name Type Description Default
url str

url of the exposure, e.g. https://models.physiomeproject.org/e/5f.

required

Returns:

Type Description
Exposure | None

The exposure with the first CellML file it links to, None when it

Exposure | None

links to none or has no workspace or commit.

Raises:

Type Description
PhysiomeError

if the exposure cannot be fetched.

remove_tree

remove_tree(path)

Remove a directory tree, read-only files included.

git marks the files of its object store read-only, which os.unlink refuses on windows (PermissionError: [WinError 5] Access is denied), so a file which cannot be removed is made writable and removed again.

Parameters:

Name Type Description Default
path Path

the directory to remove.

required

workspace_dir

workspace_dir(exposure, cache=None)

Directory of the workspace of an exposure, cloned on first use.

The repository serves the workspaces over git but refuses a shallow fetch, so the whole workspace is cloned (a few megabytes) and checked out at the commit of the exposure.

Parameters:

Name Type Description Default
exposure Exposure

the exposure.

required
cache Path | None

cache root, cache_dir() by default.

None

Returns:

Type Description
Path

The directory with the files of the workspace.

Raises:

Type Description
PhysiomeError

if git is missing or the clone fails.

model_path

model_path(exposure, cache=None)

Path of the CellML file of an exposure, cloned on first use.

Parameters:

Name Type Description Default
exposure Exposure

the exposure.

required
cache Path | None

cache root, cache_dir() by default.

None

Returns:

Type Description
Path

The CellML file inside the workspace.

Raises:

Type Description
PhysiomeError

if the workspace cannot be cloned or has no such file.

query_exposures

query_exposures(limit=MAX_MODELS)

The exposures of the selection, one per workspace.

A workspace is published again whenever its model changes, so only the first exposure of a workspace is kept; the result is sorted by exposure id and cut to limit models.

Parameters:

Name Type Description Default
limit int

how many exposures to keep at most.

MAX_MODELS

Returns:

Type Description
list[Exposure]

The exposures with a CellML file.

Raises:

Type Description
PhysiomeError

if the listing cannot be fetched.

read_selection

read_selection(path)

Read a selection file written by write_selection.

Parameters:

Name Type Description Default
path Path

the JSON file, e.g. physiome/models.json.

required

Returns:

Type Description
Selection

The selection.

Raises:

Type Description
PhysiomeError

if the file cannot be read or has no models.

write_selection

write_selection(models, path)

Write the selection of a update run.

Parameters:

Name Type Description Default
models list[Exposure]

the exposures of the selection.

required
path Path

the JSON file to write.

required

Returns:

Type Description
Selection

The selection which was written.