gpt4 book ai didi

python-3.x - 属性错误 : module 'google.cloud.monitoring_v3.types' has no attribute 'MetricDescriptor'

转载 作者:行者123 更新时间:2023-12-02 02:35:48 32 4
gpt4 key购买 nike

我正在运行脚本以在 gcp 上创建 gpu 指标并收到以下错误:

AttributeError: 'MetricServiceClient' object has no attribute 'project_path'

AttributeError: module 'google.cloud.monitoring_v3.types' has no attribute 'MetricDescriptor'

最佳答案

项目路径

google-cloud-monitoring 的 2.0 版本图书馆包括一个breaking change这没有记录在更改日志中,但它包含在 upgrading guide 中. project_path函数重命名为 common_project_path .

Versions < 2.0.0

from google.cloud import monitoring_v3

client = monitoring_v3.MetricServiceClient()
project_path = client.project_path("project_id")

Versions >= 2.0.0

from google.cloud import monitoring_v3

client = monitoring_v3.MetricServiceClient()
project_path = client.common_project_path("project_id")

指标描述符

MetricDescriptor 类型看起来在 2.0.0 中移动了释放为好。它也包含在 upgrading guide 中(有一个不完整的片段)。

Versions < 2.0.0

from google.cloud import monitoring_v3

descriptor = monitoring_v3.types.MetricDescriptor()

Versions >= 2.0.0

from google.api import metric_pb2 as ga_metric

descriptor = ga_metric.MetricDescriptor()

关于python-3.x - 属性错误 : module 'google.cloud.monitoring_v3.types' has no attribute 'MetricDescriptor' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64337089/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com