ezmllib

This documentation describes the HPE Ezmeral ML Ops Notebook Python library:

ezmllib version 0.3

The ezmllib library streamlines your notebook-based coding experience through built-in Python functions. In some cases, these built-in functions are intended as replacements for the equivalent notebook magic functions supplied by Hewlett Packard Enterprise.

Kubeconfig

These modules contain functions to set up kubectl access from the notebook, to add users to an existing Kubeflow user secret, and to get information about the user and secret.

Example:

from ezmllib import kubeconfig

ezkubeconfig

This module contains functions to set up kubectl access from the notebook and to add users to an existing Kubeflow user secret.

Example:

from ezmllib.kubeconfig import ezkubeconfig

set_kubeconfig

This function sets up kubeconfig for current user. The function makes an API call to HPE Ezmeral Runtime Enterprise and gets the latest kubeconfig file.

Syntax:

set_kubeconfig(pwd)

Parameters:

  • pwd : The HPE Ezmeral Runtime Enterprise password of the user.

Returns:

None

Example:

from ezmllib.kubeconfig import ezkubeconfig
ezkubeconfig.set_kubeconfig("password")

set_local_kubeconfig

This function sets up kubeconfig from a user-uploaded kubeconfig file. The file must be present in the following notebook directory: /home/{user}/kubeconfig

Syntax:

set_local_kubeconfig()

Returns:

None

Example:

from ezmllib.kubeconfig import ezkubeconfig
ezkubeconfig.set_local_kubeconfig()

Kubeflow

These modules contain functions to configure a Kubeflow environment in a notebook session, to print Kubeflow job logs in a notebook, and to manage PyTorch and TensorFlow jobs.

Example:

from ezmllib import kubeflow

ezkflog

This module provides an interface for accessing Kubeflow job logs from the notebook session.

Example:

from ezmllib.kubeflow import ezkflog

logs

This function prints out the specified Kubeflow job logs in the notebook.

Syntax:

logs(name, events=False, status=False, **kwargs)

Parameters:

  • name : Kubeflow job name.
  • events: [True,False]: Display Kubernetes job events for the Kubeflow job.
  • status: [True,False]: Display Kubernetes status of the Kubeflow job.
  • **kwargs:
    • follow: [True,False]: Stream the logs.
    • since: [ "10m","30m","1h", ....]: time period to fetch logs from.
    • previous: [True,False]: When True, prints the logs for the previous instance of the container in the pod, if available. For example, you can specify True to get the logs of the container for a job that failed.
from ezmllib.kubeflow.ezkflog import logs
logs("test",events=True, status=True, follow=True, since="1h", previous="False")

ezkfp

This module provides a Kubeflow session client for interfacing with Kubeflow from a notebook.

Example:

from ezmllib.kubeflow import ezkfp

KfSession

Kubeflow session class

Syntax:

KfSession()

Parameters:

The constructor takes the following **kwargs:

  • user: (Optional) HPE Ezmeral Runtime Enterprise user.
  • password: (Optional) HPE Ezmeral Runtime Enterprise password of the user.
  • url: (Optional) URL of the Kubeflow API.
  • certs: Path to CA certificate. Required if using an https enabled system, optional if using http.

If an optional parameter is not provided, it will be set through automation. For example, if the password is not provided, the function prompts the user for the password.

Returns: KfSession object

Example:

from ezmllib.kubeflow.ezkfp import KfSession
K = KfSession()

kf_client

This function creates returns an object for interacting with the Kubeflow Pipeline API. The function checks if the user has a .kubeflow directory that contains the file kf.json. The kf.json file contains the Kubeflow endpoint, the Kubeflow session, and certs location. If the user's .kubeflow directory exists, the function reads the session cookies from that directory, and returns the client object. If not, the function creates the directory and file, creates and stores session cookies and the Kubeflow endpoint in the file, and then returns the client object. Syntax:

kf_client(recreate=False)

Parameters:

  • recreate: [True,False]: When True, the function overwrites the user's existing .kubeflow directory with the directory the function creates. Default value: False

Returns:

Returns a kfp.Client object for interacting with the Kubeflow Pipeline API

Example:

from ezmllib.kubeflow.ezkfp import KfSession
K = KfSession()
client = K.kf_client()

MLflow

These modules contain functions related to using MLflow for model management. Functions in this module import and set environment variables, create a secret populated with S3 credentials, create model endpoints, register models, and register experiments.

ezmlflow

This module contains the MLflow automation functions.

Example:

from ezmllib.mlflow import ezmlflow

load_mlflow

This function imports and sets environment variables for MLflow. The function then creates a secret that is populated with the s3 credentials and endpoint for use by Prism. Execute this function prior to using MLflow in a KD Notebook. The mlflow secret must be attached to the notebook application to load successfully.

Syntax:

load_mlflow()

Returns: None

Example:

from ezmllib.mlflow import load_mlflow
load_mlflow()

register_model

This function registers a model for deployment and creates a Kubernetes ConfigMap with the details. The function requires the model artifact path and the name to be registered.

Syntax:

register_model(modelname, modelpath, description_url="")

Parameters:

  • modelname: Name of model to be registered.
  • modelpath: Path to model artifact.
  • description_url: (Optional) String containing a description of the model.

Returns:

None

Example:

from ezmllib.mlflow import register_model
register_model("test-model","s3://mlflow/example/path/to/artifacts/model","Example model")

set_exp

This function registers the specified experiment in the MLflow tracking service.

Syntax:

set_exp(exp_name)

Parameters:

  • exp_name: Name of the experiment to be registered.

Returns:

None

Example:

from ezmllib.mlflow import set_exp
set_exp("demo experiment")

logs

This function prints out MLflow job logs in the notebook.

Syntax:

logs(job_id, training_engine_name)

Parameters:

  • job_id: ID of MLflow job.
  • training_engine_name: Training engine cluster name.

Returns:

Logs from the specified MLflow job

Example:

from ezmllib.mlflow import logs
logs("<ID>", "training-engine-instance")

Model

These modules automate the management of model prediction, registry, and deployment.

Example:

from ezmllib import model

ezkdmodel

This module contains functions related to HPE Ezmeral ML Ops model management, including registering and deploying models and making predictions. The model registry and deployment functions provide an alternative to doing these tasks through the HPE Ezmeral Runtime Enterprise GUI.

Example:

from ezmllib.model import ezkdmodel

predict

This function makes model predictions and returns a string of data.

Syntax:

predict(modelName, modelVersion, data, deployment_service)

Parameters:

  • deployment_service: Name of model deployment service, created under the "Model Serving" tab.
  • modelName: Name of the model.
  • modelVersion: Model version number in integer format.
  • data: Inference data in dictionary format.

Returns:

A response object that contains the model prediction results

Example:

from ezmllib.model import predict
predict("ml-inferencing", "test-model", 1, inference-data-dict)

register

This function registers the model components. A model must be registered before it can be served.

Syntax:

register(model_registry_name, model_path, scoring_path, model_version, model_description="")

Parameters:

  • model_registry_name: the model registry name created to register the model_path, scoring_path, and model_version.
  • model_path: The model URI. For example: repo://your/model/path
  • scoring_path: The model prediction/scoring script URI. For example: repo://your/scoring/path
  • model_version: The version of the model to serve, in integer format.
  • model_description (kwarg): Description of the model for display in model registry.

Returns:

None

Example:

from ezmllib.model import register
register("test-model","repo://your/model/path"," repo://your/scoring/path",1,model_description="Example model")

deploy

This function deploys a model and provides options for controlling resources allocated to the model.

Syntax:

deploy(deployment_service,cm_array,sc_array=[],
       dtapenabled="false",
       lb_cpu=LB_CPU,
       lb_memory=LB_MEMORY,
       lb_gpu=LB_GPU,
       lb_cpu_lmt=LB_CPU_LMT,
       lb_memory_lmt=LB_MEMORY_LMT,
       lb_gpu_lmt=LB_GPU_LMT,
       rs_cpu=RS_CPU,
       rs_memory=RS_MEMORY,
       rs_gpu=RS_GPU,
       rs_cpu_lmt=RS_CPU_LMT,
       rs_memory_lmt=RS_MEMORY_LMT,
       rs_gpu_lmt=RS_GPU_LMT,
       description=""`)

Parameters:

  • deployment_service: Name of deployment service or inference cluster to deploy the model with. Enclose the name in quotes.
  • cm_array: An array containing the list of ConfigMap names to attach to model inference app.
    • Default value: []
  • sc_array (kwarg): List of secret names to attach to model inference app.
    • Default value: []
  • dtapenabled: ["true","false"]: When "true", enables DataTap connection for the model inference app.
    • Default value: "false"
  • lb_cpu (Optional): Requested CPU for the inference load balancer. Enclose the value in quotes.
    • Default value: "2"
  • lb_memory (Optional): Requested Memory for the inference load balancer. Enclose the value in quotes.
    • Default value: "4Gi"
  • lb_gpu (Optional): Requested GPU for the inference load balancer. Enclose the value in quotes.
    • Default value: "0"
  • lb_cpu_lmt (Optional): Requested CPU limit for the inference load balancer. Enclose the value in quotes.
    • Default value: "2"
  • lb_memory_lmt (Optional): Requested Memory limit for the inference load balancer. Enclose the value in quotes.
    • Default value: "4Gi"
  • lb_gpu_lmt (Optional): Requested GPU limit for the inference load balancer. Enclose the value in quotes.
    • Default value: "0"
  • rs_cpu (Optional): Requested CPU for the inference REST Server. Enclose the value in quotes.
    • Default value: "2"
  • rs_memory (Optional): Requested Memory for the inference REST Server. Enclose the value in quotes.
    • Default value: "4Gi"
  • rs_gpu (Optional): Requested GPU for the inference REST Server. Enclose the value in quotes.
    • Default value: "0"
  • rs_cpu_lmt (Optional): Requested CPU limit for the inference REST Server. Enclose the value in quotes.
    • Default value: "2"
  • rs_memory_lmt (Optional): Requested Memory limit for the inference REST Server. Enclose the value in quotes.
    • Default value: "4Gi"
  • rs_gpu_lmt (Optional): Requested GPU limit for the inference REST Server. Enclose the value in quotes.
    • Default value: "0"
  • description (kwarg): Description of deployed model, enclosed in quotes. For example: description="test deployment"

Returns: None

Example:

from ezmllib.model import deploy
cm_array=[]
deploy("ml-inferencing",cm_array,description="test deployment")

register_and_deploy

This function registers then deploys a model in a KubeDirector inference application, and provides options for limiting resource consumption.

Syntax:

register_and_deploy(model_registry_name, model_path, scoring_path, 
                    model_version,
                    deployment_service,
                    cm_array,
                    sc_array=[],
                    dtapenabled="false",
                    lb_cpu=LB_CPU,
                    lb_memory=LB_MEMORY,
                    lb_gpu=LB_GPU,
                    lb_cpu_lmt=LB_CPU_LMT,
                    lb_memory_lmt=LB_MEMORY_LMT,
                    lb_gpu_lmt=LB_GPU_LMT,
                    rs_cpu=RS_CPU,
                    rs_memory=RS_MEMORY,
                    rs_gpu=RS_GPU,
                    rs_cpu_lmt=RS_CPU_LMT,
                    rs_memory_lmt=RS_MEMORY_LMT,
                    rs_gpu_lmt=RS_GPU_LMT,
                    description="",
                    model_description="")

Parameters:

  • model_registry_name: The model registry name created to register the model_path, scoring_path, and model_version. Enclose the name in quotes.
  • model_path: The model URI, enclosed in quotes. For example: "repo://your/model/path"
  • scoring_path: The model prediction/scoring script URI, enclosed in quotes. For example: "repo://your/scoring/path"
  • model_version: The version of the model to serve, in integer format.
  • deployment_service: Name of deployment service or inference cluster to deploy the model with. Enclose the name in quotes.
  • cm_array: An array containing the list of ConfigMap names to attach to model inference app.
    • Default value: []
  • sc_array (kwarg): List of secret names to attach to model inference app.
    • Default value: []
  • dtapenabled: ["true","false"]: When "true", enables DataTap connection for the model inference app.
    • Default value: "false"
  • lb_cpu (Optional): Requested CPU for the inference load balancer. Enclose the value in quotes.
    • Default value: "2"
  • lb_memory (Optional): Requested Memory for the inference load balancer. Enclose the value in quotes.
    • Default value: "4Gi"
  • lb_gpu (Optional): Requested GPU for the inference load balancer. Enclose the value in quotes.
    • Default value: "0"
  • lb_cpu_lmt (Optional): Requested CPU limit for the inference load balancer. Enclose the value in quotes.
    • Default value: "2"
  • lb_memory_lmt (Optional): Requested Memory limit for the inference load balancer. Enclose the value in quotes.
    • Default value: "4Gi"
  • lb_gpu_lmt (Optional): Requested GPU limit for the inference load balancer. Enclose the value in quotes.
    • Default value: "0"
  • rs_cpu (Optional): Requested CPU for the inference REST Server. Enclose the value in quotes.
    • Default value: "2"
  • rs_memory (Optional): Requested Memory for the inference REST Server. Enclose the value in quotes.
    • Default value: "4Gi"
  • rs_gpu (Optional): Requested GPU for the inference REST Server. Enclose the value in quotes.
    • Default value: "0"
  • rs_cpu_lmt (Optional): Requested CPU limit for the inference REST Server. Enclose the value in quotes.
    • Default value: "2"
  • rs_memory_lmt (Optional): Requested Memory limit for the inference REST Server. Enclose the value in quotes.
    • Default value: "4Gi"
  • rs_gpu_lmt (Optional): Requested GPU limit for the inference REST Server. Enclose the value in quotes.
    • Default value: "0"
  • description (kwarg): Description of deployed model, enclosed in quotes. For example: description="test deployment"
  • model_description (kwarg): Description for the model for display in model registry, enclosed in quotes. For example: `model_description="Example model"'

Returns: None

Example:

from ezmllib.model import register_and_deploy
cm_array = []
register_and_deploy("test-model","repo://your/model/path",
                    "repo://your/scoring/path",1, 
                    "ml-inferencing",cm_array,description="test deployment", 
                    model_description="Example model")

get_inference_app_details

This function gets inference app details of the specified the inference app.

Syntax:

get_inference_app_details(kd_inference_app_name)

Parameters:

  • kd_inference_app_name: Name of the model inference service (name of app created by "Model Serving" tab).

Returns: Dictionary containing "Inference App State", "Message", and "Service URL" as keys with relevant details.

Example:

from ezmllib.model import get_inference_app_details 
get_inference_app_details("test-inference-app")

update_registry

This function updates the existing model registry.

Syntax:

update_registry(context, modelname, modelpath=None, scoringpath=None)

Parameters:

  • context: Name of current context as listed in kubeconfig. Enclose the name in quotes.
  • modelname: Registered name of model. Enclose the value in quotes.
  • modelpath: (Optional) URI for model artifacts. Enclose the value in quotes.
  • scoringpath: (Optional) URI for model prediction or scoring script. Enclose the value in quotes.

Returns: None; Prints message indicating success or failure to update

Example:

from ezmllib.model import update_registry
update_registry("ECP-TEST-compute-mlops-dev1", "test-model")

Spark

These modules contain functions to manage Spark jobs.

ezspark

This module contains functions to manage Spark jobs.

Example:

from ezmllib.spark import ezspark

submit

This function submits Spark jobs with inputs, or with a provided yaml file.

Syntax:

submit(
    app_path=None,
    data_path=None,
    yaml_path=None,
    name=None,
    image_name='gcr.io/mapr-252711/spark-py-3.1.2:202111021109R',
    driver_cores=1,
    driver_memory='512m',
    driver_core_limit='1000m',
    executor_cores=1,
    executor_instances=2,
    executor_memory='512m',
    executor_core_limit='1000m',
    spark_version='3.1.2',
    python_version='3',
    app_type='Python',
    api_version='sparkoperator.hpe.com/v1beta2',
    kind='SparkApplication',
    namespace=None,
)

Parameters:

  • app_path: (Optional) Path to application file for the Spark job. Enclose the path in quotes. For example: app_path="local:///opt/mapr/spark/spark-2.4.7/examples/src/main/python/wordcount.py" - Default value: None.
  • data_path: (Optional) Path to data file for the Spark job. Enclose the path in quotes. For example: data_path="dtap://TenantStorage/data/wordcount.txt" - Default value: None.
  • yaml_path: (Optional) Path to yaml file for the Spark job. Enclose the path in quotes. - Default value: None.
  • name: (Optional) Name of the Spark job. Enclose the name in quotes. For example: name="mysparkjob1" - Default value: None.
  • image_name: Spark image name.
    • Default value: 'gcr.io/mapr-252711/spark-py-3.1.2:202111021109R'
  • driver_cores: Number of CPU cores to allocate to the Spark driver.
    • Default value: 1
  • driver_memory: Allocated memory for the Spark driver. - Default value: '512m'
  • driver_core_limit: Maximum allowed CPU cores for Spark driver.
    • Default value: '1000m'
  • executor_cores: Allocated CPU cores for Spark executor.
    • Default value: 1
  • executor_instances: Number of Spark executor instances.
    • Default value: 2
  • executor_memory: Memory request for the Spark executor.
    • Default value: '512m'
  • executor_core_limit: Maximum CPU cores allotted to the Spark executor.
    • Default value: '1000m'
  • spark_version: Version of Spark to use in the Spark job.
    • Default value: '3.1.2'
  • python_version: Version of Python to use in the Spark job.
    • Default value: '3'
  • app_type: Spark application type.
    • Default value: 'Python'
  • api_version: Spark API version to be used.
    • Default value: 'sparkoperator.hpe.com/v1beta2'
  • kind
    • Default value: 'SparkApplication'
  • namespace: (Optional) Namespace in which to execute the job.
    • Default value: None. If None, deploys to the notebook namespace.

Returns: None; Prints output of job configuration and status of its creation

Example:

from ezmllib.spark import submit
submit(app_path="local:///opt/mapr/spark/spark-3.1.2/examples/src/main/python/wordcount.py",
       data_path="dtap://TenantStorage/data/wordcount.txt",
       name="test1"
      )

delete

This function deletes the Spark job specified by job name. If no name is provided, lists all Spark jobs and prompts user to list the Spark job names to be deleted, in space-delimited format. For example: name1 name2 name3

Syntax:

delete(name)

Parameters:

  • name: String containing the job name.

Returns: None; Prints message indicating deletion status of the job

Example:

from ezmllib.spark import delete
delete("test1")

logs

This function displays log messages from the specified Spark job.

Syntax:

logs(name, events=False, **kwargs)

Parameters:

  • name: Spark job name.
  • events: [True,False]: When True, includes Kubernetes event logs.
  • **kwargs:
    • follow: [True,False]: When True, streams the logs
    • since ["10m", "30m", "1hr", ...etc.]: Timeframe from which to fetch logs.
    • tail: ["10","100", ...etc.]: Provides the last N log messages.
    • previous: [True,False]: When True, prints the logs for the previous instance of the container in the pod, if available. For example, you can specify True to get the logs of the container for a job that failed.

Returns: None; Prints spark job logs as notebook cell output

Example:

from ezmllib.spark import logs
logs("test1")

Storage

These modules contain a utility for generating secrets and modules for uploading and downloading objects from the Amazon S3 object storage service.

Example:

from ezmllib import storage

ezs3

This module provides a client interface for easily moving files between a notebook session and s3 storage.

Example:

from ezmllib.storage import ezs3

s3_util

This is a class that provides s3 upload and download functions. This class automatically reads s3 storage credentials from the secret in Kubernetes environment. Users can provide these credentials manually through optional parameters in functions that accept **kwargs.

Syntax:

s3_util(src, dest)

Parameters:

  • src: Source path. Specifies where file is located.
  • dest: Destination path. Specifies where file is to be uploaded to or downloaded to.

Returns: s3_util object

Example:

from ezmllib.storage.ezs3 import s3_util
u = s3_util(local_path, aws_s3_path)

upload

This function uploads file to self.dest of the s3_util client.

Syntax:

upload()

Parameters:

To use different credentials than the credentials stored in the s3_secret, specify the following optional parameters to be passed as **kwargs:

  • aws_access_key_id: (Optional) Remote storage username credential.
  • aws_secret_access_key: (Optional) Remote storage password credential.

Returns: None

Example:

from ezmllib.storage.ezs3 import s3_util
u = s3_util(local_path, aws_s3_path)
u.upload()

download

This function downloads a file to: self.**dest**

Syntax:

download()

Parameters: To use different credentials than the credentials stored in the s3_secret, specify the following optional parameters to be passed as **kwargs:

  • aws_access_key_id: (Optional) Remote storage username credential.
  • aws_secret_access_key: (Optional) Remote storage password credential.

Returns: None

Example:

from ezmllib.storage.ezs3 import s3_util
u = s3_util(aws_s3_path, local_path)
u.download()

create_s3_secret

Given the provided credentials, this function creates a secret in the user's namespace to store the remote storage access key and ID. The s3_util reads the security parameters from the secret to facilitate the file transfer.

Syntax:

create_s3_secret(s3_id, s3_key)

Parameters:

  • s3_id: Username for the remote storage.
  • s3_key: Password for the remote storage.

Returns: None

Example:

from ezmllib.storage.ezs3 import create_s3_secret
AWS_S3_ACCESS_KEY_ID = "user"
AWS_S3_SECRET_ACCESS_KEY = "pass"
create_s3_secret(AWS_S3_ACCESS_KEY_ID,AWS_S3_SECRET_ACCESS_KEY)

TensorFlow

These modules contain functions to configure a TensorFlow environment in a notebook session.

Example:

from ezmllib import tensorflow

eztensorflow

This module provides a convenient interface for TensorFlow in a notebook environment.

Example:

from ezmllib.tensorflow import eztensorflow

config

This function configures the TensorFlow environment for this notebook session. The function configures TensorFlow to use GPU hardware, if available, and to specify whether to use TensorFlow version 2.

Syntax:

config(tf, v2=False)

Parameters:

  • tf: TensorFlow library object.
  • v2: [True,False]: Specifies whether to use TensorFlow version 2. Default value: False

Returns: A TensorFlow library object for use in the notebook

Example:

import tensorflow as tf
import ezmllib
tf = ezmllib.tensorflow.config(tf, v2=True) 

modelmgmt

These modules interface with the model management service from within a notebook instance

Example:

from ezmllib import modelmgmt

ezmodelmgmt

Ezmodelmgmt provides an client for easily managing model experiments, runs, and their artifacts.

Example:

from ezmllib.modelmgmt import ezmodelmgmt

Ezmodelmgmt

This is a class that provides model management functions for experiments, runs, and artifacts. This class automatically reads s3 storage credentials and model management details from the model management secret in Kubernetes environment. This secret is required for Ezmodelmgmt to function.

Syntax:

Ezmodelmgmt(exp_name=None, artifact_location= None, backend_url=None)

Parameters:

  • exp_name: Name of the experiment the client will manage. Client will notify if name is already used
  • artifact_location: (Optional) Path to store all artifacts to for experiment. Default used if not provided
  • backend_url: (Optional) URL of model management backend service for client to connect to

Returns: Ezmodelmgmt object

Example:

from ezmllib.modelmgmt.ezmodelmgmt import Ezmodelmgmt
#Set experiment name here
#experiment_name=''
client = Ezmodelmgmt(experiment_name)

create_experiment

This function updates the client to use a new experiment created by the model management APIs

Syntax:

create_experiment(name, artifact_location=None, **tags)

Parameters:

  • name: String containing name of experiment to be created
  • artifact_location: (Optional) Path to store all artifacts to for experiment. Default used if not provided
  • tags: (Optional) Dictionary of key-value pairs to tag the experiment with

Returns: Experiment ID; Prints API response

Example:

from ezmllib.modelmgmt.ezmodelmgmt import Ezmodelmgmt
client = Ezmodelmgmt(experiment_name_1)
exp_id = client.create_experiment(experiment_name_2)

start_run

Starts/creates mlflow run for the experiment set in the client object

Syntax:

start_run(tags)

Parameters:

  • tags: (Optional) Dictionary of key-value pairs to tag the run with

Returns: Run ID; Prints API response

Example:

from ezmllib.modelmgmt.ezmodelmgmt import Ezmodelmgmt
client = Ezmodelmgmt(experiment_name)
run_id = client.start_run()

log_param

Log a parameter for a run

Syntax:

log_param(key, value, run_id = None)

Parameters:

  • key: String with key name for parameter
  • value: Float with parameter value
  • run_id: (Optional) String indicating which run to log the parameter to. Uses existing run if not provided, or creates one.

Returns: None; Prints API response

Example:

from ezmllib.modelmgmt.ezmodelmgmt import Ezmodelmgmt
client = Ezmodelmgmt(experiment_name)
client.log_param("learning_rate",0.5)

log_metric

Log a metric for a run

Syntax:

log_metric(key, value, run_id = None)

Parameters:

  • key: String with the key name for the metric
  • value: Float with value of metric
  • run_id: (Optional) String indicating which run to log the metric to. Uses existing run if not provided, or creates one.

Returns: None; Prints API response

Example:

from ezmllib.modelmgmt.ezmodelmgmt import Ezmodelmgmt
client = Ezmodelmgmt(experiment_name)
client.log_metric("root_mean_squared_error", 0.85)

log_run_tag

Log a tag for a run

Syntax:

log_run_tag(key, value, run_id = None)

Parameters:

  • key: String with the key name for tag
  • value: String with value of tag
  • run_id: (Optional) String indicating which run to log the tag to. Uses existing run if not provided, or creates one.

Returns: None; Prints API response

Example:

from ezmllib.modelmgmt.ezmodelmgmt import Ezmodelmgmt
client = Ezmodelmgmt(experiment_name)
client.log_run_tag("key", "value")

get_run

Get run details by run_id

Syntax:

get_run(run_id = None)

Parameters:

  • run_id: (Optional) String specifying run by run_id. Uses existing run if not provided, or creates one.

Returns: API Response Object

Example:

from ezmllib.modelmgmt.ezmodelmgmt import Ezmodelmgmt
client = Ezmodelmgmt(experiment_name)
client.get_run()#gets current run details
client.get_run("e8fda241508f4658a88762a3c37f311c") # gets details of specified run if user has access 

get_runs

Get all run details for a set of experiments by their experiment ID

Syntax:

get_run(exp_ids=[])

Parameters:

  • exp_ids: (Optional) List of Strings specifying experiment by exp_id. Uses client experiment ID if not provided.

Returns: API Response Object

Example:

from ezmllib.modelmgmt.ezmodelmgmt import Ezmodelmgmt
client = Ezmodelmgmt(experiment_name)
client.get_runs()#gets current experiment details
client.get_runs(["1","2","3"]) # gets details of specified experiments if user has access 

delete_run

Soft delete of experiment run by run id

Syntax:

delete_run(run_id = None)

Parameters:

  • run_id: (Optional) String specifying run by run_id. Uses current active run if not provided

Returns: API Response Object

Example:

from ezmllib.modelmgmt.ezmodelmgmt import Ezmodelmgmt
client = Ezmodelmgmt(experiment_name)
client.delete_run("e8fda241508f4658a88762a3c37f311c") #delete specific run
client.delete_run() # delete active run 

restore_run

Restore a deleted experiment run by run id

Syntax:

delete_run(run_id = None)

Parameters:

  • run_id: (Optional) String specifying run by run_id. Uses most recent cached run if not provided

Returns: API Response Object

Example:

from ezmllib.modelmgmt.ezmodelmgmt import Ezmodelmgmt
client = Ezmodelmgmt(experiment_name)
client.restore_run("e8fda241508f4658a88762a3c37f311c") #restore specific run
client.restore_run() # restore active run 

list_experiment

List all experiments of the notebook user

Syntax:

list_experiment()

Parameters:

  • N/A

Returns: API Response Object

Example:

from ezmllib.modelmgmt.ezmodelmgmt import Ezmodelmgmt
client = Ezmodelmgmt(experiment_name)
client.list_experiment()

get_experiment

Get experiment details for a specific experiment by ID

Syntax:

get_experiment(exp_id = None)

Parameters:

  • exp_id: (Optional) String specifying experiment by exp_id. Uses client's experiment if not specified

Returns: API Response Object

Example:

from ezmllib.modelmgmt.ezmodelmgmt import Ezmodelmgmt
client = Ezmodelmgmt(experiment_name)
client.get_experiment() # gets the experiment defined by "experiment_name"
client.get_experiment("42") # gets the experiment with exp ID 42

set_exp_tag

Tag an experiment with a key-value pair

Syntax:

log_run_tag(key, value, exp_id = None)

Parameters:

  • key: String with the key name for tag
  • value: String with value of tag
  • exp_id: (Optional) String specifying experiment by exp_id. Uses client's experiment if not specified

Returns: None; Prints API response

Example:

from ezmllib.modelmgmt.ezmodelmgmt import Ezmodelmgmt
client = Ezmodelmgmt(experiment_name)
client.set_exp_tag("key", "value")

log_artifacts

Log a directory of files for a specific run

Syntax:

log_artifact(folder_location, run_id=None ):

Parameters:

  • folder_location: String with full path of folder to be logged, e.g. /home/<user>/test_results
  • run_id: (Optional) String specifying run by run_id. Uses most recent cached run if not provided

Returns: None; Prints message on failure

Example:

from ezmllib.modelmgmt.ezmodelmgmt import Ezmodelmgmt
client = Ezmodelmgmt(experiment_name)
client.log_artifacts("/home/user1/test_results")

log_artifact

Log a file for a specific run

Syntax:

log_artifact(file_location, run_id=None ):

Parameters:

  • file location: String with full path of file to be logged, e.g. /home/<user>/data.csv
  • run_id: (Optional) String specifying run by run_id. Uses most recent cached run if not provided

Returns: None; Prints message on failure

Example:

from ezmllib.modelmgmt.ezmodelmgmt import Ezmodelmgmt
client = Ezmodelmgmt(experiment_name)
client.log_artifact("/home/user1/data/data.csv")

log_model

Log a model object and its specification to a specific run

Syntax:

log_model(model=None,flavor=None,run_id=None,registered_model_name=None):

Parameters:

  • model: Model object to be logged

  • flavor: (Optional) Framework used to create model. If not provided, will dynamically detect

    • Supported flavors:

      • sklearn
      • keras
      • xgboost
      • pytorch
      • h2o
      • spark
      • tensorflow

      Note: Custom models defined with TF or PyTorch primitives must specify flavor. Client will prompt user to if it is not provided as an argument. Ex: client.log_model(model=custom_model, flavor='pytorch'...)

  • run_id: (Optional) String specifying run by run_id. Uses most recent cached run if not provided

  • registered_model_name: (Optional) Name to register the model with

Returns: None; Prints message on failure

Example:

from ezmllib.modelmgmt.ezmodelmgmt import Ezmodelmgmt
client = Ezmodelmgmt(experiment_name)
client.log_artifact("/home/user1/data/data.csv")