Skip to main content

How to Register a Model with mlflow.register_model

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

Logging a model saves it in a run; registering it gives it a name and a version number in the MLflow Model Registry, so other code can load "version 2 of iris-classifier" instead of a run ID. mlflow.register_model does that for a model you've already logged. This guide registers a model twice and reads what MLflow 3.18.0 prints each time.

Syntax​

Syntax
version = mlflow.register_model(model_uri, name, tags={"key": "value"})
PartWhat it means
model_uriThe logged model, such as info.model_uri from log_model, which looks like models:/m-...
nameThe registered model's name; MLflow creates it the first time
tagsOptional tags for the new version, such as {"validation_status": "pending"}
versionA ModelVersion: its name, its version number and its source

The reference for mlflow.register_model: "Create a new model version in model registry for the model files specified by model_uri." On name: "If a registered model with the given name does not exist, it will be created automatically." A models:/<model_id> address registers "a logged model (for example, one returned by log_model)".

Prerequisites​

  • An MLflow tracking server with a database backend at http://127.0.0.1:8080, such as mlflow server --port 8080 with its default SQLite database. The registry needs one.
  • mlflow and scikit-learn in your project, for example with uv add mlflow scikit-learn pandas.

Step 1: Log and Register a Model​

The example trains a logistic regression on scikit-learn's iris flowers, with the species names as labels, logs it, and registers it as iris-classifier:

The register_model.py script in a macOS-style code window: the iris data with species names as labels, a LogisticRegression logged in a run, then mlflow.register_model with the logged model's URI and the name iris-classifier, printing the version and its source.

register_model.py
import mlflow
from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression

mlflow.set_tracking_uri("http://127.0.0.1:8080")
mlflow.set_experiment("register-model-example")

iris = load_iris(as_frame=True)
X, y = iris.data, iris.target_names[iris.target] # species names, such as setosa
model = LogisticRegression(max_iter=1000).fit(X, y)

with mlflow.start_run():
info = mlflow.sklearn.log_model(model, name="model", input_example=X.head(3))

version = mlflow.register_model(info.model_uri, "iris-classifier")
print(f"Registered {version.name}, version {version.version}, from {version.source}")
Terminal
uv run python register_model.py
Output (last lines)
Successfully registered model 'iris-classifier'.
2026/11/25 09:43:26 INFO mlflow.store.model_registry.abstract_store: Waiting up to 300 seconds for model version to finish creation. Model name: iris-classifier, version 1
Created version '1' of model 'iris-classifier'.
Registered iris-classifier, version 1, from models:/m-25c3a789faf847ea975b066eff58b048

The end of the output in a terminal: Successfully registered model iris-classifier, MLflow waiting up to 300 seconds for version 1, Created version 1 of model iris-classifier, and the script's line naming version 1 and its source models:/m-25c3a789faf847ea975b066eff58b048.

  • Successfully registered model 'iris-classifier'.: the name didn't exist, so MLflow created the registered model.
  • Waiting up to 300 seconds: register_model waits until the version is ready, five minutes at most, set by its await_registration_for argument.
  • Created version '1': the logged model is now version 1.
  • from models:/m-...: the version's source is the logged model it holds.

Step 2: Register Another Version​

Run the script again. It trains and logs a new model, and registers it under the same name:

Terminal
uv run python register_model.py
Output (last lines)
Registered model 'iris-classifier' already exists. Creating a new version of this model...
2026/11/25 09:43:30 INFO mlflow.store.model_registry.abstract_store: Waiting up to 300 seconds for model version to finish creation. Model name: iris-classifier, version 2
Created version '2' of model 'iris-classifier'.
Registered iris-classifier, version 2, from models:/m-d3a71dde61844dc0a5573153ec972113

The end of the second run's output in a terminal: Registered model iris-classifier already exists, Creating a new version of this model, Created version 2, and the script's line naming version 2 and its new source model.

The name existed, so MLflow added version 2, from the new logged model. Version 1 stays as it was: versions are never overwritten.

Common Mistakes​

MistakeWhat happensDo this instead
Expecting the second call to replace version 1It adds version 2Use an alias, such as champion, to mark the version in use
Typing the name slightly differentlyA second registered modelKeep the name in one place, such as a setting

Troubleshooting​

SymptomLikely causeFix
The call waits a long timeIt waits for the version to be ready, up to await_registration_for secondsPass await_registration_for=0 to return at once
The registry calls fail on your own serverThe server stores runs in files, not a databaseStart it with a database backend, such as its default SQLite database

FAQ​

Can I register while logging instead?​

Yes, with registered_model_name= on log_model: How to Register a Model When You Log It in MLflow.

Which run does the version point to?​

The run that logged the model. The returned ModelVersion has it in run_id, next to source: How to Find the Run and Logged Model Behind a Model Version in MLflow.

Conclusion​

mlflow.register_model(info.model_uri, "iris-classifier") created the registered model and version 1 on the first run, and version 2 on the second, each pointing to the logged model it came from.

Additional Resources​