调用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
相关产品推荐
相关产品推荐

