---
title: Track runs with the legacy Python CLI
description: How AI Runtime (`air`) CLI workloads map to MLflow experiments, runs, and the Databricks Jobs run page, including system metrics and logging custom metrics.
canonical_url: https://docs.databricks.com/aws/en/machine-learning/ai-runtime/connecting/cli/legacy-cli/track-runs
---

# Track runs with the legacy Python CLI

> [!IMPORTANT]
>
> This documentation has been retired and might not be updated.
>
> The Python-based `air` CLI, installed with the `databricks-air` package, is now deprecated and is no longer actively maintained.
>
> Use the Databricks CLI for new workloads. See [Use the Databricks CLI with AI Runtime](https://docs.databricks.com/aws/en/machine-learning/ai-runtime/connecting/cli/index.md).

Each workload you submit with `air run` is both a Databricks job run and an MLflow run:

* The job run (visible on the workspace **Jobs & Pipelines** page) tracks execution: status, compute, retries, and driver output.
* The MLflow run tracks the experiment: parameters, metrics, system metrics, and artifacts.

One submission creates one job run and one MLflow run. A retry creates a new MLflow run.

## Experiments and runs

The following workload YAML fields control the MLflow experiment, run, and artifact storage:

```yaml
experiment_name: my-training # Creates or appends to this MLflow experiment
mlflow_run_name: baseline-lr3e5 # Names the MLflow run for this submission
# Stores artifacts in a UC volume
mlflow_artifact_location: /Volumes/main/default/mlflow-artifacts/my-training
compute:
  num_accelerators: 8
  accelerator_type: GPU_8xH100
command: torchrun --nproc_per_node=8 train.py
max_retries: 2
```

* `experiment_name` (Required): Creates an MLflow experiment with this name if one doesn't exist, or appends a new run to the existing experiment. An experiment holds many runs.
* `mlflow_run_name` (Optional): Sets the run name. If omitted, the run name defaults to the experiment name (`experiment_name`).
* `mlflow_artifact_location` (Optional): Sets the root location for artifacts. If omitted, a new experiment uses the default DBFS location, and an existing experiment uses the location tied to the `experiment_name`. For a Unity Catalog volume, use `/Volumes/<catalog>/<schema>/<volume>/...`. For an existing experiment, the specified location must match the experiment's artifact location or be omitted.
* `max_retries` (Optional): Each retry attempt is a new MLflow run in the same experiment, so you can compare attempts. The original submission and its retries share one job run.

![MLflow run page showing metrics](https://docs.databricks.com/aws/en/images/machine-learning/ai-runtime/mlflow-run-page.png)

## Navigate between Jobs, MLflow, and previous workloads

You can get to a run from three places:

* **Jobs**: The Jobs run page lists your runs, and each run links to its MLflow run and experiment.
* **MLflow**: The Experiments page lists your MLflow experiments.
* **Previous workloads**: `air get run <job-run-id>` prints clickable links to the run's job, experiment, and MLflow run. `air list runs` lists your previous runs and lets you filter to find a specific run.

```bash
air get run <job-run-id> # Links to the job, experiment, and MLflow run
air list runs # List previous runs; filter to find a specific run
```

## System metrics

GPU, CPU, and memory system metrics are captured automatically for every run. No configuration is required. View them on the MLflow run's **System metrics** tab.

![System metrics tab of an MLflow run (GPU/CPU/memory)](https://docs.databricks.com/aws/en/images/machine-learning/ai-runtime/mlflow-system-metrics.png)

## Log custom metrics

The platform creates the MLflow run and exposes its ID to your training process through the `MLFLOW_RUN_ID` environment variable. Use the [MLflow tracking API](https://docs.databricks.com/aws/en/mlflow/tracking.md) to log your own parameters, metrics, and artifacts to that run.

On distributed (multi-node) workloads, every node shares the same MLflow run. Log from the rank-0 process only, so each metric is recorded once:

```python
import os

import mlflow

# Log from rank 0 only; all nodes share the same MLFLOW_RUN_ID.
if os.environ.get("RANK", "0") == "0":
    with mlflow.start_run(run_id=os.environ["MLFLOW_RUN_ID"]):
        mlflow.log_param("learning_rate", 3e-4)
        for step, loss in enumerate(training_losses):
            mlflow.log_metric("train_loss", loss, step=step)
```

## Logs and artifacts

Stream or download a run's logs with `air logs`:

```bash
air logs <job-run-id> # Stream logs from node 0
air logs <job-run-id> --node 2 # Logs from a specific node
air logs <job-run-id> --download-to ./logs/ # Download instead of streaming
```

Logs are also available as artifacts on the MLflow run. To persist model checkpoints, write them to a Unity Catalog volume. For checkpointing patterns, see [Improve training performance and resiliency on AI Runtime](https://docs.databricks.com/aws/en/machine-learning/ai-runtime/guides/performance-and-resiliency.md).

## <a id="additional-resources" /> Additional resources

* [Legacy Python CLI quickstart for AI Runtime](https://docs.databricks.com/aws/en/machine-learning/ai-runtime/connecting/cli/legacy-cli/quickstart.md)
* [Workload YAML reference for the legacy Python CLI](https://docs.databricks.com/aws/en/machine-learning/ai-runtime/connecting/cli/legacy-cli/yaml-config.md)
* [Experiment tracking and observability](https://docs.databricks.com/aws/en/machine-learning/ai-runtime/monitor-deploy/tracking-observability.md)
