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
¶
One exposure of the repository, the published version of a model.
Selection
dataclass
¶
A snapshot of the exposures of the check, physiome/models.json.
physiome_cache
¶
Cache directory of the workspaces.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cache
|
Path | None
|
cache root, |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
|
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
¶
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. |
required |
Returns:
| Type | Description |
|---|---|
Exposure | None
|
The exposure with the first CellML file it links to, |
Exposure | None
|
links to none or has no workspace or commit. |
Raises:
| Type | Description |
|---|---|
PhysiomeError
|
if the exposure cannot be fetched. |
remove_tree
¶
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
¶
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, |
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
¶
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, |
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
¶
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 a selection file written by write_selection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
the JSON file, e.g. |
required |
Returns:
| Type | Description |
|---|---|
Selection
|
The selection. |
Raises:
| Type | Description |
|---|---|
PhysiomeError
|
if the file cannot be read or has no models. |