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

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这个字段。该字段是在较新的版本中才被引入的。

  • 具体解决步骤

    1. 升级google-cloud-aiplatform到最新稳定版:
      pip install --upgrade google-cloud-aiplatform
      
    2. 验证版本:执行以下代码确认安装的版本(建议版本≥1.38.0,该版本首次引入该字段):
      import google.cloud.aiplatform
      print(google.cloud.aiplatform.__version__)
      
    3. 确认导入正确性:确保代码中导入的是aiplatform_v1下的ModelMonitoringAlertConfig,避免引用旧版本的类。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.21 15:45:56