在Mlflow中设置user_id

Mar*_*ran 6 python mlflow

我正在与多个用户一起运行 MLflow,可以实例化实验。

有什么方法可以覆盖设置为系统用户名的 user_id 吗?

寻找适用于 start_run 块的解决方案。

有任何想法吗?

with mlflow.start_run():

Run Code Online (Sandbox Code Playgroud)

cri*_*sal 0

start_run不支持user_id作为参数,并且它的 kwargs 实际上是 Run 标签,因此您需要使用其他函数。

为了完成您需要的操作,您必须为自己创建一个FileStore对象的运行,然后将这个新对象包装run在一个ActiveRun包装器中,在 with 块之后将自动完成作为参数传递的运行。

代码应该如下所示。

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
Run Code Online (Sandbox Code Playgroud)

  • 谢谢。我没能做到这一点。用以下命令破解它: ```python os.environ["LOGNAME"] = "username" ``` (2认同)