mlsteam_model_sdk.core.registry

Local model registry

Classes

Registry(config_dir)

Local model registry operator

class mlsteam_model_sdk.core.registry.Registry(config_dir: Path)

Bases: object

Local model registry operator

LOCAL_MUUID = '__local__'
LOCAL_PUUID = '__local__'
__init__(config_dir: Path) None

Initializes a local model registry operator.

Parameters:

config_dir – SDK configuration base directory

delete_model(muuid: Optional[str] = None, model_name: Optional[str] = None, default_muuid: Optional[str] = None)

Deletes all model versions of a model from local registry.

A model is specified by muuid, model_name, or default_muuid.

Parameters:
  • muuid – model uuid

  • model_name – model name

  • default_muuid – default model uuid

delete_model_version(vuuid: Optional[str] = None, version_name: Optional[str] = None, muuid: Optional[str] = None, model_name: Optional[str] = None, default_muuid: Optional[str] = None, delete_all: bool = False)

Deletes one or multiple model versions from local registry.

A model version is specified in one of the following ways: - model version uuid (vuuid) alone - model (muuid, model_name, or default_muuid) combined with version (version_name)

When vuuid is given, it will attempt to delete the associated files even when the local registry is broken.

Parameters:
  • vuuid – model version uuid

  • version_name – version name

  • muuid – model uuid

  • model_name – model name

  • default_muuid – default model uuid

  • delete_all – delete all matching model versions

Raises:

MultipleModelVersionsException – there are multiple matching model versions and delete_all is not set

get_download_base_dir(create: bool = False) Path

Gets base path to download model version files or packages.

get_download_file(vuuid: str, packaged: bool, encrypted: bool, create_dir: bool = False) Path

Gets path to save a downloaded model version file or package.

get_extract_base_dir(create: bool = False) Path

Gets base path to extract non-encrypted model version packages.

get_extract_dir(vuuid: str, create_dir: bool = False) Path

Gets path to extract a downloaded model version package.

get_model_version_info(vuuid: Optional[str] = None, version_name: Optional[str] = None, muuid: Optional[str] = None, model_name: Optional[str] = None, default_muuid: Optional[str] = None) Optional[dict]

Gets information of a model version in local registry.

A model version is specified in one of the following ways: - model version uuid (vuuid) alone - model (muuid, model_name, or default_muuid) combined with version (version_name)

It returns the first matching model version. To get all matching model versions, call list_model_versions() instead. (It is possible to have multiple matches when a model version is specified by model name and version name.)

Parameters:
  • vuuid – model version uuid

  • version_name – version name

  • muuid – model uuid

  • model_name – model name

  • default_muuid – default model uuid

Returns:

model version info dict, or None when the model version is not found

get_new_local_vuuid() str

Generates a new local vuuid.

NOTE: This method is not thread-safe.

list_model_versions() Dict[str, dict]

Gets information of model versions in local registry.

Returns:

model version dict [vuuid => model version info dict]

set_model_version_info(puuid: str, muuid: str, model_name: str, vuuid: str, version_name: str, packaged: bool, encrypted: bool, download_time: datetime)

Sets model version record in local registry.