Rock
Rock

Reputation: 13

google.gax.errors.RetryError StatusCode.DEADLINE_EXCEEDED

from this github: https://github.com/GoogleCloudPlatform/python-docs-samples

i am trying to test Video intelligence API and do label analysis.

import argparse
import sys
import time
import io
import base64

from google.cloud.gapic.videointelligence.v1beta1 import enums
from google.cloud.gapic.videointelligence.v1beta1 import (
    video_intelligence_service_client)
# [END imports]


#python labels.py /Users/rockbaek/tildawatch-contents/EpicSkillShot/M7-_VukSueY/SKT\ vs\ KT\ Game\ 3\ _\ Grand\ Finals\ S7\ LCK\ Spring\ 2017\ _\ KT\ Rolster\ vs\ SK\ Telecom\ T1\ G3\ 1080p-M7-_VukSueY.mp4

def analyze_labels_file(path):
    """ Detects labels given a file path. """
    video_client = (video_intelligence_service_client.
                    VideoIntelligenceServiceClient())
    features = [enums.Feature.LABEL_DETECTION]

    with io.open(path, "rb") as movie:
        content_base64 = base64.b64encode(movie.read())

    operation = video_client.annotate_video(
        '', features, input_content=content_base64)
    print('\nProcessing video for label annotations:')

    while not operation.done():
        sys.stdout.write('.')
        sys.stdout.flush()
        time.sleep(15)

    print('\nFinished processing.')

    # first result is retrieved because a single video was processed
    results = operation.result().annotation_results[0]

    for i, label in enumerate(results.label_annotations):
        print('Label description: {}'.format(label.description))
        print('Locations:')

        for l, location in enumerate(label.locations):
            positions = 'Entire video'
            if (location.segment.start_time_offset != -1 or
                    location.segment.end_time_offset != -1):
                positions = '{} to {}'.format(
                    location.segment.start_time_offset / 1000000.0,
                    location.segment.end_time_offset / 1000000.0)
            print('\t{}: {}'.format(l, positions))

        print('\n')

if __name__ == '__main__':
    # [START running_app]
    parser = argparse.ArgumentParser(
        description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter)
    parser.add_argument('path', help='GCS file path for label detection.')
    args = parser.parse_args()

    analyze_labels_file(args.path)
# [END running_app]
# [END full_tutorial]

and then i run it from terminal python labels.py MP4_FILE_PATH

After quite a while, it fails with this error code:

Traceback (most recent call last):
  File "labels.py", line 123, in <module>
    analyze_labels_file(args.path)
  File "labels.py", line 52, in analyze_labels_file
    '', features, input_content=content_base64)
  File "/Library/Python/2.7/site-packages/google/cloud/gapic/videointelligence/v1beta1/video_intelligence_service_client.py", line 237, in annotate_video
    self._annotate_video(request, options), self.operations_client,
  File "/Library/Python/2.7/site-packages/google/gax/api_callable.py", line 428, in inner
    return api_caller(api_call, this_settings, request)
  File "/Library/Python/2.7/site-packages/google/gax/api_callable.py", line 416, in base_caller
    return api_call(*args)
  File "/Library/Python/2.7/site-packages/google/gax/api_callable.py", line 376, in inner
    return a_func(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/google/gax/retry.py", line 144, in inner
    raise exc
google.gax.errors.RetryError: GaxError(Retry total timeout exceeded with exception, caused by <_Rendezvous of RPC that terminated with (StatusCode.DEADLINE_EXCEEDED, Deadline Exceeded)>)

Please help why it is not working! :(

Upvotes: 1

Views: 689

Answers (2)

kmonsoor
kmonsoor

Reputation: 8119

For the visitors from future, I faced same error with Cloud Speech API.

I just increased the timeout value while calling operation.result. That solved it. Though this fragment isn't in OP's code, it should be in Google's example code OP mentioned.

operation.result(timeout=90)   # increase this numeric value

Upvotes: 1

florence Perot
florence Perot

Reputation: 1

I tried your code with a small video and it seems to work just fine for me. Maybe you are hitting some form of quota or limits (refer: https://cloud-dot-devsite.googleplex.com/video-intelligence/limits)? I have also run large videos loaded in Google Storage and using Python client library without issue.

Other step to try: send the request to the service via a curl command.

Upvotes: 0

Related Questions