Skip to content

MLflow integration guide#

With the Neptune-MLflow integration, you can export run metadata from MLflow to Neptune.

In development

We're working on the plugin component of the integration, which lets you log metadata to Neptune and MLflow simultaneously.

See example in Neptune  Code examples 

Before you start#

Installing the integration#

To use your pre-installed version of Neptune together with the integration:

pip install -U neptune-mlflow

To install both Neptune and the integration:

pip install -U neptune neptune-mlflow

Exporting MLflow runs to Neptune#

neptune-notebooks incompatibility

Currently, the CLI component of the integration does not work together with the Neptune-Jupyter extension (neptune-notebooks).

Until a fix is released, if you have neptune-notebooks installed, you must uninstall it to be able to use the neptune mlflow command.

You can export your logged metadata from MLflow to Neptune with the neptune mlflow CLI command:

neptune mlflow

If you haven't set your credentials as environment variables, you can also pass them as arguments:

neptune mlflow --api-token YourNeptuneApiToken --project YourProjectName
How do I save my credentials as environment variables?

Set your Neptune API token and full project name to the NEPTUNE_API_TOKEN and NEPTUNE_PROJECT environment variables, respectively.

For example:

export NEPTUNE_API_TOKEN="h0dHBzOi8aHR0cHM.4kl0jvYh3Kb8...6Lc" # (1)!
  1. On Windows, the command is set instead of export.
export NEPTUNE_PROJECT="ml-team/classification" # (1)!
  1. On Windows, the command is set instead of export.

Finding your credentials:

  • API token: In the bottom-left corner of the Neptune app, expand your user menu and select Get your API token.
  • Project: Your full project name has the form workspace-name/project-name. To copy the name, click the menu in the top-right corner and select Edit project details.

If you're working in Colab, you can set your credentials with the os and getpass libraries:

import os
from getpass import getpass
os.environ["NEPTUNE_API_TOKEN"] = getpass("Enter your Neptune API token: ")
os.environ["NEPTUNE_PROJECT"] = "workspace-name/project-name"

You'll find the imported metadata in All metadata, in the following structure:

artifacts
    |-- <logged artifacts>
experiment
    |-- creation_time
    |-- experiment_id
    |-- last_update_time
    |-- name
run_data
    |-- metrics
    |-- params
    |-- tags
run_info
    |-- artifact_uri
    |-- end_time
    |-- experiment_id
    |-- lifecycle_stage
    |-- run_id
    |-- run_name
    |-- run_uuid
    |-- start_time
    |-- status
    |-- user_id
Note for large projects

When exporting runs from MLflow, Neptune checks whether each MLflow run already exists in the Neptune project.

Due to a technical limitation, a maximum of 10 000 Neptune runs can be checked for each export. Therefore, if your Neptune project contains more than 10 000 runs, it is possible that some MLflow runs will be copied over to Neptune even if they already exist in the Neptune project.


Related