使用Google Cloud Documentai v1 -status Code =&quort'deadlineExceeded'批次处理文档时异常。
我使用docai使用docai batchprocessing将.pdf文件转换为文本。我创建了使用以下代码的控制台应用程序,该应用程序与单个文档合作正常。但是,当我尝试处理多个PDF文档时,它会引发异常,
grpc.core.rpcexception:'status code =“ deadlineexceeded”, 详细信息=“截止日期超过”, debugexception =“ grpc.core.internal.coreerrordetailexception: {“创建”:“@1650465671.748000000”,“ description”:“ deadline 超过“,” file”:“ ...................... \ src \ core \ ext \ ext \ ext \ ext \ decar \ decarline_filter.cc”,“ file_line”:81,“ grpc_status”:4}:4}”)'
应用程序代码:
public static class DocAIBatchProcess
{
const string projectId = "PROJECTID";
const string processorId = "PROCESSID";
const string location = "us";
const string gcsInputBucketName = "BUCKETNAME";
const string gcsOutputBucketName = "gs://BUCKETNAME/OUTPUTFOLDER/";
const string gcsOutputUriPrefix = "PREFIX";
const string prefix = "INPUTFOLDER/";
const string delimiter = "/";
public static bool BatchProcessDocument(this IEnumerable<GCPStorage.Object> storageObjects)
{
Console.WriteLine("\n");
Console.WriteLine("Processing documents started...");
Console.WriteLine("-------------------------------");
DocumentProcessorServiceClient documentProcessorServiceClient = DocumentProcessorServiceClient.Create();
string name = $"projects/{projectId}/locations/{location}/processors/{processorId}";
GcsDocument gcsDocument = null;
GcsDocuments gcsDocuments = new GcsDocuments();
var storage = StorageClient.Create();
foreach (var storageObject in storageObjects)
{
if (storageObject.Name != prefix)
{
gcsDocument = new GcsDocument()
{
GcsUri = $"gs://gcsInputBucketName/{storageObject.Name}",
MimeType = "application/pdf"
};
gcsDocuments.Documents.Add(gcsDocument);
}
}
//Input Config
BatchDocumentsInputConfig inputConfig = new BatchDocumentsInputConfig();
inputConfig.GcsDocuments = gcsDocuments;
//Output Config
var fullGcsPath = $"gs://{gcsOutputBucketName}/{gcsOutputUriPrefix}/";
GcsOutputConfig gcsOutputConfig = new GcsOutputConfig();
gcsOutputConfig.GcsUri = gcsOutputBucketName;
DocumentOutputConfig documentOutputConfig = new DocumentOutputConfig();
documentOutputConfig.GcsOutputConfig = gcsOutputConfig;
// Configure the batch process request.
BatchProcessRequest batchProcessRequest = new BatchProcessRequest();
batchProcessRequest.Name = name;
batchProcessRequest.InputDocuments = inputConfig;
batchProcessRequest.DocumentOutputConfig = documentOutputConfig;
// Make the request
Operation<BatchProcessResponse, BatchProcessMetadata> response = documentProcessorServiceClient.BatchProcessDocuments(batchProcessRequest);
// Poll until the returned long-running operation is complete
Operation<BatchProcessResponse, BatchProcessMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
BatchProcessResponse result = completedResponse.Result;
}
}
deadlineExceeded:“截止日期在操作完成之前已过期。”
我试图研究文档,但找不到任何混乱。如果有人知道为什么会发生这种情况?任何帮助将不胜感激。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于我来说,这个问题与网络防火墙有关。我的网络团队只是把我带出防火墙,它没有任何问题。谢谢
This issue is related to network firewall for me. my network team just put me out of firewall and it worked without any issue. thanks