我正在尝试 Cloud Healthcare API GitHub 教程上的 AutoML Vision of ML Codelabs。 https://github.com/GoogleCloudPlatform/healthcare/blob/master/imaging/ml_codelab/breast_density_auto_ml.ipynb
我运行了将DICOM转换为JPEG部分的导出DICOM数据单元代码,并且请求以及所有前提单元代码都成功了。
但是等待操作完成会超时,并且永远不会完成。 (数据集页面上的导出 DicomData 请求状态在一天内保持"正在运行"。我做了很多次,但所有请求都堆叠在一起保持"正在运行"。有几次我尝试从头开始,结果是一样的。
到目前为止,我做到了:
1(删除"output_config",因为发生无效参数错误。 https://github.com/GoogleCloudPlatform/healthcare/issues/133
2( 根据需要启用云资源管理器 API。
这是单元格代码。
# Path to export DICOM data.
dicom_store_url = os.path.join(HEALTHCARE_API_URL, 'projects', project_id, 'locations', location, 'datasets', dataset_id, 'dicomStores', dicom_store_id)
path = dicom_store_url + ":export"
# Headers (send request in JSON format).
headers = {'Content-Type': 'application/json'}
# Body (encoded in JSON format).
# output_config = {'output_config': {'gcs_destination': {'uri_prefix': jpeg_folder, 'mime_type': 'image/jpeg; transfer-syntax=1.2.840.10008.1.2.4.50'}}}
output_config = {'gcs_destination': {'uri_prefix': jpeg_folder, 'mime_type': 'image/jpeg; transfer-syntax=1.2.840.10008.1.2.4.50'}}
body = json.dumps(output_config)
resp, content = http.request(path, method='POST', headers=headers, body=body)
assert resp.status == 200, 'error exporting to JPEG, code: {0}, response: {1}'.format(resp.status, content)
print('Full response:n{0}'.format(content))
# Record operation_name so we can poll for it later.
response = json.loads(content)
operation_name = response['name']
这是等待的结果。
Waiting for operation completion...
Full response:
{
"name": "projects/my-datalab-tutorials/locations/us-central1/datasets/sample-dataset/operations/18300485449992372225",
"metadata": {
"@type": "type.googleapis.com/google.cloud.healthcare.v1beta1.OperationMetadata",
"apiMethodName": "google.cloud.healthcare.v1beta1.dicom.DicomService.ExportDicomData",
"createTime": "2019-08-18T10:37:49.809136Z"
}
}
AssertionErrorTraceback (most recent call last)
<ipython-input-18-1a57fd38ea96> in <module>()
21 timeout = time.time() + 10*60 # Wait up to 10 minutes.
22 path = os.path.join(HEALTHCARE_API_URL, operation_name)
---> 23 _ = wait_for_operation_completion(path, timeout)
<ipython-input-18-1a57fd38ea96> in wait_for_operation_completion(path, timeout)
15
16 print('Full response:n{0}'.format(content))
---> 17 assert success, "operation did not complete successfully in time limit"
18 print('Success!')
19 return response
AssertionError: operation did not complete successfully in time limit
API 版本为 v1beta1。
我想知道是否有人有任何建议。
谢谢。
经过几次不断尝试并坚持运行了一个晚上,它终于成功了。我不知道为什么。
Codelabs 最近进行了更新。错误消息是由于 Codelab 中的超时,而不是实际操作造成的。此问题已在更新中得到解决。如果您仍然遇到任何问题,请告诉我!