mlops.model package

Submodules

mlops.model.training_config module

Contains the TrainingConfig class.

class mlops.model.training_config.TrainingConfig(history: keras.callbacks.History, train_args: Dict[str, Any])

Bases: object

Contains training configuration and results.

history: The model’s training history. train_args: The training arguments.

history: keras.callbacks.History
train_args: Dict[str, Any]

mlops.model.versioned_model module

Contains the VersionedModel class.

class mlops.model.versioned_model.VersionedModel(path: str)

Bases: mlops.artifact.versioned_artifact.VersionedArtifact

Represents a versioned model.

property md5: str

Returns the artifact’s MD5 hash.

Returns

The artifact’s MD5 hash.

property metadata_path: str

Returns the local or remote path to the artifact’s metadata.

Returns

The local or remote path to the artifact’s metadata.

property name: str

Returns the artifact’s name.

Returns

The artifact’s name.

property path: str

Returns the local or remote path to the artifact.

Returns

The local or remote path to the artifact.

property version: str

Returns the artifact’s version.

Returns

The artifact’s version.

mlops.model.versioned_model_builder module

Contains the VersionedModelBuilder class.

class mlops.model.versioned_model_builder.VersionedModelBuilder(versioned_dataset: mlops.dataset.versioned_dataset.VersionedDataset, model: keras.engine.training.Model, training_config: Optional[mlops.model.training_config.TrainingConfig] = None)

Bases: mlops.artifact.versioned_artifact_builder.VersionedArtifactBuilder

An object containing all of the components that form a versioned model.

publish(path: str, *args: Any, name: str = 'model', version: Optional[str] = None, tags: Optional[List[str]] = None, **kwargs: Any) str

Saves the versioned model files to the given path. If the path and appended version already exists, this operation will raise a PublicationPathAlreadyExistsError.

The following files will be created:
path/version/ (the publication path and version)

model.h5 (the saved model) meta.json (metadata)

The contents of meta.json will be:
{

name: (model name) version: (model version) hash: (MD5 hash of all objects apart from meta.json) dataset: (the link to the dataset used during training) history: (the training history dictionary) train_args: (the training arguments dictionary) created_at: (timestamp) tags: (optional list of tags)

}

Parameters
  • path – The path, either on the local filesystem or in a cloud store such as S3, to which the model should be saved. The version will be appended to this path as a subdirectory. An S3 path should be a URL of the form “s3://bucket-name/path/to/dir”. It is recommended to use this same path to publish all models, since it will prevent the user from creating two different models with the same version.

  • name – The name of the model, e.g., “vgg16”.

  • version – A string indicating the model version. The version should be unique to this model. If None, the publication timestamp will be used as the version.

  • tags – An optional list of string tags to add to the model metadata.

Returns

The versioned model’s publication path.

Module contents

Contains model modules.