Search code examples
mlflowmlops

How can I load the latest model version from MLflow model registry?


I can load a specific version of a model using the mlflow client:

import mlflow

model_version = 1

model = mlflow.pyfunc.load_model(
    model_uri=f"models:/c3760a15e6ac48f88ad7e5af940047d4/{model_version}"
)

But is there a way to load the latest model version?


Solution

  • There is no such thing, like load latest, but:

    • You can specify the stage (staging, production) - see docs
    • You can find latest version using the get_latest_versions function - but it will also return latest per stage

    So you need to define what latest means for you.