Tag a Model using the API¶
Give an alias to a model using the API is the same as doing it manually but using python code. This is usefull if you want to automate the process of tagging models.
In [2]:
Copied!
import mlflow
MODEL_NAME = "" # insert the name of your model (make sure the model is registered)
MODEL_VERSION = 1 # change to the model version you want to tag: 1, 2, 3, etc.
MODEL_STAGE = "" # insert the Alias
# stage model
client = mlflow.MlflowClient()
info = client.transition_model_version_stage(
name=MODEL_NAME,
version=MODEL_VERSION,
stage=MODEL_STAGE
)
# check current stage
print(info.current_stage)
import mlflow
MODEL_NAME = "" # insert the name of your model (make sure the model is registered)
MODEL_VERSION = 1 # change to the model version you want to tag: 1, 2, 3, etc.
MODEL_STAGE = "" # insert the Alias
# stage model
client = mlflow.MlflowClient()
info = client.transition_model_version_stage(
name=MODEL_NAME,
version=MODEL_VERSION,
stage=MODEL_STAGE
)
# check current stage
print(info.current_stage)
Production