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

调用MLflow client.create_model_version触发AttributeError错误求助

错误原因分析:AttributeError: 'str' object has no attribute 'items'

核心问题

错误根源是参数传递顺序不匹配,导致字符串被误当作字典处理:

  • 你调用client.create_model_version(MODEL_NAME, source, run_id, description)时使用了位置参数传递。
  • MLflow的create_model_version方法签名中,前三个必填参数是name、source、run_id,第四个参数是tags(要求字典类型),而description是第五个可选参数。
  • 你传入的字符串description被方法识别为tags参数,代码尝试对这个字符串执行字典专属的.items()方法,因此触发AttributeError。

修复方案

调用方法时显式指定参数名,彻底避免位置参数顺序错误:

client.create_model_version(
    name=MODEL_NAME,
    source=source,
    run_id=run_id,
    description=description
)

内容的提问来源于stack exchange,提问作者Jake Dodd

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.07 12:15:03