使用Google Cloud Documentai v1 -status Code =&quort'deadlineExceeded'批次处理文档时异常。

发布于 2025-01-23 05:29:06 字数 3885 浏览 4 评论 0 原文

我正在尝试使用

我使用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:“截止日期在操作完成之前已过期。”

我试图研究文档,但找不到任何混乱。如果有人知道为什么会发生这种情况?任何帮助将不胜感激。

I am trying to create PoC for Google Cloud DocumentAI V1 using this

I am using DocAI to convert .pdf files into text using DocAI BatchProcessing. I have created console application with below code, which is working fine with single document. But when I try to process multiple pdf documents it's throwing exception,

Grpc.Core.RpcException: 'Status(StatusCode="DeadlineExceeded",
Detail="Deadline Exceeded",
DebugException="Grpc.Core.Internal.CoreErrorDetailException:
{"created":"@1650465671.748000000","description":"Deadline
Exceeded","file":"......\src\core\ext\filters\deadline\deadline_filter.cc","file_line":81,"grpc_status":4}")'

enter image description here

Application Code:

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 = 
quot;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 = 
quot;gs://gcsInputBucketName/{storageObject.Name}",
                        MimeType = "application/pdf"
                    };
                    gcsDocuments.Documents.Add(gcsDocument);
                }
            }

            //Input Config
            BatchDocumentsInputConfig inputConfig = new BatchDocumentsInputConfig();
            inputConfig.GcsDocuments = gcsDocuments;

            //Output Config
            var fullGcsPath = 
quot;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 : "Deadline expired before operation could complete."

I tried looking into documentation but couldn't find anything concreate. If someone knows about why this is happening ? Any assistance would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情话墙 2025-01-30 05:29:06

对于我来说,这个问题与网络防火墙有关。我的网络团队只是把我带出防火墙,它没有任何问题。谢谢

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文