Access the MLflow tracking server from outside Databricks

You may wish to log to the MLflow tracking server from your own applications or from the MLflow CLI.

This article describes the required configuration steps. Start by installing MLflow and configuring your credentials (Step 0). You can then either configure an application (Step 1a) or configure the MLflow CLI (Step 1b).

For information on how to launch and log to an open-source tracking server, see the open source documentation.

Step 0: Configure your environment

If you don’t have a Databricks Workspace, you can try Databricks for free on Community Edition, which provides a simple managed MLflow experience for lightweight experimentation.

To configure your environment to access your Databricks hosted MLflow tracking server:

  1. Install MLflow using pip install mlflow.

  2. Configure authentication according to your Databricks subscription.

    • Community Edition. Do one of:

      • Create a credentials file using your username and password using databricks configure.

      • Specify credentials using environment variables:

        # Configure MLflow to communicate with a Databricks-hosted tracking server
        export MLFLOW_TRACKING_URI=databricks
        # Specify your Databricks username & password
        export DATABRICKS_USERNAME="..."
        export DATABRICKS_PASSWORD="..."
        
    • Databricks Platform. Do one of:

      • Generate a REST API token and create your credentials file using databricks configure --token.

      • Specify credentials using environment variables:

        # Configure MLflow to communicate with a Databricks-hosted tracking server
        export MLFLOW_TRACKING_URI=databricks
        # Specify the workspace hostname and token
        export DATABRICKS_HOST="..."
        export DATABRICKS_TOKEN="..."
        # Or specify your Databricks username & password
        export DATABRICKS_USERNAME="..."
        export DATABRICKS_PASSWORD="..."
        

Step 1a: Configure MLflow applications

Configure MLflow applications to log to Databricks by setting the tracking URI to databricks, or databricks://<profileName>, if you specified a profile name via --profile while creating your credentials file. For example, you can achieve this by setting the MLFLOW_TRACKING_URI environment variable to “databricks”.

Step 1b: Configure the MLflow CLI

Configure the MLflow CLI to communicate with a Databricks tracking server with the MLFLOW_TRACKING_URI environment variable. For example, to create an experiment using the CLI with the tracking URI databricks, run:

# Replace <your-username> with your Databricks username
export MLFLOW_TRACKING_URI=databricks
mlflow experiments create -n /Users/<your-username>/my-experiment