authorizationtrackingmlflowmlops

How to connect to MLFlow tracking server that has auth?


I want to connect to remote tracking server (http://123.456.78.90) that requires authentication

When I do this:

import mlflow
mlflow.set_tracking_uri("http://123.456.78.90")
mlflow.set_experiment("my-experiment")

I get an error

MlflowException: API request to endpoint /api/2.0/mlflow/experiments/list failed with error code 401 != 200. Response body: 401 Authorization Required

I understand that I need to log in first but I have no idea how to do it


Solution

  • MLflow documentation says:

    MLFLOW_TRACKING_USERNAME and MLFLOW_TRACKING_PASSWORD - username and password to use with HTTP Basic authentication. To use Basic authentication, you must set both environment variables.

    So you just need to set these variables in your code using os.environ:

    os.environ['MLFLOW_TRACKING_USERNAME'] = 'name'
    os.environ['MLFLOW_TRACKING_PASSWORD'] = 'pass'