cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Machine Learning
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Promote registered UC models using CLI

victorNilsson
New Contributor

Hi,

I am currently transitioning some of our MLops workflows to use models registered in Unity Catalog (UC) instead of the "normal" model registry. I am trying to follow the instructions on https://docs.gcp.databricks.com/en/machine-learning/manage-model-lifecycle/index.html, and I try to replicate the "Promote models across environments (deploy model)" steps.

To promote our models we have been using the mlflow/model-versions/transition-stage REST API endpoint to move models between stages. A similar approach could be done by using model aliases in UC for which there are API endpoints for. Though the recommendations seems to be to promote models by moving them between environment catalogs instead, e.g. move from "test_env.models.test_model" to "prod_env.models.test_model", but I am unable to find a suitable API call for it. 

It is possible to run python code inside a cluster to do this, e.g. using

import mlflow

mlflow.set_registry_uri("databricks-uc")

environment_from = "test_env.models.test_model"
environment_to = "prod_env.models.test_model"
alias = "production"

client = mlflow.tracking.MlflowClient()
copied_model_version = client.copy_model_version(
    src_model_uri = f"models:/{environment_from}@{alias}",
    dst_name = environment_to,
)
client.set_registered_model_alias(
    name=environment_to,
    alias=alias,
    version=copied_model_version.version
)

but I want to handle this transition from outside databricks.

Is there anyway that I can that I can replicate this processs using mlflow cli/databricks cli calls?

Br,
Victor

0 REPLIES 0
Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.