GCP中配置ModelMonitoringAlertConfig启用enable_logging报错,如何解决?
关于ModelMonitoringAlertConfig中enable_logging字段报错的问题
我尝试在ModelMonitoringAlertConfig中启用enable_logging,使用了以下Python代码:
from google.cloud import aiplatform_v1 as vertex_ai_beta ... alerting_config = vertex_ai_beta.ModelMonitoringAlertConfig( enable_logging=True, email_alert_config=vertex_ai_beta.ModelMonitoringAlertConfig.EmailAlertConfig( user_emails=NOTIFY_EMAILS ) )
运行后出现报错:
Unknown field for ModelMonitoringAlertConfig: enable_logging
官方文档显示该字段应当可用,我也尝试过使用aiplatform_v1beta1版本,请问问题出在哪里?
问题原因及解决办法
核心原因:库版本不兼容
官方文档展示的是最新版API的字段,但你本地安装的google-cloud-aiplatform库版本过低,还未加入enable_logging这个字段。该字段是在较新的版本中才被引入的。具体解决步骤
- 升级
google-cloud-aiplatform到最新稳定版:pip install --upgrade google-cloud-aiplatform - 验证版本:执行以下代码确认安装的版本(建议版本≥1.38.0,该版本首次引入该字段):
import google.cloud.aiplatform print(google.cloud.aiplatform.__version__) - 确认导入正确性:确保代码中导入的是
aiplatform_v1下的ModelMonitoringAlertConfig,避免引用旧版本的类。
- 升级
内容的提问来源于stack exchange,提问作者schoon
相关产品推荐
相关产品推荐

