我正在尝试使用异步客户端库(该库也是由 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) 我正在尝试让 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
我正在 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
中是开箱即用的。