This project has retired. For details please refer to its Attic page.
Model Client | Apache Submarine
Skip to main content
Version: 0.6.0

Model Client

class ModelClient()​

The submarine ModelsClient provides a high-level API for logging metrics / parameters and managing models.

ModelsClient(tracking_uri=None, registry_uri=None)->ModelsClient​

Initialize a ModelsClient instance.

Parameters

  • tracking_uri: If run in Submarine, you do not need to specify it. Otherwise, specify the external tracking_uri.
  • registry_uri: If run in Submarine, you do not need to specify it. Otherwise, specify the external registry_uri.

Returns

  • ModelsClient instance

Example

from submarine import ModelsClient

modelClient = ModelsClient(tracking_uri="0.0.0.0:4000", registry_uri="0.0.0.0:5000")

ModelsClient.start()->[Active Run]​

For details of Active Run

Start a new Mlflow run, and direct the logging of the artifacts and metadata to the Run named "worker_i" under Experiment "job_id". If in distributed training, worker and job id would be parsed from environment variable. If in local traning, worker and job id will be generated.

Returns

  • Active Run

ModelsClient.log_param(key, value)->None​

Log parameter under the current run.

Parameters

  • key – Parameter name
  • value – Parameter value

Example

from submarine import ModelsClient

modelClient = ModelsClient()
with modelClient.start() as run:
modelClient.log_param("learning_rate", 0.01)

ModelsClient.log_params(params)->None​

Log a batch of params for the current run.

Parameters

  • params – Dictionary of param_name: String -> value

Example

from submarine import ModelsClient

params = {"learning_rate": 0.01, "n_estimators": 10}

modelClient = ModelsClient()
with modelClient.start() as run:
modelClient.log_params(params)

ModelsClient.log_metric(self, key, value, step=None)->None​

Log a metric under the current run.

Parameters

  • key – Metric name (string).
  • value – Metric value (float).
  • step – Metric step (int). Defaults to zero if unspecified.

Example

from submarine import ModelsClient

modelClient = ModelsClient()
with modelClient.start() as run:
modelClient.log_metric("mse", 2500.00)

ModelsClient.log_metrics(self, metrics, step=None)->None​

Log multiple metrics for the current run.

Parameters

  • metrics – Dictionary of metric_name: String -> value: Float.
  • step – A single integer step at which to log the specified Metrics. If unspecified, each metric is logged at step zero.

Example

from submarine import ModelsClient

metrics = {"mse": 2500.00, "rmse": 50.00}

modelClient = ModelsClient()
with modelClient.start() as run:
modelClient.log_metrics(metrics)

(Beta) ModelsClient.save_model(self, model_type, model, artifact_path, registered_model_name=None)​

Save model to model registry.

(Beta) ModelsClient.load_model(self, name, version)->mlflow.pyfunc.PyFuncModel​

Load a model from model registry.

(Beta) ModelsClient.update_model(self, name, new_name)->None​

Update a model by new name.

(Beta) ModelsClient.delete_model(self, name, version)->None​

Delete a model in model registry.