Set user_id in Mlflow

Viewed 897

I am running MLflow with several users can instanciate experiments.

Is there any way to override user_id which is set to system username?

Looking for a solution which works with start_run block.

Any ideas?

with mlflow.start_run():

1 Answers

start_run doesn't support user_id as argument, and its kwargs are actually Run tags, so you need to work with other functions.

In order to do what you need, you have to create for yourself the run from a FileStore object, then wrap this new run inside an ActiveRun wrapper, that after the with-block will automatically finish the run passed as argument.

The code should look like this.

import time

import mlflow
from mlflow import ActiveRun
from mlflow.store.tracking.file_store import FileStore

now = int(time.time() * 1000)  # mlflow default when start_time is None

fs = FileStore()
run = fs.create_run(
   experiment_id = None, # defaults to "0"
   user_id = "your_user_id", # your actual user-id
   start_time = now, 
   tags = {},
)

with ActiveRun(run) as arun:
   ...

# after with block, run is finished
Related