Overview

A model can have one or more versions, each version:

  • Can lock a specific run to track lineage.
  • Can be deployed as an internal app.
  • Can be deployed in production.

CLI Reference

You can check the complete models CLI reference here or by using polyaxon models --help.

Client Reference

Polyaxon’s ProjectClient library exposes all methods to:

Since v1.18, Polyaxon’s RunClient library exposes a method to automatically promote the run to a model version:

Model version creation

You can create your model versions using the CLI, API, or the UI.

CLI

polyaxon models register -p OWNER_NAME/MODEL_NAME --version VERSION_NAME --description ... --tags tag1,tag2,... --artifacts model-name,env,asset-version

Client

from polyaxon.client import ProjectClient

project_client = ProjectClient(project="ORGANIZATION/bot-detection")

version = project_client.register_model_version(
    version="v1",
    description="description for this version...",
    tags=["prod"],
    content={"key": "val", "env": ["package1", "package2"]},
    run="f27c0580dcdf4ed7b2f36726c5257ade",
    artifacts=["model", "env"],
)

Note: You can use force=True to override a previous version registered with the same name.

UI

version-create

Model version creation from a run

When a user create a run that tracks a model, users can promote a model version directly from a run:

version-promote

Once a model version is registered, the run will be marked as promoted:

version-promoted

Model version overview and definition

CLI

polyaxon models get -ver VERSION_NAME

Client

from polyaxon.client import ProjectClient

project_client = ProjectClient(project="ORGANIZATION/bot-detection")

version = project_client.get_model_version(version="v1")
print(version)

UI

version-overview

Model version stage changes

You can update the stage of the model version to reflect the production-readiness

CLI

polyaxon models stage -ver VERSION_NAME -to staging --reason ModelTestGithubAction --message "Tests passed and the model was automatically moved to staging" ...

Client

from polyaxon.client import V1Stages
from polyaxon.client import ProjectClient

project_client = ProjectClient(project="ORGANIZATION/bot-detection")

project_client.stage_model_version(
    version="v1",
    stage=V1Stages.STAGING,
    reason="AirflowPipelineStageUpdate",
    message="Tests passed and the model was automatically moved to staging",
)

UI

version-stage

Model version admin

CLI

You can override a model version with push:

polyaxon models register -ver ... --force

Or update specific info:

polyaxon models update -ver ...

and delete

polyaxon models delete -ver ...

Client

from polyaxon.client import ProjectClient

project_client = ProjectClient(project="ORGANIZATION/bot-detection")

# Update
project_client.patch_model_version(
    version="v1",
    data={"description": "new description", "tags": ["new-tag1", "new-tag2"]}
)

# Delete
project_client.delete_model_version(version="v1")

UI

You can manage a model version using the UI

version-admin

Model version packaging and pulling

CLI

polyaxon models pull -ver VERSION_NAME --help

Client

from polyaxon.client import ProjectClient

project_client = ProjectClient(project="ORGANIZATION/bot-detection")

project_client.pull_model_version(
    version="v1",
    path="/tmp/path"
)

Model version promotion from a run tracking

Client

from polyaxon import tracking

tracking.init()

# Model lineage reference
model_ref = "model"

# Logging the model as pickle
with tempfile.TemporaryDirectory() as d:
    model_path = os.path.join(d, "model.pkl")
    with open(model_path, "wb") as out:
        pickle.dump(gbc, out)
    tracking.log_model(model_path, name=model_ref, framework="scikit-learn")

# Promoting the run to a model version
if some_condition:
    tracking.promote_to_model_version(
        version="rc2",
        description="model promoted directly from the run",
        tags=["tag1", "tag2"],
        content={"key": "value"},
        artifacts=[model_ref]
    )

# End
tracking.end()