Skip to main content

MLflow Tutorial for Machine Learning in Python — Part 10: Production Checklist and Recap

· 34 min read
Jagdish Kumawat
Founder @ Dewiride

The shopper project now trains, evaluates, registers and serves its model with MLflow. Before you rely on a setup like this, it has to answer four questions: which code made each model, who can reach the tracking server, what happens when its files are lost, and how it survives the next MLflow release. In this last part you'll answer all four on the series' own projects, then go through a production checklist and a recap of the whole series.

This is Part 10 of a 10-part series.

  1. Part 1: Install MLflow and Track Your First Experiment
  2. Part 2: Log Metrics Over Time and System Metrics
  3. Part 3: Log Artifacts and Datasets
  4. Part 4: Search and Filter Runs
  5. Part 5: Autologging and Hyperparameter Tuning with Nested Runs
  6. Part 6: Log, Load and Validate Models
  7. Part 7: Evaluate Models and Set Quality Gates
  8. Part 8: Register, Version and Promote Models with the Model Registry
  9. Part 9: Serve a Model as a REST API and in Docker
  10. Part 10: Production Checklist and Recap (you are here)

Every command and output on this page is real, captured while building the project.

Get the Source Code​

Get the complete source code of House Price Prediction with MLflow and scikit-learn on Dewiride Store →

Get the complete source code of Term Deposit Prediction with MLflow and scikit-learn on Dewiride Store →

Get the complete source code of Shopper Purchase Prediction with MLflow and scikit-learn on Dewiride Store →

Each archive is one of the three projects this series builds, and its own post gets it running: house prices, term deposits and shopper purchases. Every step is still shown here, for free.

What You'll Build in This Part​

  • a Git commit on every run: a small code_version.py module, so each run records which code produced it, even though MLflow doesn't find the commit by itself here;
  • a check of the tracking server's network protection: what it refuses, and why;
  • a backup script that copies the tracking server's database and files while the server runs;
  • a restored copy of the server on a second port, to prove the backup works;
  • a database upgrade, the step every future MLflow upgrade needs;
  • a production checklist for everything the series built, and a recap of all ten parts.

What Production-Ready Means Here​

The series runs everything on your own computer, and that doesn't change in this part. Production-ready here means four things you can check:

  • Reproducible. Every model can be traced back to its code, its data and its settings. Parts 1 to 3 logged the parameters and data, and Part 6 logged each model with its environment. The missing piece is the code version.
  • Protected. Only programs that should reach the tracking server can. MLflow's documentation, Protect Your Tracking Server from Network Exposure, says: "MLflow 3.5.0+ includes security middleware to protect against DNS rebinding, CORS attacks, and clickjacking."
  • Recoverable. The tracking server keeps everything in two places, mlflow.db and mlartifacts/. A backup is only proven once you've restored it.
  • Upgradable. New MLflow releases can change the database's layout, its schema. MLflow's upgrade guide lists the steps.

The Example Project​

The shopper project, dewiride-shopper-purchase-prediction, predicts whether an online shopping session ends in a purchase, and its champion model has been served since Part 9. The mlflow-server folder holds the tracking server from Part 1: its database mlflow.db, with the runs, models and registry of all three projects, and its files in mlartifacts/.

What This Part Costs​

Nothing: MLflow, Git and Python's standard library are free. A backup takes as much disk space as the data it copies; here it was 2.4 MB for the database and 11 MB of files.

Prerequisites​

  • Part 9 finished: the mlflow-server folder and the dewiride-shopper-purchase-prediction project, from Part 9.

Step 1: Start the Tracking Server​

Open a terminal in the mlflow-server folder and start the server, as before:

Terminal 1 (in mlflow-server)
uv run mlflow server --port 8080
Output (excerpt)
[MLflow] Security middleware enabled with default settings (localhost-only). To allow connections from other hosts, use --host 0.0.0.0 and configure --allowed-hosts and --cors-allowed-origins.
...
2026/11/28 13:39:43 INFO: Uvicorn running on http://127.0.0.1:8080 (Press CTRL+C to quit)

Leave it running. You saw the first line in Part 1: the server has protected itself this way all along, and Step 6 shows what that protection does. Open a second terminal in the dewiride-shopper-purchase-prediction folder for the next steps.

Step 2: See What a Run Records About Its Code​

Train the model once more, the way you have since Part 6:

Terminal 2 (in dewiride-shopper-purchase-prediction)
uv run train --run-name before-git-commit
Output (last lines)
2026/11/28 13:26:20 INFO shopper_purchase_prediction: Run before-git-commit logged the model models:/m-d10e1836469f47a6a38fb13f39ff3a63, test ROC AUC 0.9286
🏃 View run before-git-commit at: http://127.0.0.1:8080/#/experiments/3/runs/edcea13de2184325905dbdf9d058c2c7
🧪 View experiment at: http://127.0.0.1:8080/#/experiments/3

The run's ID is the end of its link. Ask MLflow for everything it stored about the run, with your own run ID:

Terminal 2
uv run mlflow --env-file .env runs describe --run-id edcea13de2184325905dbdf9d058c2c7
Output (excerpt)
Loaded environment variables from: .env
...
"tags": {
"mlflow.user": "you",
"mlflow.source.name": "/Users/you/source/dewiride-shopper-purchase-prediction/.venv/bin/train",
"mlflow.source.type": "LOCAL",
"mlflow.runName": "before-git-commit"
}

The terminal output of mlflow runs describe for the run before-git-commit: its tags list mlflow.user, mlflow.source.name ending in .venv/bin/train, mlflow.source.type LOCAL and mlflow.runName, and no Git commit.

--env-file .env makes the mlflow command read the project's .env, so it talks to your tracking server. Without it, it uses a new, empty mlflow.db in the current folder and fails with MlflowException: Run with id=… not found.

MLflow sets the tags that start with mlflow. itself. Its System Tags Reference lists one more, mlflow.source.git.commit, the "Git commit hash", set "When run from git repo". The project has been a Git repository since Part 1, but the tag isn't there. The run's page in the UI, under About this run, shows the same: a source, train, and nothing next to it.

The About this run panel of the run before-git-commit in the MLflow UI: Source shows only train.

Step 3: Find Out Why the Commit Is Missing​

mlflow.source.name is the clue: the run started from .venv/bin/train, the launcher that uv run train runs. On Windows it's in .venv\Scripts; Python's venv documentation says a virtual environment has "a bin (or Scripts on Windows) subdirectory". MLflow looks for the commit in the folder of that launcher, and Git ignores the whole .venv folder. Ask Git why, with git check-ignore:

Terminal 2
git check-ignore -v .venv
Output
.gitignore:10:.venv .venv

The terminal output of git check-ignore -v .venv: line 10 of .gitignore, .venv, ignores the .venv folder.

Line 10 of .gitignore, from Part 1, ignores .venv. In MLflow 3.18.0, the function that finds a run's commit gives up when Git ignores the folder it starts from, so every run started through a project command has no commit. Fixed: MLflow Doesn't Record the Git Commit of a Run Started with uv run follows the cause into MLflow's code.

The project's commands should keep working as they are, so the project will read the commit itself and give it to MLflow.

Step 4: Record the Commit on Every Run​

Create src/shopper_purchase_prediction/code_version.py. It starts with the project folder and the tag's name:

src/shopper_purchase_prediction/code_version.py (excerpt)
import logging
import subprocess
from pathlib import Path

logger = logging.getLogger("shopper_purchase_prediction")

# The project folder: src/shopper_purchase_prediction/code_version.py is two folders below it.
PROJECT_DIR = Path(__file__).resolve().parents[2]
GIT_COMMIT_TAG = "mlflow.source.git.commit"
  • Path(__file__).resolve().parents[2]: __file__ is this file's path. parents[0] is its folder, shopper_purchase_prediction, parents[1] is src, and parents[2] is the project folder, wherever the project lives.
  • GIT_COMMIT_TAG: the same tag MLflow sets when it finds the commit itself, so the UI shows it in the same place.

Then the function that reads the commit:

src/shopper_purchase_prediction/code_version.py (excerpt)
def git_commit_tag() -> dict[str, str]:
"""The tag that records the commit the project's code is at, or no tag outside Git."""
try:
result = subprocess.run(
["git", "rev-parse", "HEAD"],
cwd=PROJECT_DIR,
capture_output=True,
text=True,
check=True,
)
except OSError, subprocess.CalledProcessError:
logger.warning("Found no Git commit for the project, so the run won't record one")
return {}
return {GIT_COMMIT_TAG: result.stdout.strip()}
  • git rev-parse HEAD: prints the full hash of the commit the project is at (how git rev-parse HEAD works).
  • subprocess.run(...): runs it in the project folder. Python's subprocess reference on check=True: "If check is true, and the process exits with a non-zero exit code, a CalledProcessError exception will be raised." capture_output=True and text=True keep what Git prints as text in result.stdout.
  • except OSError, subprocess.CalledProcessError:: Git isn't installed, or the folder isn't a Git repository with a commit, as when someone unzips the project without its history. The run then goes ahead without the tag, and the warning says why. Writing two exceptions without parentheses needs Python 3.14 or newer; the project uses 3.15.
  • result.stdout.strip(): the hash, without the line break Git ends it with.

The complete file:

src/shopper_purchase_prediction/code_version.py
"""The Git commit of the project's code, recorded on every MLflow run.

MLflow records a run's Git commit only when the script the run started from is inside the Git
repository. The project's commands start from launchers in .venv/bin, which Git ignores, so the
commit is read here and passed to mlflow.start_run as the same tag MLflow would set."""

import logging
import subprocess
from pathlib import Path

logger = logging.getLogger("shopper_purchase_prediction")

# The project folder: src/shopper_purchase_prediction/code_version.py is two folders below it.
PROJECT_DIR = Path(__file__).resolve().parents[2]
GIT_COMMIT_TAG = "mlflow.source.git.commit"


def git_commit_tag() -> dict[str, str]:
"""The tag that records the commit the project's code is at, or no tag outside Git."""
try:
result = subprocess.run(
["git", "rev-parse", "HEAD"],
cwd=PROJECT_DIR,
capture_output=True,
text=True,
check=True,
)
except OSError, subprocess.CalledProcessError:
logger.warning("Found no Git commit for the project, so the run won't record one")
return {}
return {GIT_COMMIT_TAG: result.stdout.strip()}

code_version.py in a code editor: git_commit_tag runs git rev-parse HEAD in the project folder and returns the mlflow.source.git.commit tag, or no tag when Git or a commit is missing.

Now give the tag to every run the project starts. mlflow.start_run takes it as tags; its reference describes the parameter as "An optional dictionary of string keys and values to set as tags on the run." In train.py, import the function next to the other project imports:

src/shopper_purchase_prediction/train.py (new import)
from shopper_purchase_prediction.code_version import git_commit_tag

and pass the tag where the run starts:

src/shopper_purchase_prediction/train.py (changed line)
with mlflow.start_run(run_name=args.run_name, tags=git_commit_tag()) as run:

evaluate.py starts two runs, the evaluation and the nested baseline from Part 7, and promote.py one, from Part 8. Add the same import to both files, and the same tags=git_commit_tag() to each of these three lines:

src/shopper_purchase_prediction/evaluate.py (changed lines)
with mlflow.start_run(run_name="baseline", nested=True, tags=git_commit_tag()):
src/shopper_purchase_prediction/evaluate.py (changed lines)
with mlflow.start_run(run_name=args.run_name, tags=git_commit_tag()):
src/shopper_purchase_prediction/promote.py (changed line)
with mlflow.start_run(run_name=args.run_name, tags=git_commit_tag()) as run:

Step 5: Commit the Change, Then Train​

The tag records the commit the code is at when the run starts, so commit the change before you train with it:

Terminal 2
git add src/shopper_purchase_prediction
git commit -m "Record the Git commit of the code on every MLflow run"
Output
[master 6740b92] Record the Git commit of the code on every MLflow run
4 files changed, 38 insertions(+), 4 deletions(-)
create mode 100644 src/shopper_purchase_prediction/code_version.py
Terminal 2
git rev-parse HEAD
Output
6740b922418ec98b77442b4c2035224964c4d3e4

The terminal output of git commit, 4 files changed with code_version.py created, and of git rev-parse HEAD, the full hash 6740b922418ec98b77442b4c2035224964c4d3e4.

Your hash is different. Train again:

Terminal 2
uv run train --run-name with-git-commit
Output (last lines)
2026/11/28 13:30:26 INFO shopper_purchase_prediction: Run with-git-commit logged the model models:/m-2b984bc459184e68b50c7b439badcdb6, test ROC AUC 0.9286
🏃 View run with-git-commit at: http://127.0.0.1:8080/#/experiments/3/runs/c986c8dda80e443399d1b9556dde7ed9
🧪 View experiment at: http://127.0.0.1:8080/#/experiments/3
Terminal 2
uv run mlflow --env-file .env runs describe --run-id c986c8dda80e443399d1b9556dde7ed9
Output (excerpt)
Loaded environment variables from: .env
...
"tags": {
"mlflow.user": "you",
"mlflow.source.name": "/Users/you/source/dewiride-shopper-purchase-prediction/.venv/bin/train",
"mlflow.source.type": "LOCAL",
"mlflow.source.git.commit": "6740b922418ec98b77442b4c2035224964c4d3e4",
"mlflow.runName": "with-git-commit"
}

The terminal output of mlflow runs describe for the run with-git-commit: its tags now include mlflow.source.git.commit, 6740b922418ec98b77442b4c2035224964c4d3e4.

mlflow.source.git.commit is the hash git rev-parse HEAD printed. The run's page shows the first seven characters next to the source:

The About this run panel of the run with-git-commit in the MLflow UI: Source shows train and the commit 6740b92.

With the hash, you can always get back to exactly the code that trained this model. The earlier run, before-git-commit, keeps its tags as they were.

Step 6: Check the Tracking Server's Network Protection​

The server has listened on 127.0.0.1 since Part 1, so other computers can't reach it. A web page open in your browser runs on your computer, though, and the security middleware from Step 1 stands between such pages and the server. MLflow's CLI reference explains its two main settings, the allowed hosts: "DNS rebinding allows attackers to trick your browser into accessing internal services", and the allowed origins: "CORS attacks allow malicious websites to make requests to your MLflow server using your credentials." By default, the server accepts only the host names localhost and 127.0.0.1 and private network addresses, and only pages from localhost or 127.0.0.1 may call it from a browser.

Send the server a request that names another host, with curl -i so you see the status line too:

Terminal 2
curl -i -H "Host: mlflow.example.com" http://127.0.0.1:8080/
Output
HTTP/1.1 403 Forbidden
date: Sat, 28 Nov 2026 13:39:16 GMT
server: uvicorn
content-type: text/plain
Transfer-Encoding: chunked

Invalid Host header - possible DNS rebinding attack detected

The terminal output of curl with a Host header of mlflow.example.com: 403 Forbidden and Invalid Host header - possible DNS rebinding attack detected.

The request reached the server, and the server refused it because of the name in its Host header. That's what stops a site whose name has been pointed at your computer. Then a request that a page on another site would send, with its address in the Origin header:

Terminal 2
curl -i -X POST -H "Origin: https://app.example.com" -H "Content-Type: application/json" -d '{"max_results": 1}' http://127.0.0.1:8080/api/2.0/mlflow/experiments/search
Output
HTTP/1.1 403 Forbidden
date: Sat, 28 Nov 2026 13:39:16 GMT
server: uvicorn
content-type: text/plain
access-control-allow-credentials: true
access-control-expose-headers: *
vary: Origin
Transfer-Encoding: chunked

Cross-origin request blocked

The terminal output of a POST request with Origin https://app.example.com: 403 Forbidden and Cross-origin request blocked.

The server refused the request because of the page it came from. Finally, the headers every answer carries:

Terminal 2
curl -I http://127.0.0.1:8080/
Output (excerpt)
HTTP/1.1 200 OK
...
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN

x-frame-options: SAMEORIGIN means only pages from the server itself may show its UI inside a frame, which is what stops clickjacking, and nosniff tells the browser not to guess what a file contains.

For this series, keep the defaults and keep the server on 127.0.0.1: it has no sign-in, so anyone who can reach it can read and change everything. When you want to open it under another name, How to Let an MLflow Server Accept Another Host Name with --allowed-hosts shows how, and when your own web app should call it, How to Let a Web App Call an MLflow Server with --cors-allowed-origins.

Step 7: Write a Backup Script​

Everything the tracking server knows is in mlflow.db, and every file it keeps is in mlartifacts/. Copying mlflow.db while the server writes to it isn't safe. SQLite's own page, How To Corrupt An SQLite Database File, warns that a copy made "while it is in the middle of a transaction" "might contain some old and some new content, and thus be corrupt." SQLite's backup, which Python's sqlite3 module offers, is the safe way. Python's sqlite3 reference: "Create a backup of an SQLite database. Works even if the database is being accessed by other clients or concurrently by the same connection."

In the mlflow-server folder, create backup.py. It starts with where everything is:

mlflow-server/backup.py (excerpt)
SERVER_DIR = Path(__file__).resolve().parent
DATABASE = SERVER_DIR / "mlflow.db"
ARTIFACTS = SERVER_DIR / "mlartifacts"
BACKUPS = SERVER_DIR / "backups"

SERVER_DIR is the folder backup.py is in, so the script finds the files wherever you start it from. Then each backup gets a new folder, named after the time in UTC:

mlflow-server/backup.py (excerpt)
if not DATABASE.is_file():
print(
f"No database at {DATABASE}: keep backup.py next to mlflow.db",
file=sys.stderr,
)
return 1
target = BACKUPS / datetime.now(UTC).strftime("%Y-%m-%d_%H-%M-%S")
target.mkdir(parents=True)

The check comes first because sqlite3.connect creates a new, empty file when there's none, and backing that up would only look like a backup. The folder name, such as 2026-11-28_13-36-55, has no colons, which Windows doesn't allow in names: Microsoft's Naming Files, Paths, and Namespaces lists : among its reserved characters. Then the copy:

mlflow-server/backup.py (excerpt)
with (
closing(sqlite3.connect(DATABASE)) as source,
closing(sqlite3.connect(target / DATABASE.name)) as copy,
):
source.backup(copy)
if ARTIFACTS.is_dir():
shutil.copytree(ARTIFACTS, target / ARTIFACTS.name)
  • source.backup(copy): copies the database into the new file, as it is at one moment.
  • closing(...): closes both connections when the block ends. A sqlite3 connection's own with doesn't do that; the reference: "The context manager neither implicitly opens a new transaction nor closes the connection. If you need a closing context manager, consider using contextlib.closing()."
  • shutil.copytree: copies the artifact folder with everything in it. Python's shutil reference: "Recursively copy an entire directory tree rooted at src to a directory named dst and return the destination directory."

The complete file:

mlflow-server/backup.py
"""Back up the MLflow tracking server: its database, mlflow.db, and its artifacts, mlartifacts.

Run it with `uv run python backup.py` in the server's folder. It's safe while the server is running:
SQLite's backup copies the database as it is at one moment, even while MLflow writes to it. Each
backup goes into a new folder under backups/, named after the UTC time it started."""

import shutil
import sqlite3
import sys
from contextlib import closing
from datetime import UTC, datetime
from pathlib import Path

SERVER_DIR = Path(__file__).resolve().parent
DATABASE = SERVER_DIR / "mlflow.db"
ARTIFACTS = SERVER_DIR / "mlartifacts"
BACKUPS = SERVER_DIR / "backups"


def main() -> int:
"""Copy the database and the artifacts into backups/<time>."""
if not DATABASE.is_file():
print(
f"No database at {DATABASE}: keep backup.py next to mlflow.db",
file=sys.stderr,
)
return 1
target = BACKUPS / datetime.now(UTC).strftime("%Y-%m-%d_%H-%M-%S")
target.mkdir(parents=True)

with (
closing(sqlite3.connect(DATABASE)) as source,
closing(sqlite3.connect(target / DATABASE.name)) as copy,
):
source.backup(copy)
if ARTIFACTS.is_dir():
shutil.copytree(ARTIFACTS, target / ARTIFACTS.name)

print(f"Backed up the tracking server to {target}")
return 0


if __name__ == "__main__":
sys.exit(main())

backup.py in a code editor: it backs up mlflow.db with SQLite's backup into backups/ and a folder named after the UTC time, then copies mlartifacts.

Step 8: Back Up the Server While It Runs​

Open a third terminal in the mlflow-server folder, and leave the server running:

Terminal 3 (in mlflow-server)
uv run python backup.py
Output
Backed up the tracking server to /Users/you/source/mlflow-server/backups/2026-11-28_13-36-55

The terminal output of uv run python backup.py: Backed up the tracking server to the backups folder named 2026-11-28_13-36-55.

The new folder holds both parts of the server:

mlflow-server/backups/
backups/
└── 2026-11-28_13-36-55/
├── mlartifacts/
│ ├── 1/
│ ├── 2/
│ └── 3/
└── mlflow.db

mlartifacts/ keeps one folder per experiment ID: 1 is the house prices, 2 the term deposits and 3 the shoppers. Run backup.py whenever you want a backup, and copy the backups folder to another disk or another place: a backup on the same disk as the server is lost with it.

Step 9: Check That the Backup Restores​

A backup you haven't restored is only a hope. Start a second tracking server from the backup, on another port, with your own backup folder's name. The live server keeps running:

Terminal 3
uv run mlflow server --port 8081 --backend-store-uri sqlite:///backups/2026-11-28_13-36-55/mlflow.db --artifacts-destination backups/2026-11-28_13-36-55/mlartifacts
Output (excerpt)
Registry store URI not provided. Using backend store URI.
[MLflow] Security middleware enabled with default settings (localhost-only). To allow connections from other hosts, use --host 0.0.0.0 and configure --allowed-hosts and --cors-allowed-origins.
...
2026/11/28 13:40:34 INFO: Uvicorn running on http://127.0.0.1:8081 (Press CTRL+C to quit)
  • --backend-store-uri: where the server keeps its records. The CLI reference: "URI to which to persist experiment and run data." sqlite:/// followed by a path is an SQLite file, here the backup's.
  • --artifacts-destination: where it keeps the files, "The base artifact location from which to resolve artifact upload/download/list requests", here the backup's mlartifacts.

Open http://127.0.0.1:8081/#/experiments in your browser. All three projects' experiments are there, with the times they were created:

The Experiments page of the server restored from the backup: shopper-purchase-prediction, term-deposit-prediction, house-price-prediction and Default, with their original creation times.

Then open the registered model's page, http://127.0.0.1:8081/#/models/shopper-purchase-prediction. The three versions from Part 8 are there, with their quality-gate tags, and champion still points to version 2:

The shopper-purchase-prediction registered model on the restored server: versions 3, 2 and 1, quality_gate failed on version 3 and passed on version 2, and the champion alias on version 2.

The records came back, and the files did too. Click Version 2, then model next to Source Model, and on the model's page click Artifacts, then MLmodel:

The champion model's Artifacts tab on the restored server: MLmodel, conda.yaml, input_example.json, model.skops, python_env.yaml, requirements.txt and serving_input_example.json, with MLmodel open.

The server read the model's files from the backup's mlartifacts. The backup works. Close the browser tab, go to the third terminal and press Ctrl+C to stop the second server.

Step 10: Upgrade the Database Before a New MLflow Version​

When a new MLflow version comes out, its database layout may have changed. MLflow's upgrade guide lists the steps: "Stop the server. Upgrade the package version in the environment. Run database migrations (if database backend is used). Restart the server." It also warns: "Schema migrations can be slow and are not guaranteed to be transactional. Always take a backup of the database before running the migration." Step 8 was that backup.

MLflow 3.18.0 is still the newest release as this is written, so there's no new version to move to. Run the migration step anyway, to see what it does to a database that's already up to date. In the first terminal, press Ctrl+C to stop the server, then:

Terminal 1 (in mlflow-server)
uv run mlflow db upgrade sqlite:///mlflow.db
Output
2026/11/28 13:39:30 INFO mlflow.store.db.utils: Updating database tables

The terminal output of uv run mlflow db upgrade sqlite:///mlflow.db: Updating database tables.

The database was already at the newest layout for MLflow 3.18.0, so there was nothing to change. After a real upgrade, the same command migrates the tables: How to Upgrade an MLflow Tracking Database with mlflow db upgrade upgrades a database made by MLflow 3.16.0. Don't skip the step by just starting the new version: MLflow 3.18.0 migrated that older database on its own as it started, without a backup (Fixed: The MLflow Server Upgrades an Old Database on Its Own When It Starts). Start the server again:

Terminal 1 (in mlflow-server)
uv run mlflow server --port 8080

The Production Checklist​

Each line is something the series built, and the part that shows how.

Reproducibility

  • Every run records its code version: mlflow.source.git.commit, with code_version.py when runs start from project commands (this part, Steps 4 and 5). Commit before you train.
  • Every run records its settings: parameters and the random seed, logged with the run (Part 1, Part 2).
  • Every run records its data: the datasets it used, with a digest that changes when the data does (Part 3).
  • Every model carries its contract and environment: a signature, an input example and its package versions; the training output above shows MLflow taking them from uv.lock: "Exported 92 dependencies via uv" (Part 6).
  • The lock file is committed: uv.lock pins every package, so the project installs the same versions everywhere (Part 1).

Quality

  • No model goes live without passing the quality gate: evaluated against the baseline with thresholds (Part 7).
  • The registry decides which model is live: the champion alias, moved only by promote after the gate (Part 8).
  • Tuning is recorded too: every candidate of a search as a nested run (Part 5).

Security

  • The tracking server stays on 127.0.0.1, with the security middleware's defaults (this part, Step 6).
  • The model server stays on 127.0.0.1 too: it has no sign-in either (Part 9).
  • Models are saved with skops, which loads only the types you trust, not with pickle (Part 6).
  • Settings and addresses live in .env, which Git ignores (Part 1).
  • Telemetry is off, if you don't want MLflow to send anonymous usage data (Part 1).

Operations

  • Back up while the server runs, and keep a copy on another disk (this part, Steps 7 and 8).
  • Restore each new kind of backup on a second server before you need it (this part, Step 9).
  • Back up, then upgrade the database before you start a new MLflow version (this part, Step 10).
  • Clear out deleted runs with mlflow gc (Part 4).
  • Watch for problems early: metrics over time and system metrics during training (Part 2).

What You Built in This Series​

Your Folders Now Look Like This​

source/
source/
├── mlflow-server/
│ ├── .venv/
│ ├── backups/
│ │ └── 2026-11-28_13-36-55/
│ │ ├── mlartifacts/
│ │ └── mlflow.db
│ ├── mlartifacts/
│ ├── backup.py
│ ├── mlflow.db
│ ├── pyproject.toml
│ └── uv.lock
├── dewiride-house-price-prediction/
│ └── ...
├── dewiride-term-deposit-prediction/
│ └── ...
└── dewiride-shopper-purchase-prediction/
├── .venv/
├── data/
│ └── online-shoppers.zip
├── examples/
│ ├── sessions.csv
│ └── sessions.json
├── src/
│ └── shopper_purchase_prediction/
│ ├── __init__.py
│ ├── call_api.py
│ ├── code_version.py
│ ├── config.py
│ ├── data.py
│ ├── evaluate.py
│ ├── model.py
│ ├── predict.py
│ ├── promote.py
│ ├── registry.py
│ ├── train.py
│ └── validate.py
├── .env
├── .env.example
├── .gitignore
├── .python-version
├── README.md
├── pyproject.toml
└── uv.lock

Clean Up Everything the Series Created​

When you're done with the series, stop the tracking server first: go to the first terminal and press Ctrl+C. Your runs, models and registry stay in mlflow.db and mlartifacts/ until you delete them.

To remove everything the series created:

  • The model image from Part 9: docker rmi shopper-purchase-prediction:2 (How to Remove a Docker Image).
  • The environments mlflow models serve built: the folder .mlflow/envs in your home folder, with no model server running.
  • The California Housing download from Part 1: the folder scikit_learn_data in your home folder.
  • The four folders: mlflow-server, with its backups, and the three projects. Copy the backups somewhere else first if you want to keep your runs.

Common Mistakes​

MistakeWhat happensDo this instead
Training before committingThe run records the previous commit, which isn't the code that trained itCommit, then train
Running an mlflow command without --env-file .env in a project folderIt uses a new mlflow.db in that folder: MlflowException: Run with id=… not foundAdd --env-file .env, and delete the stray mlflow.db
Copying mlflow.db with a file copy while the server runsSQLite warns that such a copy "might contain some old and some new content, and thus be corrupt"Use backup.py, which uses SQLite's backup
Starting the restored server on the live server's portPort 8080 is taken by the running serverUse another port, such as 8081
Starting a new MLflow version on the old databaseMLflow 3.18.0 migrated a 3.16.0 database on its own as it started, with no backup; when no tables are missing, it refuses with Detected out-of-date database schema insteadBack up, then mlflow db upgrade, then start the server

Troubleshooting​

SymptomLikely causeFix
No commit next to Source on a new runThe run didn't get the tag, or the warning Found no Git commit for the project was printedCheck that start_run has tags=git_commit_tag(), and that the project folder has at least one commit
MlflowException: Run with id=… not foundThe mlflow command didn't read .envFixed: "MlflowException: Run with id=… not found" When You Run an MLflow CLI Command
Invalid Host header - possible DNS rebinding attack detectedThe server was reached under a name it doesn't allowUse 127.0.0.1 or localhost, or allow the name with --allowed-hosts
Cross-origin request blocked from your own web appThe app's origin isn't allowedAllow it with --cors-allowed-origins
[Errno 48] Address already in use when starting the second serverAnother program already listens on that portFixed: "[Errno 48] Address already in use" When You Start the MLflow Server

FAQ​

Do I have to stop the server to back it up?​

No. Step 8 backed it up while it was running, and Step 9 restored that backup. Python's reference says SQLite's backup "Works even if the database is being accessed by other clients".

Do the runs from before this part get a commit?​

No. Tags are written when a run starts. before-git-commit still shows only train as its source.

What about the house price and term deposit projects?​

They start runs from project commands too, so they need the same change: code_version.py with their own logger name, and tags=git_commit_tag() where train.py (house prices) and tune.py (term deposits) start their runs.

Is it safe to put the tracking server on the network now?​

Not as it is: it has no sign-in, so anyone who can reach it can read and change everything. The security middleware protects it from web pages in your browser, not from people. MLflow's guide to basic HTTP authentication is the place to start if you ever need to share it.

Conclusion​

The series' setup now answers its four questions. code_version.py gives every run its Git commit, 6740b92 here, which MLflow didn't find on its own because runs start from launchers in the Git-ignored .venv. The tracking server refused a request with a foreign Host header and a POST from another site, both with 403. backup.py copied mlflow.db and mlartifacts while the server was running, and a second server on port 8081 showed every experiment, the champion alias and the model's files from that backup. mlflow db upgrade showed the step every future MLflow upgrade needs.

That's the whole series: ten parts, three projects and one tracking server, from your first run to a served, versioned and backed-up model. The series page lists every part in order. The complete source code of each project is on Dewiride Store: House Price Prediction, Term Deposit Prediction and Shopper Purchase Prediction, each with MLflow and scikit-learn.

Additional Resources​


← Previous: Part 9: Serve a Model as a REST API and in Docker