gplately.PlateModelManager

class gplately.PlateModelManager(model_manifest: str = '', timeout=(None, None))[source]

Bases: object

Manage discovery and loading of plate reconstruction model metadata.

Model manifests can be loaded from a local file or an HTTP(S) endpoint. Retrieved model configurations are used to construct PlateModel instances.

__init__(model_manifest: str = '', timeout=(None, None))[source]

Create a PlateModelManager instance.

If model_manifest is omitted, the manager probes known PMM manifest endpoints and uses the first reachable URL.

Parameters:
  • model_manifest – Local path or HTTP(S) URL for a models.json manifest. Use this when hosting a custom model repository.

  • timeout – Timeout tuple passed to HTTP requests.

Raises:
  • InvalidConfigFile – If the manifest path/URL is invalid or does not contain valid JSON.

  • ServerUnavailable – If the manifest URL cannot be reached.

Methods

__init__([model_manifest, timeout])

Create a PlateModelManager instance.

download_all_models([data_dir])

Download layer data for all available models into data_dir.

get_available_model_names()

Return all model keys from the loaded manifest.

get_default_repo_url()

Return the first reachable default model-manifest URL.

get_local_available_model_names(local_dir)

Return locally available model names from local_dir.

get_model([model_name, data_dir, ...])

Return a PlateModel for model_name.

Attributes

models

Return metadata for all configured models.

download_all_models(data_dir: str = './') None[source]

Download layer data for all available models into data_dir.

Parameters:

data_dir (str) – Destination directory for downloaded model data.

get_available_model_names()[source]

Return all model keys from the loaded manifest.

Returns:

Available model names and aliases.

Return type:

list[str]

static get_default_repo_url()[source]

Return the first reachable default model-manifest URL.

Endpoints are probed in order using HTTP HEAD requests.

Returns:

Reachable manifest URL.

Return type:

str

Raises:

ServerUnavailable – If none of the default endpoints are reachable.

static get_local_available_model_names(local_dir: str)[source]

Return locally available model names from local_dir.

Parameters:

local_dir (str) – The local folder containing models.

Returns:

Names of subdirectories that look like valid local PMM models (contain .metadata.json).

Return type:

list[str]

get_model(model_name: str = 'default', data_dir: str = '.', reference_frame: ReferenceFrame | None = None) PlateModel | None[source]

Return a PlateModel for model_name.

The method resolves aliases, applies optional reference-frame handling, and instantiates PlateModel with the resolved configuration.

Parameters:
  • model_name – Model name or alias (case-insensitive). Defaults to "default".

  • data_dir – Parent directory for model downloads and cache files.

  • reference_frame – Optional reference frame. When PMAG is requested and a _pmag_ref variant exists, that variant is selected automatically.

Returns:

A configured PlateModel, or None if the model is unavailable or incompatible with the requested reference frame.

Raises:

InvalidConfigFile – If alias resolution detects an invalid alias chain.

property models: Dict

Return metadata for all configured models.

Returns:

Mapping from model names to model entries.

Return type:

Dict

Raises:

Exception – If model metadata is unavailable.