Score:0

Exception while batch processing document with Google Cloud DocumentAI V1 - StatusCode="DeadlineExceeded"

in flag

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}")'

    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 : "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.

Kabilan Mohanraj avatar
th flag
Hello. This question seems to be [off-topic](https://serverfault.com/help/on-topic) for Server Fault. Stack Overflow would be the right forum to ask since it is a programming question. I was able to find the question you have created on Stack Overflow -> https://stackoverflow.com/questions/71941998
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.