Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

odezoo.api

The Python interface to odezoo: list, search and fetch models

models

models(*, registry: Path | str | None = None) -> list[Model]

List every model in the registry

Parameters

registry : Path | str
A registry checkout to use instead of $ODEZOO_REGISTRY or the bundled registry

Returns

list[Model]
The models, sorted by id

model

model(id: str, *, registry: Path | str | None = None) -> Model

Look up one model

Parameters

id : str
The model’s id; other capitals and surrounding spaces are forgiven
registry : Path | str
A registry checkout to use instead of $ODEZOO_REGISTRY or the bundled registry

Returns

Model
The model: its paper, keywords, versions and sources

Raises

ModelNotFound
If no model has that id; the message suggests similar ones
search(text: str = '', *, category: str | Sequence[str] | None = None, keyword: str | Sequence[str] | None = None, species: str | Sequence[str] | None = None, family: str | Sequence[str] | None = None, format: str | None = None, reviewed: bool | None = None, registry: Path | str | None = None) -> list[Model]

Find models by text and filters

Every word of text must occur somewhere in the model’s id, name, family, paper title and authors, keywords, cell type or species. Several values for one filter are alternatives; different filters must all hold.

Parameters

text : str
Words that must all occur, in any case; by default none
category : str | Sequence[str]
Categories, from odezoo.schema.CATEGORIES, of which a model must have one
keyword : str | Sequence[str]
Keywords of which a model must have one
species : str | Sequence[str]
Species, in any case, one of which must be the model’s
family : str | Sequence[str]
Families, one of which must be the model’s
format : str
A format, cellml or ode, that the model must have a version in
reviewed : bool
True for reviewed models only, False for unreviewed ones only
registry : Path | str
A registry checkout to use instead of $ODEZOO_REGISTRY or the bundled registry

Returns

list[Model]
The matching models, sorted by id

values

values(field: str, text: str = '', *, category: str | Sequence[str] | None = None, keyword: str | Sequence[str] | None = None, species: str | Sequence[str] | None = None, family: str | Sequence[str] | None = None, format: str | None = None, reviewed: bool | None = None, registry: Path | str | None = None) -> dict[str, int]

Count how many models have each value of a field, such as each species

The models counted are those search finds with the same text and filters.

Parameters

field : str
category, keyword, species, family, format or cell_type
text : str
Words that must all occur, in any case; by default none
category : str | Sequence[str]
Categories, from odezoo.schema.CATEGORIES, of which a model must have one
keyword : str | Sequence[str]
Keywords of which a model must have one
species : str | Sequence[str]
Species, in any case, one of which must be the model’s
family : str | Sequence[str]
Families, one of which must be the model’s
format : str
A format, cellml or ode, that the model must have a version in
reviewed : bool
True for reviewed models only, False for unreviewed ones only
registry : Path | str
A registry checkout to use instead of $ODEZOO_REGISTRY or the bundled registry

Returns

dict[str, int]
Each value and the number of models with it, the most common first, then alphabetically; models without a value are left out

Raises

ValueError
If field is not one of those above

get

get(id: str, *, version: str | None = None, format: str | None = None, dest: Path | str | None = None, cache: bool = True, cache_dir: Path | str | None = None, registry: Path | str | None = None, force: bool = False) -> Path

Fetch a model’s file, verified by its sha256, and return where it is

The file is taken from the registry checkout, the cache, this repository’s copy on GitHub or upstream, in that order, and only with the sha256 the registry records for it.

Parameters

id : str
The model’s id
version : str
The version to fetch; by default the model’s default version, else its newest
format : str
cellml or ode: the version must be in this format
dest : Path | str
Where to write the file: an existing folder, or a path ending in a separator (such as models/, created if missing), gets <id>.<ext> in it, and anything else is the path of the file. By default the file is not copied, and its path in the cache (or in the registry checkout) is returned.
cache : bool
Whether to read and write the cache, by default True; False needs dest
cache_dir : Path | str
The cache folder, by default $ODEZOO_CACHE_DIR or else the platform’s cache folder
registry : Path | str
A registry checkout to use instead of $ODEZOO_REGISTRY or the bundled registry
force : bool
Whether to overwrite a different file at the destination, by default False

Returns

Path
The file

Raises

ModelNotFound
If no model has that id
VersionNotFound
If the model has no such version, or none in format
FetchError
If no place gave the file with the recorded sha256
OutputExistsError
If the destination holds a different file and force is False
OdezooError
If the file cannot be kept in the cache and dest is not given
ValueError
If cache is False and dest is not given