标签: google-cloud-ai

为什么会失败并显示“'async for'需要一个具有 __aiter__ 方法的对象,得到协程”

我正在尝试使用异步客户端库(该库也是由 Google 提供)调用外部 API(由 Google 提供的 API)。

我尝试调用的异步方法是async list_featurestores()文档)。它提供了以下示例代码:

from google.cloud import aiplatform_v1

async def sample_list_featurestores():
    # Create a client
    client = aiplatform_v1.FeaturestoreServiceAsyncClient()

    # Initialize request argument(s)
    request = aiplatform_v1.ListFeaturestoresRequest(
        parent="parent_value",
    )

    # Make the request
    page_result = client.list_featurestores(request=request)

    # Handle the response
    async for response in page_result:
        print(response)
Run Code Online (Sandbox Code Playgroud)

(我已经从上面的链接页面复制/粘贴了该代码)。

为了运行该代码,我对其进行了稍微调整:

import asyncio
from google.cloud import aiplatform_v1

async def sample_list_featurestores():
    client = aiplatform_v1.FeaturestoreServiceAsyncClient()
    request = aiplatform_v1.ListFeaturestoresRequest(parent="projects/MY_GCP_PROJECT/locations/europe-west2",)
    page_result  = client.list_featurestores(request=request)
    async for response in page_result:
        print(response)


if …
Run Code Online (Sandbox Code Playgroud)

python python-asyncio google-cloud-ai

7
推荐指数
1
解决办法
6767
查看次数

google-cloud/aiplatform 顶点 AI 预测服务客户端截断响应 NodeJS

我正在尝试让 aiplatform 客户端在 NodeJS 项目上工作,它似乎有效,我的意思是凭据很好,并且我得到了“有效”响应。但是预测的内容被截断了(使用curl我得到了完整的列表),只有第一行出现在那里。我想知道我是否应该以不同的方式解析 IValues 或者什么。有人在 NodeJS 项目上成功集成了 AIPlatform 库吗?

这是脚本:

/**
 * TODO(developer): Uncomment these variables before running the sample.\
 * (Not necessary if passing values as arguments)
 */
import * as sdk from "@google-cloud/aiplatform";

const project = "generativeai-390315";
const loc = 'us-central1';

// Imports the Google Cloud Prediction service client
const { PredictionServiceClient } = sdk.v1;

// Import the helper module for converting arbitrary protobuf.Value objects.
const { helpers } = sdk;

const credentials = {
    client_email: …
Run Code Online (Sandbox Code Playgroud)

machine-learning node.js google-cloud-ai bart google-cloud-aiplatform

5
推荐指数
1
解决办法
979
查看次数

使用 Workload Identity 对 Kubernetes 上的 Cloud ML Engine 容器中的独立 gsutil 进行身份验证

我正在 Google Cloud AI Training (Cloud ML Engine) 上启动容器镜像

在这些容器中,我需要使用 gsutil。一些容器具有 gsutil。在这种情况下,我可以立即使用它而无需任何身份验证步骤。

有些容器没有 gsutil,所以我必须安装它。问题是安装的 gsutil 不起作用。

当我使用官方cloud-sdk图像时,gsutil无需任何身份验证步骤即可工作。

当我使用python:3.7图像并gsutil从 PyPI安装时,它不起作用:

python -m pip install gsutil --quiet
gsutil cp a gs://b/c
Run Code Online (Sandbox Code Playgroud)

ServiceException: 401 匿名调用者没有 storage.objects.get 访问...

我怎样才能让独立的 gsutil 获得所需的凭据?

大多数指南侧重于手动调用gcloud auth、复制 URL 和复制回令牌。这不是我寻求的解决方案(应该是自动化的)。我知道自动化解决方案是可能的,因为在某些图像gsutil中是开箱即用的。

gsutil kubernetes google-cloud-ml google-cloud-ai

4
推荐指数
1
解决办法
575
查看次数