Changing parameters across repeated trials makes it hard to remember which settings produced a given result. MLflow is an experiment tracking tool that records the parameters, metrics, and artifacts for each run so you can compare them in one place. I installed it and tested whether it could record and compare runs with the network disconnected.
MLflow records parameters, metrics, and tags for each run and lets you compare multiple runs in one view. The project releases its source code under the Apache 2.0 License (*1).
1. Install MLflow
FROM docker.io/library/python:3.12.13-slim
RUN pip install --no-cache-dir --quiet 'mlflow==3.14.0'
WORKDIR /work
podman build -t mlflow-sandbox .
2. Roadblock: The File Store Is Deprecated
MLflow can store experiment records in local files without a server. I used the traditional file-store URI (file:///work/mlruns), and the run stopped with this error.
mlflow.exceptions.MlflowException: The filesystem tracking backend (e.g., './mlruns') is
in maintenance mode and will not receive further updates. Please migrate to a database
backend (e.g., 'sqlite:///mlflow.db') ...
In the current MLflow release, the file store runs in maintenance mode. New use requires explicit permission. I followed the error message's guidance and switched to a SQLite backend.
3. Record Runs with a SQLite Backend
import mlflow
mlflow.set_tracking_uri("sqlite:///work/mlflow.db")
mlflow.set_experiment("rootless-container-benchmark")
with mlflow.start_run(run_name="baseline") as run:
mlflow.log_param("memory_limit_mb", 2048)
mlflow.log_param("cpu_limit", 2)
mlflow.log_metric("startup_seconds", 1.42)
mlflow.log_metric("throughput_rps", 340.5)
with mlflow.start_run(run_name="tuned") as run:
mlflow.log_param("memory_limit_mb", 4096)
mlflow.log_param("cpu_limit", 2)
mlflow.log_metric("startup_seconds", 1.18)
mlflow.log_metric("throughput_rps", 512.3)
runs = mlflow.search_runs(experiment_names=["rootless-container-benchmark"])
print(runs[["tags.mlflow.runName", "params.memory_limit_mb", "metrics.throughput_rps"]].to_string(index=False))
podman run --rm --network none --memory 2g --cpus 2 --pids-limit 512 --userns=keep-id \
-v "$(pwd)":/work -w /work mlflow-sandbox \
python tracking_demo.py
The -v option makes the specified directory readable and writable from inside the container. Run this in an empty directory reserved for the experiment. Because sqlite:///work/mlflow.db creates the database file under the mount point, avoid running it in a location that contains important existing data.
During the run, MLflow printed several lines warning that it could not find the git command. MLflow had tried to record Git commit information from the environment that launched the run, so the failure did not affect the experiment records. The command printed this table:
tags.mlflow.runName params.memory_limit_mb metrics.throughput_rps
tuned 4096 512.3
baseline 2048 340.5
MLflow recorded the two runs with different parameter values, and search_runs compared them in one view. Experiment recording and search finished with one local SQLite file and no server.
You Don't Need to Remember the Settings from a Past Run
Changing parameters across repeated trials without keeping records leaves you unable to reproduce what happened under each setting. Run a tool such as MLflow on the local machine, and you can build experiment tracking into your workflow without operating a server. You can start with records, rather than memory, as the basis for your experiment history.
Sources
*1 MLflow (GitHub), https://github.com/mlflow/mlflow, Apache 2.0 License