简体   繁体   中英

Set user_id in Mlflow

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():

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM