Skip to content

Commit

Permalink
fix(videointelligence): make features a positional parameter in `an…
Browse files Browse the repository at this point in the history
…notate_video`, update retry config, make AnnotateVideo nonidempotent (via synth) (#9440)
  • Loading branch information
yoshi-automation authored and busunkim96 committed Oct 28, 2019
1 parent 604f32d commit 9fd07ec
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ def __init__(
# Service calls
def annotate_video(
self,
features,
input_uri=None,
input_content=None,
features=None,
video_context=None,
output_uri=None,
location_id=None,
Expand All @@ -213,11 +213,11 @@ def annotate_video(
>>>
>>> client = videointelligence_v1.VideoIntelligenceServiceClient()
>>>
>>> input_uri = 'gs://cloud-samples-data/video/cat.mp4'
>>> features_element = enums.Feature.LABEL_DETECTION
>>> features = [features_element]
>>> input_uri = 'gs://cloud-samples-data/video/cat.mp4'
>>>
>>> response = client.annotate_video(input_uri=input_uri, features=features)
>>> response = client.annotate_video(features, input_uri=input_uri)
>>>
>>> def callback(operation_future):
... # Handle result.
Expand All @@ -229,6 +229,7 @@ def annotate_video(
>>> metadata = response.metadata()
Args:
features (list[~google.cloud.videointelligence_v1.types.Feature]): Required. Requested video annotation features.
input_uri (str): Input video location. Currently, only `Google Cloud
Storage <https://cloud.google.com/storage/>`__ URIs are supported, which
must be specified in the following format: ``gs://bucket-id/object-id``
Expand All @@ -241,7 +242,6 @@ def annotate_video(
request as ``input_content``. If set, ``input_content`` should be unset.
input_content (bytes): The video data bytes. If unset, the input video(s) should be specified
via ``input_uri``. If set, ``input_uri`` should be unset.
features (list[~google.cloud.videointelligence_v1.types.Feature]): Required. Requested video annotation features.
video_context (Union[dict, ~google.cloud.videointelligence_v1.types.VideoContext]): Additional video context and/or feature-specific parameters.
If a dict is provided, it must be of the same form as the protobuf
Expand Down Expand Up @@ -288,9 +288,9 @@ def annotate_video(
)

request = video_intelligence_pb2.AnnotateVideoRequest(
features=features,
input_uri=input_uri,
input_content=input_content,
features=features,
video_context=video_context,
output_uri=output_uri,
location_id=location_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
},
"retry_params": {
"default": {
"initial_retry_delay_millis": 1000,
"retry_delay_multiplier": 2.5,
"max_retry_delay_millis": 120000,
"initial_rpc_timeout_millis": 120000,
"initial_retry_delay_millis": 100,
"retry_delay_multiplier": 1.3,
"max_retry_delay_millis": 60000,
"initial_rpc_timeout_millis": 20000,
"rpc_timeout_multiplier": 1.0,
"max_rpc_timeout_millis": 120000,
"max_rpc_timeout_millis": 20000,
"total_timeout_millis": 600000,
}
},
"methods": {
"AnnotateVideo": {
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
}
},
Expand Down
12 changes: 6 additions & 6 deletions videointelligence/synth.metadata
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"updateTime": "2019-10-09T12:39:48.814274Z",
"updateTime": "2019-10-28T21:37:18.071018Z",
"sources": [
{
"generator": {
"name": "artman",
"version": "0.38.0",
"dockerImage": "googleapis/artman@sha256:0d2f8d429110aeb8d82df6550ef4ede59d40df9062d260a1580fce688b0512bf"
"version": "0.40.3",
"dockerImage": "googleapis/artman@sha256:c805f50525f5f557886c94ab76f56eaa09cb1da58c3ee95111fd34259376621a"
}
},
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "2dec8f98383214ad4fafa7680eb0cc46d6531976",
"internalRef": "273619851"
"sha": "3fb0873b5f8a4cf5be4f848d20e5ccb2bdee1a67",
"internalRef": "277134185"
}
},
{
"template": {
"name": "python_library",
"origin": "synthtool.gcp",
"version": "2019.5.2"
"version": "2019.10.17"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,17 @@ def test_annotate_video(self):
client = videointelligence_v1.VideoIntelligenceServiceClient()

# Setup Request
input_uri = "gs://cloud-samples-data/video/cat.mp4"
features_element = enums.Feature.LABEL_DETECTION
features = [features_element]
input_uri = "gs://cloud-samples-data/video/cat.mp4"

response = client.annotate_video(input_uri=input_uri, features=features)
response = client.annotate_video(features, input_uri=input_uri)
result = response.result()
assert expected_response == result

assert len(channel.requests) == 1
expected_request = video_intelligence_pb2.AnnotateVideoRequest(
input_uri=input_uri, features=features
features=features, input_uri=input_uri
)
actual_request = channel.requests[0][1]
assert expected_request == actual_request
Expand All @@ -114,10 +114,10 @@ def test_annotate_video_exception(self):
client = videointelligence_v1.VideoIntelligenceServiceClient()

# Setup Request
input_uri = "gs://cloud-samples-data/video/cat.mp4"
features_element = enums.Feature.LABEL_DETECTION
features = [features_element]
input_uri = "gs://cloud-samples-data/video/cat.mp4"

response = client.annotate_video(input_uri=input_uri, features=features)
response = client.annotate_video(features, input_uri=input_uri)
exception = response.exception()
assert exception.errors[0] == error

0 comments on commit 9fd07ec

Please sign in to comment.