You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在MLflow中根据run name获取对应的run id

MLflow 查找特定运行对应 run id 的方法

方法1:通过UI界面获取

  • 运行列表页自定义列:点击列表顶部的「Columns」按钮,勾选「Run ID」选项,即可恢复在列表中显示所有运行的run id
  • 运行详情页查看:点击对应run name进入运行详情页,页面顶部直接显示run id,同时浏览器地址栏的URL中也会包含该run的id参数

方法2:通过Python API查询(适合代码自动化场景)

你可以通过run name作为筛选条件,直接调用MLflow接口查询,示例代码如下:

import mlflow

# 替换为你的MLflow跟踪服务地址,本地运行可省略
mlflow.set_tracking_uri("http://your-mlflow-tracking-uri:5000")

# 按run name筛选,可同时指定实验名称缩小范围
filter_str = "tags.mlflow.runName = '你要查询的run名称'"
runs_df = mlflow.search_runs(
    experiment_names=["你的实验名称"],
    filter_string=filter_str,
    order_by=["start_time DESC"] # 按运行时间倒序,优先返回最新的运行
)

# 提取run id
if not runs_df.empty:
    run_id = runs_df.iloc[0]["run_id"]
    print(f"查询到的run id为:{run_id}")

方法3:通过CLI命令行查询

直接在终端执行如下命令即可返回匹配条件的运行信息,其中包含run id:

mlflow runs list \
  --experiment-name 你的实验名称 \
  --filter "tags.mlflow.runName = '你要查询的run名称'" \
  --order-by start_time DESC

注意:MLflow的run name不强制唯一,若存在多个重名运行,建议额外添加参数、指标、运行时间等筛选条件,确保查询结果准确。

内容的提问来源于stack exchange,提问作者Anshul Raman

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.16 23:54:03