我得到了一个非常类似于下面的错误,但我不在欧盟:core.exceptions.InvalidArgument: 400请求包含一个无效的参数
当我使用raw_document并处理本地pdf文件时,它工作得很好。但是,当我在GCS位置上指定一个pdf文件时,它会失败。
错误消息:
the processor name: projects/xxxxxxxxx/locations/us/processors/f7502cad4bccdd97
the form process request: name: "projects/xxxxxxxxx/locations/us/processors/f7502cad4bccdd97"
inline_document {
uri: "gs://xxxx/temp/test1.pdf"
}
Traceback (most recent call last):
File "C:\Python39\lib\site-packages\google\api_core\grpc_helpers.py", line 66, in error_remapped_callable
return callable_(*args, **kwargs)
File "C:\Python39\lib\site-packages\grpc\_channel.py", line 946, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "C:\Python39\lib\site-packages\grpc\_channel.py", line 849, in _end_unary_response_blocking
raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.INVALID_ARGUMENT
details = "Request contains an invalid argument."
debug_error_string = "{"created":"@1647296055.582000000","description":"Error received from peer ipv4:142.250.80.74:443","file":"src/core/lib/surface/call.cc","file_line":1070,"grpc_message":"Request contains an invalid argument.","grpc_status":3}"
>代码:
client = documentai.DocumentProcessorServiceClient(client_options=opts)
# The full resource name of the processor, e.g.:
# projects/project-id/locations/location/processor/processor-id
# You must create new processors in the Cloud Console first
name = f"projects/{project_id}/locations/{location}/processors/{processor_id}"
print(f'the processor name: {name}')
# document = {"uri": gcs_path, "mime_type": "application/pdf"}
document = {"uri": gcs_path}
inline_document = documentai.Document()
inline_document.uri = gcs_path
# inline_document.mime_type = "application/pdf"
# Configure the process request
# request = {"name": name, "inline_document": document}
request = documentai.ProcessRequest(
inline_document=inline_document,
name=name
)
print(f'the form process request: {request}')
result = client.process_document(request=request)我不认为我在存储桶上有权限问题,因为相同的设置对于同一桶上的文档分类过程很好。
发布于 2022-03-15 03:52:43
发布于 2022-08-23 03:11:29
这在5个月后仍然是一个问题,在接受的答案中没有提到的是(我可能错了,但在我看来)批处理只能将它们的结果输出到GCS,所以仍然需要额外的步骤从桶中下载一些东西(不管是选项1下的输入文档,还是选项2下的结果)。更重要的是,如果您不想获得结果,您将不得不在桶中进行清理,因此,在许多情况下,除了结果下载可能小于输入文件下载之外,选项2不会带来太大的优势。
我在Python函数中使用客户端库,并且受到这个问题的影响。我之所以实现选项1,是因为它看起来很简单,而且我一直在等待修复。我还考虑过使用工作流程客户端库来触发运行文档AI进程的工作流,或者调用Document,但这一切都不是最优的。
https://stackoverflow.com/questions/71474905
复制相似问题