如何从getOperation响应中获取modelId?当我使用operationId运行getOperation()函数时,即使modelId为true,响应也不包含done。
我从这个问题开始尝试了所有的方法:How to programmatically get model id from google-cloud-automl with node.js client library
但是返回给我的响应是不同的。
我的函数:
exports.testOperationStatus = async function(operationId) {
// Construct request
const request = {
name: `projects/${projectId}/locations/${location}/operations/${operationId}`,
};
const [response] = await client.operationsClient.getOperation(request);
console.log(`Name: ${response.name}`);
console.log(`Operation details:`);
console.log(`${JSON.stringify(response, null, 2)}`);
}
我的回答是:
{
"name": "projects/projectId/locations/us-central1/operations/operationId”,
"metadata": {
"type_url": "type.googleapis.com/google.cloud.automl.v1.OperationMetadata",
"value": {
"type": "Buffer",
"data": […]
}
},
"done": true,
"response": {
"type_url": "type.googleapis.com/google.cloud.automl.v1.Model",
"value": {
"type": "Buffer",
"data": […]
}
},
"result": "response"
}
如何使用operationId获取modelId?
发布于 2020-07-29 07:46:20
我终于弄明白这个问题了!它返回带有模型Id的名称,作为“值”?内的缓冲区。为了提取模型Id,我必须这样做
const modelId = response.response.value.toString('utf8').replace(/projects\/[a-zA-Z0-9-]*\/locations\/[a-zA-Z0-9-]*\/models\//,''
https://stackoverflow.com/questions/62956141
复制相似问题