h1st.model_repository.model_repository module

class h1st.model_repository.model_repository.ModelSerDe[source]

Bases: object

STATS_PATH = 'stats.joblib'
METRICS_PATH = 'metrics.joblib'
METAINFO_FILE = 'METAINFO.yaml'
serialize(model, path)[source]

Serialize a H1ST model’s model property to disk.

Parameters
  • model – H1ST Model

  • path – path to save models to

deserialize(model, path)[source]

Populate a H1ST model’s model property with saved atomic models.

Parameters
  • model – H1ST Model

  • path – path to model folder

class h1st.model_repository.model_repository.ModelRepository(storage=None)[source]

Bases: object

Model repository allows user to persist and load model to different storage system.

Model repository uses ModelSerDer to serialize a model into a temporary folder and then create a tar archive to store on storage. For loading, the repo retrieve the tar archive from the storage and then extract to temporary folder for restoring the model object.

__init__(storage=None)[source]

Initialize self. See help(type(self)) for accurate signature.

persist(model, version=None)[source]

Save a model to the model repository

Parameters
  • model – target model

  • version – version name, leave blank for autogeneration

Returns

model version

load(model, version=None)[source]

Restore the model from the model repository

Parameters
  • model – target model

  • version – version name, leave blank to load the latest version

delete(model, version)[source]

Delete a model from model repository

Parameters
  • model – model instance or the model class

  • version – target version

download(model, version, path)[source]

Download a model archive to local disk

Parameters
  • model – model instance or model class

  • version – version name

  • path – target folder to extract the model archive

classmethod get_model_repo(ref=None)[source]

Retrieve the default model repository for the project

Parameters

ref – target model

Returns

Model repository instance