pip install mlflowThe full platform, including the server and UI. Python 3.10+ since MLflow 3.pip install mlflow-skinnyClient only — no server, no UI, far fewer dependencies. The right choice inside a training container.pip install mlflow-tracingTracing SDK alone, for instrumenting an app that only needs to emit traces. Do not co-install with fullmlflow.pip install "mlflow[genai]"Extras also includedatabricks,gateway,langchain,mcp,auth,kubernetes,azure,sqlserver.pip install 'mlflow<3'Pin to 2.x if you are not ready to migrate. MLflow 3 reads 2.x data; the reverse is not true.mlflow --version · mlflow doctordoctordumps environment and config for bug reports; add--mask-envsbefore pasting it anywhere.
mlflow server --port 5000Starts the tracking server and UI. Binds to localhost only; use--host 0.0.0.0to expose it.mlflow server --backend-store-uri sqlite:///mlflow.dbA database backend. Required for the Model Registry — the file store cannot serve it.mlflow server --artifacts-destination s3://bucketProxies artifact traffic through the server, so clients need no cloud credentials.mlflow demo3.xSpins up a server pre-populated with demo data. The fastest way to see what the UI offers.mlflow models serve -m "models:/fraud-rf@champion" -p 1234Local REST endpoint at/invocations. Defaults to a virtualenv built from the model's requirements.mlflow run . -P lr=0.02Runs an MLproject entry point with parameters.mlflow gc --older-than 30dPermanently deletes runs already in the deleted stage. Deletion in the UI only soft-deletes.mlflow db upgrade sqlite:///mlflow.dbMigrates the schema after an MLflow upgrade. Back up first — migrations are not transactional.mlflow experiments search · mlflow runs list --experiment-id 1Browse from the shell. Both needMLFLOW_TRACKING_URIset.mlflow artifacts download -u "runs:/<id>/plots"Pull artifacts without writing Python.
mlflow.set_tracking_uri("http://127.0.0.1:5000")Call it before anything else. Without it everything lands in a local./mlrunsfolder.mlflow.set_tracking_uri("sqlite:///mlflow.db")Talk to a database directly, no server needed. Enough to unlock the registry for solo work.export MLFLOW_TRACKING_URI=...The CLI does not read your Python config — most CLI commands need this variable set.mlflow.set_registry_uri("databricks-uc")Registry can live somewhere other than tracking — this is how you target Unity Catalog.# backend store = metadata · artifact store = filesTwo separate things. Params and metrics go to one, model weights and plots to the other.mlflow.get_tracking_uri()Check what you are actually connected to before blaming the server.# file store cannot serve the Model RegistryIf registry calls fail, this is nearly always why. Move to SQLite or Postgres.
mlflow.set_experiment("fraud-detection")Creates it if missing. Everything after this call lands there.mlflow.create_experiment(name, artifact_location="s3://bucket", tags={...})Explicit creation when you need a custom artifact root or tags from the start.mlflow.search_experiments(filter_string="tags.team = 'ds'")Find experiments programmatically.MLFLOW_EXPERIMENT_NAME · MLFLOW_EXPERIMENT_IDSet the target from the environment so the same script works across stages unchanged.mlflow experiments create -n "my-exp"Same thing from the shell.# deleting an experiment only marks it deletedThe file store moves it to.trash. Space is reclaimed only bymlflow gc.
with mlflow.start_run() as run:The form to use. Ends the run on exit and marks it FAILED if the block raises.mlflow.start_run(run_name="rf-baseline")A readable label. Without one MLflow generates a random name.mlflow.start_run(nested=True)Child run under the currently active one — the pattern for sweeps and CV folds.mlflow.start_run(run_id=rid)Reopen an existing run to append more data to it.mlflow.end_run(status="FAILED")Manual close. Statuses: FINISHED, FAILED, KILLED.run.info.run_id · run.info.statusIdentity and state. Keep the id if you plan to reopen or reference the run.mlflow.active_run() · mlflow.last_active_run()The run in progress, and the one that just finished — handy after autologging.run_info.run_uuidremoved in 3Userun_info.run_id.
mlflow.log_param("lr", 0.01) · mlflow.log_params({...})Inputs. Stored as strings, and immutable — re-logging a key with a different value raises.mlflow.log_metric("auc", 0.94) · mlflow.log_metrics({...})Outputs. Numeric and append-only — a metric is a series, not a single value.mlflow.log_metric("loss", l, step=epoch)The x-axis for charts. Any 64-bit int — may be negative, out of order, or have gaps.mlflow.log_metric(k, v, timestamp=ms)Custom wall-clock, in milliseconds. Passing seconds puts your point in 1970.mlflow.log_metric(k, v, model_id=..., dataset=...)3.xAttaches the metric to a specific model checkpoint and dataset, not just the run.mlflow.set_tag("env", "prod") · mlflow.set_tags({...})Mutable labels you can search on. Unlike params, tags can be changed later.mlflow.set_tag("mlflow.note.content", "...")The one system tag you are meant to set. Renders as a Notes panel on the run page.# auto tags: mlflow.source.name / .user / .source.git.commitSet for you. Git commit is captured whenever you run inside a repo.# params are strings — log_param("n", 300) reads back "300"Cast on the way out, or filter with the numeric form in search.
mlflow.autolog()Enables every installed integration at once. Params, metrics, the model and plots, with no log calls.mlflow.sklearn.autolog() · mlflow.pytorch.autolog()Per-library, when the blanket call captures more than you want.mlflow.autolog(log_models=False)Track metrics without uploading a model artifact every fit — the usual fix for a bloated store.mlflow.autolog(disable=True)Turn it off again for a block.mlflow.autolog(silent=True)Suppresses the integration warnings that flood notebook output.mlflow.autolog(exclusive=True)Blocks your manual calls from mixing into an autologged run.mlflow.openai.autolog() · mlflow.langchain.autolog()For LLM libraries autolog emits traces, not metrics. 40+ integrations. See card 19.# autolog starts a run if none is activeAnd ends it whenfitreturns. Wrap instart_runif you want to add your own metrics after.every_n_iterTF, removed in 3Write a callback if you need a custom logging frequency.
mlflow.log_artifact("confusion.png")One file. Optionalartifact_path=puts it in a subfolder.mlflow.log_artifacts("./plots/")A whole directory in one call.mlflow.log_figure(fig, "roc.png")A matplotlib or plotly figure straight from memory — no temp file.mlflow.log_table(data, "preds.json") · mlflow.log_text(s, "notes.txt")Alsolog_dictandlog_imagefor the common cases.ds = mlflow.data.from_pandas(df, name="train")Alsofrom_numpy,from_spark,from_huggingface. Captures schema and a digest.mlflow.log_input(ds, context="training")Records which data produced the run — the missing half of reproducibility.mlflow.artifacts.download_artifacts(run_id=..., artifact_path=...)Fetch them back to local disk.mlflow.get_artifact_uri("model")wrong in 3Models no longer live under the run's artifacts, so this path will not load. Use the URI returned bylog_model.
with mlflow.start_run(run_name="sweep") as parent:Outer run holds the summary; each trial becomes a child.with mlflow.start_run(nested=True):The child. Collapses under the parent in the UI instead of flooding the list.filter_string=f"tags.mlflow.parentRunId = '{rid}'"How you fetch the children back out.mlflow.set_tracking_uri(...) # inside each workerRequired with multiprocessing — a spawned process does not inherit the URI.with ThreadPoolExecutor() as ex: ...Threads share the active run, so give each worker anested=Truerun of its own.mlflow.set_tag("fold", k)Tag each child so the comparison table sorts sensibly.