From 92992da8010dde7485fb8338a7ac7a70301960a6 Mon Sep 17 00:00:00 2001 From: Nicholas Cook Date: Mon, 24 Jan 2022 12:26:38 -0800 Subject: [PATCH 01/86] chore: move samples from GoogleCloudPlatform/python-docs-samples (#125) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: move samples from GoogleCloudPlatform/python-docs-samples * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- video/transcoder/README.md | 40 ++ video/transcoder/create_job_from_ad_hoc.py | 118 +++++ video/transcoder/create_job_from_preset.py | 82 ++++ video/transcoder/create_job_from_template.py | 86 ++++ video/transcoder/create_job_template.py | 115 +++++ .../create_job_with_animated_overlay.py | 148 +++++++ .../create_job_with_concatenated_inputs.py | 195 +++++++++ ...te_job_with_periodic_images_spritesheet.py | 128 ++++++ ..._job_with_set_number_images_spritesheet.py | 131 ++++++ .../create_job_with_static_overlay.py | 141 ++++++ video/transcoder/delete_job.py | 56 +++ video/transcoder/delete_job_template.py | 58 +++ video/transcoder/get_job.py | 57 +++ video/transcoder/get_job_state.py | 58 +++ video/transcoder/get_job_template.py | 58 +++ video/transcoder/job_template_test.py | 60 +++ video/transcoder/job_test.py | 410 ++++++++++++++++++ video/transcoder/list_job_templates.py | 59 +++ video/transcoder/list_jobs.py | 57 +++ video/transcoder/noxfile.py | 278 ++++++++++++ video/transcoder/requirements-test.txt | 3 + video/transcoder/requirements.txt | 3 + 22 files changed, 2341 insertions(+) create mode 100644 video/transcoder/README.md create mode 100644 video/transcoder/create_job_from_ad_hoc.py create mode 100644 video/transcoder/create_job_from_preset.py create mode 100644 video/transcoder/create_job_from_template.py create mode 100644 video/transcoder/create_job_template.py create mode 100644 video/transcoder/create_job_with_animated_overlay.py create mode 100644 video/transcoder/create_job_with_concatenated_inputs.py create mode 100644 video/transcoder/create_job_with_periodic_images_spritesheet.py create mode 100644 video/transcoder/create_job_with_set_number_images_spritesheet.py create mode 100644 video/transcoder/create_job_with_static_overlay.py create mode 100644 video/transcoder/delete_job.py create mode 100644 video/transcoder/delete_job_template.py create mode 100644 video/transcoder/get_job.py create mode 100644 video/transcoder/get_job_state.py create mode 100644 video/transcoder/get_job_template.py create mode 100644 video/transcoder/job_template_test.py create mode 100644 video/transcoder/job_test.py create mode 100644 video/transcoder/list_job_templates.py create mode 100644 video/transcoder/list_jobs.py create mode 100644 video/transcoder/noxfile.py create mode 100644 video/transcoder/requirements-test.txt create mode 100644 video/transcoder/requirements.txt diff --git a/video/transcoder/README.md b/video/transcoder/README.md new file mode 100644 index 00000000000..ce4ff9588db --- /dev/null +++ b/video/transcoder/README.md @@ -0,0 +1,40 @@ +# Transcoder API Python Samples + +This directory contains samples for the Transcoder API. Use this API to transcode videos into a variety of formats. The Transcoder API benefits broadcasters, production companies, businesses, and individuals looking to transform their video content for use across a variety of user devices. For more information, see the [Transcoder API documentation](https://cloud.google.com/transcoder/). + +## Setup + +To run the samples, you need to first follow the steps in [Before you begin](https://cloud.google.com/transcoder/docs/how-to/before-you-begin). + +For more information on authentication, refer to the +[Authentication Getting Started Guide](https://cloud.google.com/docs/authentication/getting-started). + +## Install Dependencies + +1. Clone python-docs-samples and change directory to the sample directory you want to use. + + $ git clone https://github.com/googleapis/python-video-transcoder.git + +1. Install [pip](https://pip.pypa.io/) and [virtualenv](https://virtualenv.pypa.io/) if you do not already have them. You may want to refer to the [Python Development Environment Setup Guide](https://cloud.google.com/python/setup) for Google Cloud Platform for instructions. + +1. Create a virtualenv. Samples are compatible with Python 3.6+. + + $ virtualenv env + $ source env/bin/activate + +1. Install the dependencies needed to run the samples. + + $ pip install -r requirements.txt + +## The client library + +This sample uses the [Google Cloud Client Library for Python](https://googlecloudplatform.github.io/google-cloud-python/). +You can read the documentation for more details on API usage and use GitHub +to [browse the source](https://github.com/GoogleCloudPlatform/google-cloud-python) and [report issues](https://github.com/GoogleCloudPlatform/google-cloud-python/issues). + +## Testing + +Make sure to enable the Transcoder API on the test project. Set the following environment variables: + +* `GOOGLE_CLOUD_PROJECT` +* `GOOGLE_CLOUD_PROJECT_NUMBER` diff --git a/video/transcoder/create_job_from_ad_hoc.py b/video/transcoder/create_job_from_ad_hoc.py new file mode 100644 index 00000000000..2e08c612c2f --- /dev/null +++ b/video/transcoder/create_job_from_ad_hoc.py @@ -0,0 +1,118 @@ +#!/usr/bin/env python + +# Copyright 2020 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Transcoder sample for creating a job based on a supplied job config. + +Example usage: + python create_job_from_ad_hoc.py --project_id --location --input_uri --output_uri +""" + +# [START transcoder_create_job_from_ad_hoc] + +import argparse + +from google.cloud.video import transcoder_v1 +from google.cloud.video.transcoder_v1.services.transcoder_service import ( + TranscoderServiceClient, +) + + +def create_job_from_ad_hoc(project_id, location, input_uri, output_uri): + """Creates a job based on an ad-hoc job configuration. + + Args: + project_id: The GCP project ID. + location: The location to start the job in. + input_uri: Uri of the video in the Cloud Storage bucket. + output_uri: Uri of the video output folder in the Cloud Storage bucket.""" + + client = TranscoderServiceClient() + + parent = f"projects/{project_id}/locations/{location}" + job = transcoder_v1.types.Job() + job.input_uri = input_uri + job.output_uri = output_uri + job.config = transcoder_v1.types.JobConfig( + elementary_streams=[ + transcoder_v1.types.ElementaryStream( + key="video-stream0", + video_stream=transcoder_v1.types.VideoStream( + h264=transcoder_v1.types.VideoStream.H264CodecSettings( + height_pixels=360, + width_pixels=640, + bitrate_bps=550000, + frame_rate=60, + ), + ), + ), + transcoder_v1.types.ElementaryStream( + key="video-stream1", + video_stream=transcoder_v1.types.VideoStream( + h264=transcoder_v1.types.VideoStream.H264CodecSettings( + height_pixels=720, + width_pixels=1280, + bitrate_bps=2500000, + frame_rate=60, + ), + ), + ), + transcoder_v1.types.ElementaryStream( + key="audio-stream0", + audio_stream=transcoder_v1.types.AudioStream( + codec="aac", bitrate_bps=64000 + ), + ), + ], + mux_streams=[ + transcoder_v1.types.MuxStream( + key="sd", + container="mp4", + elementary_streams=["video-stream0", "audio-stream0"], + ), + transcoder_v1.types.MuxStream( + key="hd", + container="mp4", + elementary_streams=["video-stream1", "audio-stream0"], + ), + ], + ) + response = client.create_job(parent=parent, job=job) + print(f"Job: {response.name}") + return response + + +# [END transcoder_create_job_from_ad_hoc] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", help="The location to start this job in.", default="us-central1", + ) + parser.add_argument( + "--input_uri", + help="Uri of the video in the Cloud Storage bucket.", + required=True, + ) + parser.add_argument( + "--output_uri", + help="Uri of the video output folder in the Cloud Storage bucket. Must end in '/'.", + required=True, + ) + args = parser.parse_args() + create_job_from_ad_hoc( + args.project_id, args.location, args.input_uri, args.output_uri, + ) diff --git a/video/transcoder/create_job_from_preset.py b/video/transcoder/create_job_from_preset.py new file mode 100644 index 00000000000..3539b32550e --- /dev/null +++ b/video/transcoder/create_job_from_preset.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python + +# Copyright 2020 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Transcoder sample for creating a job based on a job preset. + +Example usage: + python create_job_from_preset.py --project_id --location --input_uri --output_uri [--preset ] +""" + +# [START transcoder_create_job_from_preset] + +import argparse + +from google.cloud.video import transcoder_v1 +from google.cloud.video.transcoder_v1.services.transcoder_service import ( + TranscoderServiceClient, +) + + +def create_job_from_preset(project_id, location, input_uri, output_uri, preset): + """Creates a job based on a job preset. + + Args: + project_id: The GCP project ID. + location: The location to start the job in. + input_uri: Uri of the video in the Cloud Storage bucket. + output_uri: Uri of the video output folder in the Cloud Storage bucket. + preset: The preset template (for example, 'preset/web-hd').""" + + client = TranscoderServiceClient() + + parent = f"projects/{project_id}/locations/{location}" + job = transcoder_v1.types.Job() + job.input_uri = input_uri + job.output_uri = output_uri + job.template_id = preset + + response = client.create_job(parent=parent, job=job) + print(f"Job: {response.name}") + return response + + +# [END transcoder_create_job_from_preset] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", help="The location to start this job in.", default="us-central1", + ) + parser.add_argument( + "--input_uri", + help="Uri of the video in the Cloud Storage bucket.", + required=True, + ) + parser.add_argument( + "--output_uri", + help="Uri of the video output folder in the Cloud Storage bucket. Must end in '/'.", + required=True, + ) + parser.add_argument( + "--preset", + help="The preset template (for example, 'preset/web-hd').", + default="preset/web-hd", + ) + args = parser.parse_args() + create_job_from_preset( + args.project_id, args.location, args.input_uri, args.output_uri, args.preset, + ) diff --git a/video/transcoder/create_job_from_template.py b/video/transcoder/create_job_from_template.py new file mode 100644 index 00000000000..0a69704a440 --- /dev/null +++ b/video/transcoder/create_job_from_template.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python + +# Copyright 2020 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Transcoder sample for creating a job based on a job template. + +Example usage: + python create_job_from_template.py --project_id --location --input_uri --output_uri --template_id +""" + +# [START transcoder_create_job_from_template] + +import argparse + +from google.cloud.video import transcoder_v1 +from google.cloud.video.transcoder_v1.services.transcoder_service import ( + TranscoderServiceClient, +) + + +def create_job_from_template(project_id, location, input_uri, output_uri, template_id): + """Creates a job based on a job template. + + Args: + project_id: The GCP project ID. + location: The location to start the job in. + input_uri: Uri of the video in the Cloud Storage bucket. + output_uri: Uri of the video output folder in the Cloud Storage bucket. + template_id: The user-defined template ID.""" + + client = TranscoderServiceClient() + + parent = f"projects/{project_id}/locations/{location}" + job = transcoder_v1.types.Job() + job.input_uri = input_uri + job.output_uri = output_uri + job.template_id = template_id + + response = client.create_job(parent=parent, job=job) + print(f"Job: {response.name}") + return response + + +# [END transcoder_create_job_from_template] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", help="The location to start this job in.", default="us-central1", + ) + parser.add_argument( + "--input_uri", + help="Uri of the video in the Cloud Storage bucket.", + required=True, + ) + parser.add_argument( + "--output_uri", + help="Uri of the video output folder in the Cloud Storage bucket. Must end in '/'.", + required=True, + ) + parser.add_argument( + "--template_id", + help="The job template ID. The template must be located in the same location as the job.", + required=True, + ) + args = parser.parse_args() + create_job_from_template( + args.project_id, + args.location, + args.input_uri, + args.output_uri, + args.template_id, + ) diff --git a/video/transcoder/create_job_template.py b/video/transcoder/create_job_template.py new file mode 100644 index 00000000000..95ed05d8409 --- /dev/null +++ b/video/transcoder/create_job_template.py @@ -0,0 +1,115 @@ +#!/usr/bin/env python + +# Copyright 2020 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Transcoder sample for creating a job template. + +Example usage: + python create_job_template.py --project_id [--location ] [--template_id ] +""" + +# [START transcoder_create_job_template] + +import argparse + +from google.cloud.video import transcoder_v1 +from google.cloud.video.transcoder_v1.services.transcoder_service import ( + TranscoderServiceClient, +) + + +def create_job_template(project_id, location, template_id): + """Creates a job template. + + Args: + project_id: The GCP project ID. + location: The location to store this template in. + template_id: The user-defined template ID.""" + + client = TranscoderServiceClient() + + parent = f"projects/{project_id}/locations/{location}" + + job_template = transcoder_v1.types.JobTemplate() + job_template.name = ( + f"projects/{project_id}/locations/{location}/jobTemplates/{template_id}" + ) + job_template.config = transcoder_v1.types.JobConfig( + elementary_streams=[ + transcoder_v1.types.ElementaryStream( + key="video-stream0", + video_stream=transcoder_v1.types.VideoStream( + h264=transcoder_v1.types.VideoStream.H264CodecSettings( + height_pixels=360, + width_pixels=640, + bitrate_bps=550000, + frame_rate=60, + ), + ), + ), + transcoder_v1.types.ElementaryStream( + key="video-stream1", + video_stream=transcoder_v1.types.VideoStream( + h264=transcoder_v1.types.VideoStream.H264CodecSettings( + height_pixels=720, + width_pixels=1280, + bitrate_bps=2500000, + frame_rate=60, + ), + ), + ), + transcoder_v1.types.ElementaryStream( + key="audio-stream0", + audio_stream=transcoder_v1.types.AudioStream( + codec="aac", bitrate_bps=64000 + ), + ), + ], + mux_streams=[ + transcoder_v1.types.MuxStream( + key="sd", + container="mp4", + elementary_streams=["video-stream0", "audio-stream0"], + ), + transcoder_v1.types.MuxStream( + key="hd", + container="mp4", + elementary_streams=["video-stream1", "audio-stream0"], + ), + ], + ) + + response = client.create_job_template( + parent=parent, job_template=job_template, job_template_id=template_id + ) + print(f"Job template: {response.name}") + return response + + +# [END transcoder_create_job_template] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", + help="The location to store this template in.", + default="us-central1", + ) + parser.add_argument( + "--template_id", help="The job template ID.", default="my-job-template" + ) + args = parser.parse_args() + create_job_template(args.project_id, args.location, args.template_id) diff --git a/video/transcoder/create_job_with_animated_overlay.py b/video/transcoder/create_job_with_animated_overlay.py new file mode 100644 index 00000000000..a90c542efa5 --- /dev/null +++ b/video/transcoder/create_job_with_animated_overlay.py @@ -0,0 +1,148 @@ +#!/usr/bin/env python + +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Transcoder sample for creating a job based on a supplied job config that includes an animated overlay. + +Example usage: + python create_job_with_animated_overlay.py --project_id --location --input_uri --overlay_image_uri --output_uri +""" + +# [START transcoder_create_job_with_animated_overlay] + +import argparse + +from google.cloud.video import transcoder_v1 +from google.cloud.video.transcoder_v1.services.transcoder_service import ( + TranscoderServiceClient, +) +from google.protobuf import duration_pb2 as duration + + +def create_job_with_animated_overlay( + project_id, location, input_uri, overlay_image_uri, output_uri +): + """Creates a job based on an ad-hoc job configuration that includes an animated image overlay. + + Args: + project_id: The GCP project ID. + location: The location to start the job in. + input_uri: Uri of the video in the Cloud Storage bucket. + overlay_image_uri: Uri of the JPEG image for the overlay in the Cloud Storage bucket. Must be a JPEG. + output_uri: Uri of the video output folder in the Cloud Storage bucket.""" + + client = TranscoderServiceClient() + + parent = f"projects/{project_id}/locations/{location}" + job = transcoder_v1.types.Job() + job.input_uri = input_uri + job.output_uri = output_uri + job.config = transcoder_v1.types.JobConfig( + elementary_streams=[ + transcoder_v1.types.ElementaryStream( + key="video-stream0", + video_stream=transcoder_v1.types.VideoStream( + h264=transcoder_v1.types.VideoStream.H264CodecSettings( + height_pixels=360, + width_pixels=640, + bitrate_bps=550000, + frame_rate=60, + ), + ), + ), + transcoder_v1.types.ElementaryStream( + key="audio-stream0", + audio_stream=transcoder_v1.types.AudioStream( + codec="aac", bitrate_bps=64000 + ), + ), + ], + mux_streams=[ + transcoder_v1.types.MuxStream( + key="sd", + container="mp4", + elementary_streams=["video-stream0", "audio-stream0"], + ), + ], + overlays=[ + transcoder_v1.types.Overlay( + image=transcoder_v1.types.Overlay.Image( + uri=overlay_image_uri, + resolution=transcoder_v1.types.Overlay.NormalizedCoordinate( + x=0, y=0, + ), + alpha=1, + ), + animations=[ + transcoder_v1.types.Overlay.Animation( + animation_fade=transcoder_v1.types.Overlay.AnimationFade( + fade_type=transcoder_v1.types.Overlay.FadeType.FADE_IN, + xy=transcoder_v1.types.Overlay.NormalizedCoordinate( + x=0.5, y=0.5, + ), + start_time_offset=duration.Duration(seconds=5,), + end_time_offset=duration.Duration(seconds=10,), + ), + ), + transcoder_v1.types.Overlay.Animation( + animation_fade=transcoder_v1.types.Overlay.AnimationFade( + fade_type=transcoder_v1.types.Overlay.FadeType.FADE_OUT, + xy=transcoder_v1.types.Overlay.NormalizedCoordinate( + x=0.5, y=0.5, + ), + start_time_offset=duration.Duration(seconds=12,), + end_time_offset=duration.Duration(seconds=15,), + ), + ), + ], + ), + ], + ) + response = client.create_job(parent=parent, job=job) + print(f"Job: {response.name}") + return response + + +# [END transcoder_create_job_with_animated_overlay] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", help="The location to start this job in.", default="us-central1", + ) + parser.add_argument( + "--input_uri", + help="Uri of the video in the Cloud Storage bucket.", + required=True, + ) + parser.add_argument( + "--overlay_image_uri", + help="Uri of the overlay JPEG image in the Cloud Storage bucket. Must be a JPEG.", + required=True, + ) + parser.add_argument( + "--output_uri", + help="Uri of the video output folder in the Cloud Storage bucket. Must end in '/'.", + required=True, + ) + args = parser.parse_args() + create_job_with_animated_overlay( + args.project_id, + args.location, + args.input_uri, + args.overlay_image_uri, + args.output_uri, + ) diff --git a/video/transcoder/create_job_with_concatenated_inputs.py b/video/transcoder/create_job_with_concatenated_inputs.py new file mode 100644 index 00000000000..0a2d3ad8ba7 --- /dev/null +++ b/video/transcoder/create_job_with_concatenated_inputs.py @@ -0,0 +1,195 @@ +#!/usr/bin/env python + +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Transcoder sample for creating a job based on concatenating two input videos. + +Example usage: + python create_job_with_concatenated_inputs.py --project_id --location \ + --input1_uri --start_time_input1 --end_time_input1 \ + --input2_uri --start_time_input2 --end_time_input2 \ + --output_uri +""" + +# [START transcoder_create_job_with_concatenated_inputs] + +import argparse + +from google.cloud.video import transcoder_v1 +from google.cloud.video.transcoder_v1.services.transcoder_service import ( + TranscoderServiceClient, +) +from google.protobuf import duration_pb2 as duration + + +def create_job_with_concatenated_inputs( + project_id, + location, + input1_uri, + start_time_input1, + end_time_input1, + input2_uri, + start_time_input2, + end_time_input2, + output_uri, +): + """Creates a job based on an ad-hoc job configuration that concatenates two input videos. + + Args: + project_id (str): The GCP project ID. + location (str): The location to start the job in. + input1_uri (str): Uri of the first video in the Cloud Storage bucket. + start_time_input1 (str): Start time, in fractional seconds ending in 's' + (e.g., '0s'), relative to the first input video timeline. + end_time_input1 (str): End time, in fractional seconds ending in 's' + (e.g., '8.1s'), relative to the first input video timeline. + input2_uri (str): Uri of the second video in the Cloud Storage bucket. + start_time_input2 (str): Start time, in fractional seconds ending in 's' + (e.g., '3.5s'), relative to the second input video timeline. + end_time_input2 (str): End time, in fractional seconds ending in 's' + (e.g., '15s'), relative to the second input video timeline. + output_uri (str): Uri of the video output folder in the Cloud Storage + bucket.""" + + s1 = duration.Duration() + s1.FromJsonString(start_time_input1) + e1 = duration.Duration() + e1.FromJsonString(end_time_input1) + + s2 = duration.Duration() + s2.FromJsonString(start_time_input2) + e2 = duration.Duration() + e2.FromJsonString(end_time_input2) + + client = TranscoderServiceClient() + + parent = f"projects/{project_id}/locations/{location}" + job = transcoder_v1.types.Job() + job.output_uri = output_uri + job.config = transcoder_v1.types.JobConfig( + inputs=[ + transcoder_v1.types.Input(key="input1", uri=input1_uri,), + transcoder_v1.types.Input(key="input2", uri=input2_uri,), + ], + edit_list=[ + transcoder_v1.types.EditAtom( + key="atom1", + inputs=["input1"], + start_time_offset=s1, + end_time_offset=e1, + ), + transcoder_v1.types.EditAtom( + key="atom2", + inputs=["input2"], + start_time_offset=s2, + end_time_offset=e2, + ), + ], + elementary_streams=[ + transcoder_v1.types.ElementaryStream( + key="video-stream0", + video_stream=transcoder_v1.types.VideoStream( + h264=transcoder_v1.types.VideoStream.H264CodecSettings( + height_pixels=360, + width_pixels=640, + bitrate_bps=550000, + frame_rate=60, + ), + ), + ), + transcoder_v1.types.ElementaryStream( + key="audio-stream0", + audio_stream=transcoder_v1.types.AudioStream( + codec="aac", bitrate_bps=64000 + ), + ), + ], + mux_streams=[ + transcoder_v1.types.MuxStream( + key="sd", + container="mp4", + elementary_streams=["video-stream0", "audio-stream0"], + ), + ], + ) + response = client.create_job(parent=parent, job=job) + print(f"Job: {response.name}") + return response + + +# [END transcoder_create_job_with_concatenated_inputs] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", help="The location to start this job in.", default="us-central1", + ) + parser.add_argument( + "--input1_uri", + help="Uri of the first video in the Cloud Storage bucket.", + required=True, + ) + parser.add_argument( + "--start_time_input1", + help="Start time, in fractional seconds ending in 's' (e.g., '1.1s'), " + + "relative to the first input video timeline. Use this field to trim " + + "content from the beginning of the first video.", + required=True, + ) + parser.add_argument( + "--end_time_input1", + help="End time, in fractional seconds ending in 's' (e.g., '9.5s'), " + + "relative to the first input video timeline. Use this field to trim " + + "content from the end of the first video.", + required=True, + ) + parser.add_argument( + "--input2_uri", + help="Uri of the second video in the Cloud Storage bucket.", + required=True, + ) + parser.add_argument( + "--start_time_input2", + help="Start time, in fractional seconds ending in 's' (e.g., '1.1s'), " + + "relative to the second input video timeline. Use this field to trim " + + "content from the beginning of the second video.", + required=True, + ) + parser.add_argument( + "--end_time_input2", + help="End time, in fractional seconds ending in 's' (e.g., '9.5s'), " + + "relative to the second input video timeline. Use this field to trim " + + "content from the end of the second video.", + required=True, + ) + parser.add_argument( + "--output_uri", + help="Uri of the video output folder in the Cloud Storage bucket. " + + "Must end in '/'.", + required=True, + ) + args = parser.parse_args() + create_job_with_concatenated_inputs( + args.project_id, + args.location, + args.input1_uri, + args.start_time_input1, + args.end_time_input1, + args.input2_uri, + args.start_time_input2, + args.end_time_input2, + args.output_uri, + ) diff --git a/video/transcoder/create_job_with_periodic_images_spritesheet.py b/video/transcoder/create_job_with_periodic_images_spritesheet.py new file mode 100644 index 00000000000..5028a278f02 --- /dev/null +++ b/video/transcoder/create_job_with_periodic_images_spritesheet.py @@ -0,0 +1,128 @@ +#!/usr/bin/env python + +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Transcoder sample for creating a job that generates two spritesheets from the input video. Each spritesheet contains images that are captured periodically. + +Example usage: + python create_job_with_periodic_images_spritesheet.py --project_id --location --input_uri --output_uri +""" + +# [START transcoder_create_job_with_periodic_images_spritesheet] + +import argparse + +from google.cloud.video import transcoder_v1 +from google.cloud.video.transcoder_v1.services.transcoder_service import ( + TranscoderServiceClient, +) +from google.protobuf import duration_pb2 as duration + + +def create_job_with_periodic_images_spritesheet( + project_id, location, input_uri, output_uri +): + """Creates a job based on an ad-hoc job configuration that generates two spritesheets. + + Args: + project_id: The GCP project ID. + location: The location to start the job in. + input_uri: Uri of the video in the Cloud Storage bucket. + output_uri: Uri of the video output folder in the Cloud Storage bucket.""" + + client = TranscoderServiceClient() + + parent = f"projects/{project_id}/locations/{location}" + job = transcoder_v1.types.Job() + job.input_uri = input_uri + job.output_uri = output_uri + job.config = transcoder_v1.types.JobConfig( + # Create an ad-hoc job. For more information, see https://cloud.google.com/transcoder/docs/how-to/jobs#create_jobs_ad_hoc. + # See all options for the job config at https://cloud.google.com/transcoder/docs/reference/rest/v1beta1/JobConfig. + elementary_streams=[ + # This section defines the output video stream. + transcoder_v1.types.ElementaryStream( + key="video-stream0", + video_stream=transcoder_v1.types.VideoStream( + h264=transcoder_v1.types.VideoStream.H264CodecSettings( + height_pixels=360, + width_pixels=640, + bitrate_bps=550000, + frame_rate=60, + ), + ), + ), + # This section defines the output audio stream. + transcoder_v1.types.ElementaryStream( + key="audio-stream0", + audio_stream=transcoder_v1.types.AudioStream( + codec="aac", bitrate_bps=64000 + ), + ), + ], + # This section multiplexes the output audio and video together into a container. + mux_streams=[ + transcoder_v1.types.MuxStream( + key="sd", + container="mp4", + elementary_streams=["video-stream0", "audio-stream0"], + ), + ], + # Generate two sprite sheets from the input video into the GCS bucket. For more information, see + # https://cloud.google.com/transcoder/docs/how-to/generate-spritesheet#generate_image_periodically. + sprite_sheets=[ + # Generate a sprite sheet with 64x32px images. An image is taken every 7 seconds from the video. + transcoder_v1.types.SpriteSheet( + file_prefix="small-sprite-sheet", + sprite_width_pixels=64, + sprite_height_pixels=32, + interval=duration.Duration(seconds=7,), + ), + # Generate a sprite sheet with 128x72px images. An image is taken every 7 seconds from the video. + transcoder_v1.types.SpriteSheet( + file_prefix="large-sprite-sheet", + sprite_width_pixels=128, + sprite_height_pixels=72, + interval=duration.Duration(seconds=7,), + ), + ], + ) + response = client.create_job(parent=parent, job=job) + print(f"Job: {response.name}") + return response + + +# [END transcoder_create_job_with_periodic_images_spritesheet] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", help="The location to start this job in.", default="us-central1", + ) + parser.add_argument( + "--input_uri", + help="Uri of the video in the Cloud Storage bucket.", + required=True, + ) + parser.add_argument( + "--output_uri", + help="Uri of the video output folder in the Cloud Storage bucket. Must end in '/'.", + required=True, + ) + args = parser.parse_args() + create_job_with_periodic_images_spritesheet( + args.project_id, args.location, args.input_uri, args.output_uri, + ) diff --git a/video/transcoder/create_job_with_set_number_images_spritesheet.py b/video/transcoder/create_job_with_set_number_images_spritesheet.py new file mode 100644 index 00000000000..d416eecc7de --- /dev/null +++ b/video/transcoder/create_job_with_set_number_images_spritesheet.py @@ -0,0 +1,131 @@ +#!/usr/bin/env python + +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Transcoder sample for creating a job that generates two spritesheets from the input video. Each spritesheet contains a set number of images. + +Example usage: + python create_job_with_set_number_images_spritesheet.py --project_id --location --input_uri --output_uri +""" + +# [START transcoder_create_job_with_set_number_images_spritesheet] + +import argparse + +from google.cloud.video import transcoder_v1 +from google.cloud.video.transcoder_v1.services.transcoder_service import ( + TranscoderServiceClient, +) + + +def create_job_with_set_number_images_spritesheet( + project_id, location, input_uri, output_uri +): + """Creates a job based on an ad-hoc job configuration that generates two spritesheets. + + Args: + project_id: The GCP project ID. + location: The location to start the job in. + input_uri: Uri of the video in the Cloud Storage bucket. + output_uri: Uri of the video output folder in the Cloud Storage bucket.""" + + client = TranscoderServiceClient() + + parent = f"projects/{project_id}/locations/{location}" + job = transcoder_v1.types.Job() + job.input_uri = input_uri + job.output_uri = output_uri + job.config = transcoder_v1.types.JobConfig( + # Create an ad-hoc job. For more information, see https://cloud.google.com/transcoder/docs/how-to/jobs#create_jobs_ad_hoc. + # See all options for the job config at https://cloud.google.com/transcoder/docs/reference/rest/v1beta1/JobConfig. + elementary_streams=[ + # This section defines the output video stream. + transcoder_v1.types.ElementaryStream( + key="video-stream0", + video_stream=transcoder_v1.types.VideoStream( + h264=transcoder_v1.types.VideoStream.H264CodecSettings( + height_pixels=360, + width_pixels=640, + bitrate_bps=550000, + frame_rate=60, + ), + ), + ), + # This section defines the output audio stream. + transcoder_v1.types.ElementaryStream( + key="audio-stream0", + audio_stream=transcoder_v1.types.AudioStream( + codec="aac", bitrate_bps=64000 + ), + ), + ], + # This section multiplexes the output audio and video together into a container. + mux_streams=[ + transcoder_v1.types.MuxStream( + key="sd", + container="mp4", + elementary_streams=["video-stream0", "audio-stream0"], + ), + ], + # Generate two sprite sheets from the input video into the GCS bucket. For more information, see + # https://cloud.google.com/transcoder/docs/how-to/generate-spritesheet#generate_set_number_of_images. + sprite_sheets=[ + # Generate a 10x10 sprite sheet with 64x32px images. + transcoder_v1.types.SpriteSheet( + file_prefix="small-sprite-sheet", + sprite_width_pixels=64, + sprite_height_pixels=32, + column_count=10, + row_count=10, + total_count=100, + ), + # Generate a 10x10 sprite sheet with 128x72px images. + transcoder_v1.types.SpriteSheet( + file_prefix="large-sprite-sheet", + sprite_width_pixels=128, + sprite_height_pixels=72, + column_count=10, + row_count=10, + total_count=100, + ), + ], + ) + response = client.create_job(parent=parent, job=job) + print(f"Job: {response.name}") + return response + + +# [END transcoder_create_job_with_set_number_images_spritesheet] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", help="The location to start this job in.", default="us-central1", + ) + parser.add_argument( + "--input_uri", + help="Uri of the video in the Cloud Storage bucket.", + required=True, + ) + parser.add_argument( + "--output_uri", + help="Uri of the video output folder in the Cloud Storage bucket. Must end in '/'.", + required=True, + ) + args = parser.parse_args() + create_job_with_set_number_images_spritesheet( + args.project_id, args.location, args.input_uri, args.output_uri, + ) diff --git a/video/transcoder/create_job_with_static_overlay.py b/video/transcoder/create_job_with_static_overlay.py new file mode 100644 index 00000000000..5386a8a79ef --- /dev/null +++ b/video/transcoder/create_job_with_static_overlay.py @@ -0,0 +1,141 @@ +#!/usr/bin/env python + +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Transcoder sample for creating a job based on a supplied job config that includes a static overlay. + +Example usage: + python create_job_with_static_overlay.py --project_id --location --input_uri --overlay_image_uri --output_uri +""" + +# [START transcoder_create_job_with_static_overlay] + +import argparse + +from google.cloud.video import transcoder_v1 +from google.cloud.video.transcoder_v1.services.transcoder_service import ( + TranscoderServiceClient, +) +from google.protobuf import duration_pb2 as duration + + +def create_job_with_static_overlay( + project_id, location, input_uri, overlay_image_uri, output_uri +): + """Creates a job based on an ad-hoc job configuration that includes a static image overlay. + + Args: + project_id: The GCP project ID. + location: The location to start the job in. + input_uri: Uri of the video in the Cloud Storage bucket. + overlay_image_uri: Uri of the JPEG image for the overlay in the Cloud Storage bucket. Must be a JPEG. + output_uri: Uri of the video output folder in the Cloud Storage bucket.""" + + client = TranscoderServiceClient() + + parent = f"projects/{project_id}/locations/{location}" + job = transcoder_v1.types.Job() + job.input_uri = input_uri + job.output_uri = output_uri + job.config = transcoder_v1.types.JobConfig( + elementary_streams=[ + transcoder_v1.types.ElementaryStream( + key="video-stream0", + video_stream=transcoder_v1.types.VideoStream( + h264=transcoder_v1.types.VideoStream.H264CodecSettings( + height_pixels=360, + width_pixels=640, + bitrate_bps=550000, + frame_rate=60, + ), + ), + ), + transcoder_v1.types.ElementaryStream( + key="audio-stream0", + audio_stream=transcoder_v1.types.AudioStream( + codec="aac", bitrate_bps=64000 + ), + ), + ], + mux_streams=[ + transcoder_v1.types.MuxStream( + key="sd", + container="mp4", + elementary_streams=["video-stream0", "audio-stream0"], + ), + ], + overlays=[ + transcoder_v1.types.Overlay( + image=transcoder_v1.types.Overlay.Image( + uri=overlay_image_uri, + resolution=transcoder_v1.types.Overlay.NormalizedCoordinate( + x=1, y=0.5, + ), + alpha=1, + ), + animations=[ + transcoder_v1.types.Overlay.Animation( + animation_static=transcoder_v1.types.Overlay.AnimationStatic( + xy=transcoder_v1.types.Overlay.NormalizedCoordinate( + x=0, y=0, + ), + start_time_offset=duration.Duration(seconds=0,), + ), + ), + transcoder_v1.types.Overlay.Animation( + animation_end=transcoder_v1.types.Overlay.AnimationEnd( + start_time_offset=duration.Duration(seconds=10,), + ), + ), + ], + ), + ], + ) + response = client.create_job(parent=parent, job=job) + print(f"Job: {response.name}") + return response + + +# [END transcoder_create_job_with_static_overlay] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", help="The location to start this job in.", default="us-central1", + ) + parser.add_argument( + "--input_uri", + help="Uri of the video in the Cloud Storage bucket.", + required=True, + ) + parser.add_argument( + "--overlay_image_uri", + help="Uri of the overlay JPEG image in the Cloud Storage bucket. Must be a JPEG.", + required=True, + ) + parser.add_argument( + "--output_uri", + help="Uri of the video output folder in the Cloud Storage bucket. Must end in '/'.", + required=True, + ) + args = parser.parse_args() + create_job_with_static_overlay( + args.project_id, + args.location, + args.input_uri, + args.overlay_image_uri, + args.output_uri, + ) diff --git a/video/transcoder/delete_job.py b/video/transcoder/delete_job.py new file mode 100644 index 00000000000..5f139f9ed55 --- /dev/null +++ b/video/transcoder/delete_job.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python + +# Copyright 2020 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Transcoder sample for deleting a job. + +Example usage: + python delete_job.py --project_id --location --job_id +""" + +# [START transcoder_delete_job] + +import argparse + +from google.cloud.video.transcoder_v1.services.transcoder_service import ( + TranscoderServiceClient, +) + + +def delete_job(project_id, location, job_id): + """Gets a job. + + Args: + project_id: The GCP project ID. + location: The location this job is in. + job_id: The job ID.""" + + client = TranscoderServiceClient() + + name = f"projects/{project_id}/locations/{location}/jobs/{job_id}" + response = client.delete_job(name=name) + print("Deleted job") + return response + + +# [END transcoder_delete_job] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument("--location", help="The location of the job.", required=True) + parser.add_argument("--job_id", help="The job ID.", required=True) + args = parser.parse_args() + delete_job(args.project_id, args.location, args.job_id) diff --git a/video/transcoder/delete_job_template.py b/video/transcoder/delete_job_template.py new file mode 100644 index 00000000000..ccce70f71c5 --- /dev/null +++ b/video/transcoder/delete_job_template.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python + +# Copyright 2020 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Transcoder sample for deleting a job template. + +Example usage: + python delete_job_template.py --project_id --location --template_id +""" + +# [START transcoder_delete_job_template] + +import argparse + +from google.cloud.video.transcoder_v1.services.transcoder_service import ( + TranscoderServiceClient, +) + + +def delete_job_template(project_id, location, template_id): + """Deletes a job template. + + Args: + project_id: The GCP project ID. + location: The location of the template. + template_id: The user-defined template ID.""" + + client = TranscoderServiceClient() + + name = f"projects/{project_id}/locations/{location}/jobTemplates/{template_id}" + response = client.delete_job_template(name=name) + print("Deleted job template") + return response + + +# [END transcoder_delete_job_template] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", help="The location of the template.", required=True + ) + parser.add_argument("--template_id", help="The job template ID.", required=True) + args = parser.parse_args() + delete_job_template(args.project_id, args.location, args.template_id) diff --git a/video/transcoder/get_job.py b/video/transcoder/get_job.py new file mode 100644 index 00000000000..ec5d7f1fa7e --- /dev/null +++ b/video/transcoder/get_job.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python + +# Copyright 2020 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Transcoder sample for getting the details for a job. + +Example usage: + python get_job.py --project_id --location --job_id +""" + +# [START transcoder_get_job] + +import argparse + +from google.cloud.video.transcoder_v1.services.transcoder_service import ( + TranscoderServiceClient, +) + + +def get_job(project_id, location, job_id): + """Gets a job. + + Args: + project_id: The GCP project ID. + location: The location this job is in. + job_id: The job ID.""" + + client = TranscoderServiceClient() + + name = f"projects/{project_id}/locations/{location}/jobs/{job_id}" + response = client.get_job(name=name) + print(f"Job: {response.name}") + return response + + +# [END transcoder_get_job] + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument("--location", help="The location of the job.", required=True) + parser.add_argument("--job_id", help="The job ID.", required=True) + args = parser.parse_args() + get_job(args.project_id, args.location, args.job_id) diff --git a/video/transcoder/get_job_state.py b/video/transcoder/get_job_state.py new file mode 100644 index 00000000000..6b73acfc6c4 --- /dev/null +++ b/video/transcoder/get_job_state.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python + +# Copyright 2020 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Transcoder sample for getting the state for a job. + +Example usage: + python get_job_state.py --project_id --location --job_id +""" + +# [START transcoder_get_job_state] + +import argparse + +from google.cloud.video.transcoder_v1.services.transcoder_service import ( + TranscoderServiceClient, +) + + +def get_job_state(project_id, location, job_id): + """Gets a job's state. + + Args: + project_id: The GCP project ID. + location: The location this job is in. + job_id: The job ID.""" + + client = TranscoderServiceClient() + + name = f"projects/{project_id}/locations/{location}/jobs/{job_id}" + response = client.get_job(name=name) + + print(f"Job state: {str(response.state)}") + return response + + +# [END transcoder_get_job_state] + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument("--location", help="The location of the job.", required=True) + parser.add_argument("--job_id", help="The job ID.", required=True) + args = parser.parse_args() + get_job_state(args.project_id, args.location, args.job_id) diff --git a/video/transcoder/get_job_template.py b/video/transcoder/get_job_template.py new file mode 100644 index 00000000000..4d6ccf70915 --- /dev/null +++ b/video/transcoder/get_job_template.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python + +# Copyright 2020 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Transcoder sample for getting a job template. + +Example usage: + python get_job_template.py --project_id --location --template_id +""" + +# [START transcoder_get_job_template] + +import argparse + +from google.cloud.video.transcoder_v1.services.transcoder_service import ( + TranscoderServiceClient, +) + + +def get_job_template(project_id, location, template_id): + """Gets a job template. + + Args: + project_id: The GCP project ID. + location: The location of the template. + template_id: The user-defined template ID.""" + + client = TranscoderServiceClient() + + name = f"projects/{project_id}/locations/{location}/jobTemplates/{template_id}" + response = client.get_job_template(name=name) + print(f"Job template: {response.name}") + return response + + +# [END transcoder_get_job_template] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", help="The location of the template.", required=True + ) + parser.add_argument("--template_id", help="The job template ID.", required=True) + args = parser.parse_args() + get_job_template(args.project_id, args.location, args.template_id) diff --git a/video/transcoder/job_template_test.py b/video/transcoder/job_template_test.py new file mode 100644 index 00000000000..259595a4b55 --- /dev/null +++ b/video/transcoder/job_template_test.py @@ -0,0 +1,60 @@ +# Copyright 2020 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import uuid + +from google.api_core.exceptions import NotFound + +import create_job_template +import delete_job_template +import get_job_template +import list_job_templates + +location = "us-central1" +project_id = os.environ["GOOGLE_CLOUD_PROJECT"] +project_number = os.environ["GOOGLE_CLOUD_PROJECT_NUMBER"] +template_id = f"my-python-test-template-{uuid.uuid4()}" + + +def test_template_operations(capsys): + + # Enable the following API on the test project: + # * Transcoder API + + job_template_name = ( + f"projects/{project_number}/locations/{location}/jobTemplates/{template_id}" + ) + + try: + delete_job_template.delete_job_template(project_id, location, template_id) + except NotFound as e: + print(f"Ignoring NotFound, details: {e}") + out, _ = capsys.readouterr() + + create_job_template.create_job_template(project_id, location, template_id) + out, _ = capsys.readouterr() + assert job_template_name in out + + get_job_template.get_job_template(project_id, location, template_id) + out, _ = capsys.readouterr() + assert job_template_name in out + + list_job_templates.list_job_templates(project_id, location) + out, _ = capsys.readouterr() + assert job_template_name in out + + delete_job_template.delete_job_template(project_id, location, template_id) + out, _ = capsys.readouterr() + assert "Deleted job template" in out diff --git a/video/transcoder/job_test.py b/video/transcoder/job_test.py new file mode 100644 index 00000000000..2d9a6bab3ea --- /dev/null +++ b/video/transcoder/job_test.py @@ -0,0 +1,410 @@ +# Copyright 2020 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import time +import uuid + +import backoff +from google.cloud import storage +from googleapiclient.errors import HttpError +import pytest + +import create_job_from_ad_hoc +import create_job_from_preset +import create_job_from_template +import create_job_template +import create_job_with_animated_overlay +import create_job_with_concatenated_inputs +import create_job_with_periodic_images_spritesheet +import create_job_with_set_number_images_spritesheet +import create_job_with_static_overlay +import delete_job +import delete_job_template +import get_job +import get_job_state +import list_jobs + +location = "us-central1" +project_id = os.environ["GOOGLE_CLOUD_PROJECT"] +project_number = os.environ["GOOGLE_CLOUD_PROJECT_NUMBER"] +template_id = f"my-python-test-template-{uuid.uuid4()}" + +input_bucket_name = "cloud-samples-data/media/" +output_bucket_name = f"python-samples-transcoder-{uuid.uuid4()}" +test_video_file_name = "ChromeCast.mp4" +test_overlay_image_file_name = "overlay.jpg" +test_concat1_file_name = "ForBiggerEscapes.mp4" +test_concat2_file_name = "ForBiggerJoyrides.mp4" + +input_uri = f"gs://{input_bucket_name}{test_video_file_name}" +overlay_image_uri = f"gs://{input_bucket_name}{test_overlay_image_file_name}" +concat1_uri = f"gs://{input_bucket_name}{test_concat1_file_name}" +concat2_uri = f"gs://{input_bucket_name}{test_concat2_file_name}" +output_uri_for_preset = f"gs://{output_bucket_name}/test-output-preset/" +output_uri_for_template = f"gs://{output_bucket_name}/test-output-template/" +output_uri_for_adhoc = f"gs://{output_bucket_name}/test-output-adhoc/" +output_uri_for_static_overlay = f"gs://{output_bucket_name}/test-output-static-overlay/" +output_uri_for_animated_overlay = ( + f"gs://{output_bucket_name}/test-output-animated-overlay/" +) +small_spritesheet_file_prefix = "small-sprite-sheet" +large_spritesheet_file_prefix = "large-sprite-sheet" +spritesheet_file_suffix = "0000000000.jpeg" + +output_dir_for_set_number_spritesheet = "test-output-set-number-spritesheet/" +output_uri_for_set_number_spritesheet = ( + f"gs://{output_bucket_name}/{output_dir_for_set_number_spritesheet}" +) +output_dir_for_periodic_spritesheet = "test-output-periodic-spritesheet/" +output_uri_for_periodic_spritesheet = ( + f"gs://{output_bucket_name}/{output_dir_for_periodic_spritesheet}" +) +output_uri_for_concat = f"gs://{output_bucket_name}/test-output-concat/" + +preset = "preset/web-hd" +job_succeeded_state = "ProcessingState.SUCCEEDED" + + +@pytest.fixture(scope="module") +def test_bucket(): + storage_client = storage.Client() + bucket = storage_client.create_bucket(output_bucket_name) + + yield bucket + bucket.delete(force=True) + + +def test_create_job_from_preset(capsys, test_bucket): + create_job_from_preset.create_job_from_preset( + project_id, location, input_uri, output_uri_for_preset, preset + ) + out, _ = capsys.readouterr() + job_name_prefix = f"projects/{project_number}/locations/{location}/jobs/" + assert job_name_prefix in out + + str_slice = out.split("/") + job_id = str_slice[len(str_slice) - 1].rstrip("\n") + job_name = f"projects/{project_number}/locations/{location}/jobs/{job_id}" + assert job_name in out + + get_job.get_job(project_id, location, job_id) + out, _ = capsys.readouterr() + assert job_name in out + + time.sleep(30) + + _assert_job_state_succeeded(capsys, job_id) + + list_jobs.list_jobs(project_id, location) + out, _ = capsys.readouterr() + assert job_name in out + + delete_job.delete_job(project_id, location, job_id) + out, _ = capsys.readouterr() + assert "Deleted job" in out + + +def test_create_job_from_template(capsys, test_bucket): + + job_template_name = ( + f"projects/{project_number}/locations/{location}/jobTemplates/{template_id}" + ) + + create_job_template.create_job_template(project_id, location, template_id) + out, _ = capsys.readouterr() + assert job_template_name in out + + create_job_from_template.create_job_from_template( + project_id, location, input_uri, output_uri_for_template, template_id + ) + out, _ = capsys.readouterr() + job_name_prefix = f"projects/{project_number}/locations/{location}/jobs/" + assert job_name_prefix in out + + str_slice = out.split("/") + job_id = str_slice[len(str_slice) - 1].rstrip("\n") + job_name = f"projects/{project_number}/locations/{location}/jobs/{job_id}" + assert job_name in out + + get_job.get_job(project_id, location, job_id) + out, _ = capsys.readouterr() + assert job_name in out + + time.sleep(30) + + _assert_job_state_succeeded(capsys, job_id) + + list_jobs.list_jobs(project_id, location) + out, _ = capsys.readouterr() + assert job_name in out + + delete_job.delete_job(project_id, location, job_id) + out, _ = capsys.readouterr() + assert "Deleted job" in out + + delete_job_template.delete_job_template(project_id, location, template_id) + out, _ = capsys.readouterr() + assert "Deleted job template" in out + + +def test_create_job_from_ad_hoc(capsys, test_bucket): + create_job_from_ad_hoc.create_job_from_ad_hoc( + project_id, location, input_uri, output_uri_for_adhoc + ) + out, _ = capsys.readouterr() + job_name_prefix = f"projects/{project_number}/locations/{location}/jobs/" + assert job_name_prefix in out + + str_slice = out.split("/") + job_id = str_slice[len(str_slice) - 1].rstrip("\n") + job_name = f"projects/{project_number}/locations/{location}/jobs/{job_id}" + assert job_name in out + + get_job.get_job(project_id, location, job_id) + out, _ = capsys.readouterr() + assert job_name in out + + time.sleep(30) + + _assert_job_state_succeeded(capsys, job_id) + + list_jobs.list_jobs(project_id, location) + out, _ = capsys.readouterr() + assert job_name in out + + delete_job.delete_job(project_id, location, job_id) + out, _ = capsys.readouterr() + assert "Deleted job" in out + + +def test_create_job_with_static_overlay(capsys, test_bucket): + create_job_with_static_overlay.create_job_with_static_overlay( + project_id, + location, + input_uri, + overlay_image_uri, + output_uri_for_static_overlay, + ) + out, _ = capsys.readouterr() + job_name_prefix = f"projects/{project_number}/locations/{location}/jobs/" + assert job_name_prefix in out + + str_slice = out.split("/") + job_id = str_slice[len(str_slice) - 1].rstrip("\n") + job_name = f"projects/{project_number}/locations/{location}/jobs/{job_id}" + assert job_name in out + + get_job.get_job(project_id, location, job_id) + out, _ = capsys.readouterr() + assert job_name in out + + time.sleep(30) + + _assert_job_state_succeeded(capsys, job_id) + + list_jobs.list_jobs(project_id, location) + out, _ = capsys.readouterr() + assert job_name in out + + delete_job.delete_job(project_id, location, job_id) + out, _ = capsys.readouterr() + assert "Deleted job" in out + + +def test_create_job_with_animated_overlay(capsys, test_bucket): + create_job_with_animated_overlay.create_job_with_animated_overlay( + project_id, + location, + input_uri, + overlay_image_uri, + output_uri_for_animated_overlay, + ) + out, _ = capsys.readouterr() + job_name_prefix = f"projects/{project_number}/locations/{location}/jobs/" + assert job_name_prefix in out + + str_slice = out.split("/") + job_id = str_slice[len(str_slice) - 1].rstrip("\n") + job_name = f"projects/{project_number}/locations/{location}/jobs/{job_id}" + assert job_name in out + + get_job.get_job(project_id, location, job_id) + out, _ = capsys.readouterr() + assert job_name in out + + time.sleep(30) + + _assert_job_state_succeeded(capsys, job_id) + + list_jobs.list_jobs(project_id, location) + out, _ = capsys.readouterr() + assert job_name in out + + delete_job.delete_job(project_id, location, job_id) + out, _ = capsys.readouterr() + assert "Deleted job" in out + + +def test_create_job_with_set_number_spritesheet(capsys, test_bucket): + create_job_with_set_number_images_spritesheet.create_job_with_set_number_images_spritesheet( + project_id, location, input_uri, output_uri_for_set_number_spritesheet, + ) + out, _ = capsys.readouterr() + job_name_prefix = f"projects/{project_number}/locations/{location}/jobs/" + assert job_name_prefix in out + + str_slice = out.split("/") + job_id = str_slice[len(str_slice) - 1].rstrip("\n") + job_name = f"projects/{project_number}/locations/{location}/jobs/{job_id}" + assert job_name in out + + get_job.get_job(project_id, location, job_id) + out, _ = capsys.readouterr() + assert ( + job_name in out + ) # Get the job name so you can use it later to get the job and delete the job. + + time.sleep( + 30 + ) # Transcoding jobs need time to complete. Once the job completes, check the job state. + + _assert_job_state_succeeded(capsys, job_id) + _assert_file_in_bucket( + capsys, + test_bucket, + output_dir_for_set_number_spritesheet + + small_spritesheet_file_prefix + + spritesheet_file_suffix, + ) + _assert_file_in_bucket( + capsys, + test_bucket, + output_dir_for_set_number_spritesheet + + large_spritesheet_file_prefix + + spritesheet_file_suffix, + ) + + list_jobs.list_jobs(project_id, location) + out, _ = capsys.readouterr() + assert job_name in out + + delete_job.delete_job(project_id, location, job_id) + out, _ = capsys.readouterr() + assert "Deleted job" in out + + +def test_create_job_with_periodic_spritesheet(capsys, test_bucket): + create_job_with_periodic_images_spritesheet.create_job_with_periodic_images_spritesheet( + project_id, location, input_uri, output_uri_for_periodic_spritesheet, + ) + out, _ = capsys.readouterr() + job_name_prefix = f"projects/{project_number}/locations/{location}/jobs/" + assert job_name_prefix in out + + str_slice = out.split("/") + job_id = str_slice[len(str_slice) - 1].rstrip("\n") + job_name = f"projects/{project_number}/locations/{location}/jobs/{job_id}" + assert job_name in out + + get_job.get_job(project_id, location, job_id) + out, _ = capsys.readouterr() + assert ( + job_name in out + ) # Get the job name so you can use it later to get the job and delete the job. + + time.sleep( + 30 + ) # Transcoding jobs need time to complete. Once the job completes, check the job state. + + _assert_job_state_succeeded(capsys, job_id) + _assert_file_in_bucket( + capsys, + test_bucket, + output_dir_for_periodic_spritesheet + + small_spritesheet_file_prefix + + spritesheet_file_suffix, + ) + _assert_file_in_bucket( + capsys, + test_bucket, + output_dir_for_periodic_spritesheet + + large_spritesheet_file_prefix + + spritesheet_file_suffix, + ) + + list_jobs.list_jobs(project_id, location) + out, _ = capsys.readouterr() + assert job_name in out + + delete_job.delete_job(project_id, location, job_id) + out, _ = capsys.readouterr() + assert "Deleted job" in out + + +def test_create_job_with_concatenated_inputs(capsys, test_bucket): + create_job_with_concatenated_inputs.create_job_with_concatenated_inputs( + project_id, + location, + concat1_uri, + "0s", + "8.1s", + concat2_uri, + "3.5s", + "15s", + output_uri_for_concat, + ) + out, _ = capsys.readouterr() + job_name_prefix = f"projects/{project_number}/locations/{location}/jobs/" + assert job_name_prefix in out + + str_slice = out.split("/") + job_id = str_slice[len(str_slice) - 1].rstrip("\n") + job_name = f"projects/{project_number}/locations/{location}/jobs/{job_id}" + assert job_name in out + + get_job.get_job(project_id, location, job_id) + out, _ = capsys.readouterr() + assert job_name in out + + time.sleep( + 30 + ) # Transcoding jobs need time to complete. Once the job completes, check the job state. + + _assert_job_state_succeeded(capsys, job_id) + + list_jobs.list_jobs(project_id, location) + out, _ = capsys.readouterr() + assert job_name in out + + delete_job.delete_job(project_id, location, job_id) + out, _ = capsys.readouterr() + assert "Deleted job" in out + + +# Retrying up to 10 mins. +@backoff.on_exception(backoff.expo, AssertionError, max_time=600) +def _assert_job_state_succeeded(capsys, job_id): + try: + get_job_state.get_job_state(project_id, location, job_id) + except HttpError as err: + raise AssertionError(f"Could not get job state: {err.resp.status}") + + out, _ = capsys.readouterr() + assert job_succeeded_state in out + + +def _assert_file_in_bucket(capsys, test_bucket, directory_and_filename): + blob = test_bucket.blob(directory_and_filename) + assert blob.exists() diff --git a/video/transcoder/list_job_templates.py b/video/transcoder/list_job_templates.py new file mode 100644 index 00000000000..020f7a32973 --- /dev/null +++ b/video/transcoder/list_job_templates.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python + +# Copyright 2020 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Transcoder sample for listing job templates in a location. + +Example usage: + python list_job_templates.py --project_id --location +""" + +# [START transcoder_list_job_templates] + +import argparse + +from google.cloud.video.transcoder_v1.services.transcoder_service import ( + TranscoderServiceClient, +) + + +def list_job_templates(project_id, location): + """Lists all job templates in a location. + + Args: + project_id: The GCP project ID. + location: The location of the templates.""" + + client = TranscoderServiceClient() + + parent = f"projects/{project_id}/locations/{location}" + response = client.list_job_templates(parent=parent) + print("Job templates:") + for jobTemplate in response.job_templates: + print({jobTemplate.name}) + + return response + + +# [END transcoder_list_job_templates] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", help="The location of the templates.", required=True + ) + args = parser.parse_args() + list_job_templates(args.project_id, args.location) diff --git a/video/transcoder/list_jobs.py b/video/transcoder/list_jobs.py new file mode 100644 index 00000000000..cf1fdbd2347 --- /dev/null +++ b/video/transcoder/list_jobs.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python + +# Copyright 2020 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Transcoder sample for listing jobs in a location. + +Example usage: + python list_jobs.py --project_id --location +""" + +# [START transcoder_list_jobs] + +import argparse + +from google.cloud.video.transcoder_v1.services.transcoder_service import ( + TranscoderServiceClient, +) + + +def list_jobs(project_id, location): + """Lists all jobs in a location. + + Args: + project_id: The GCP project ID. + location: The location of the jobs.""" + + client = TranscoderServiceClient() + + parent = f"projects/{project_id}/locations/{location}" + response = client.list_jobs(parent=parent) + print("Jobs:") + for job in response.jobs: + print({job.name}) + + return response + + +# [END transcoder_list_jobs] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument("--location", help="The location of the jobs.", required=True) + args = parser.parse_args() + list_jobs(args.project_id, args.location) diff --git a/video/transcoder/noxfile.py b/video/transcoder/noxfile.py new file mode 100644 index 00000000000..3bbef5d54f4 --- /dev/null +++ b/video/transcoder/noxfile.py @@ -0,0 +1,278 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import print_function + +import glob +import os +from pathlib import Path +import sys +from typing import Callable, Dict, List, Optional + +import nox + + +# WARNING - WARNING - WARNING - WARNING - WARNING +# WARNING - WARNING - WARNING - WARNING - WARNING +# DO NOT EDIT THIS FILE EVER! +# WARNING - WARNING - WARNING - WARNING - WARNING +# WARNING - WARNING - WARNING - WARNING - WARNING + +BLACK_VERSION = "black==19.10b0" + +# Copy `noxfile_config.py` to your directory and modify it instead. + +# `TEST_CONFIG` dict is a configuration hook that allows users to +# modify the test configurations. The values here should be in sync +# with `noxfile_config.py`. Users will copy `noxfile_config.py` into +# their directory and modify it. + +TEST_CONFIG = { + # You can opt out from the test for specific Python versions. + "ignored_versions": [], + # Old samples are opted out of enforcing Python type hints + # All new samples should feature them + "enforce_type_hints": False, + # An envvar key for determining the project id to use. Change it + # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a + # build specific Cloud project. You can also use your own string + # to use your own Cloud project. + "gcloud_project_env": "GOOGLE_CLOUD_PROJECT", + # 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT', + # If you need to use a specific version of pip, + # change pip_version_override to the string representation + # of the version number, for example, "20.2.4" + "pip_version_override": None, + # A dictionary you want to inject into your test. Don't put any + # secrets here. These values will override predefined values. + "envs": {}, +} + + +try: + # Ensure we can import noxfile_config in the project's directory. + sys.path.append(".") + from noxfile_config import TEST_CONFIG_OVERRIDE +except ImportError as e: + print("No user noxfile_config found: detail: {}".format(e)) + TEST_CONFIG_OVERRIDE = {} + +# Update the TEST_CONFIG with the user supplied values. +TEST_CONFIG.update(TEST_CONFIG_OVERRIDE) + + +def get_pytest_env_vars() -> Dict[str, str]: + """Returns a dict for pytest invocation.""" + ret = {} + + # Override the GCLOUD_PROJECT and the alias. + env_key = TEST_CONFIG["gcloud_project_env"] + # This should error out if not set. + ret["GOOGLE_CLOUD_PROJECT"] = os.environ[env_key] + + # Apply user supplied envs. + ret.update(TEST_CONFIG["envs"]) + return ret + + +# DO NOT EDIT - automatically generated. +# All versions used to test samples. +ALL_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"] + +# Any default versions that should be ignored. +IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"] + +TESTED_VERSIONS = sorted([v for v in ALL_VERSIONS if v not in IGNORED_VERSIONS]) + +INSTALL_LIBRARY_FROM_SOURCE = os.environ.get("INSTALL_LIBRARY_FROM_SOURCE", False) in ( + "True", + "true", +) + +# Error if a python version is missing +nox.options.error_on_missing_interpreters = True + +# +# Style Checks +# + + +def _determine_local_import_names(start_dir: str) -> List[str]: + """Determines all import names that should be considered "local". + + This is used when running the linter to insure that import order is + properly checked. + """ + file_ext_pairs = [os.path.splitext(path) for path in os.listdir(start_dir)] + return [ + basename + for basename, extension in file_ext_pairs + if extension == ".py" + or os.path.isdir(os.path.join(start_dir, basename)) + and basename not in ("__pycache__") + ] + + +# Linting with flake8. +# +# We ignore the following rules: +# E203: whitespace before ‘:’ +# E266: too many leading ‘#’ for block comment +# E501: line too long +# I202: Additional newline in a section of imports +# +# We also need to specify the rules which are ignored by default: +# ['E226', 'W504', 'E126', 'E123', 'W503', 'E24', 'E704', 'E121'] +FLAKE8_COMMON_ARGS = [ + "--show-source", + "--builtin=gettext", + "--max-complexity=20", + "--import-order-style=google", + "--exclude=.nox,.cache,env,lib,generated_pb2,*_pb2.py,*_pb2_grpc.py", + "--ignore=E121,E123,E126,E203,E226,E24,E266,E501,E704,W503,W504,I202", + "--max-line-length=88", +] + + +@nox.session +def lint(session: nox.sessions.Session) -> None: + if not TEST_CONFIG["enforce_type_hints"]: + session.install("flake8", "flake8-import-order") + else: + session.install("flake8", "flake8-import-order", "flake8-annotations") + + local_names = _determine_local_import_names(".") + args = FLAKE8_COMMON_ARGS + [ + "--application-import-names", + ",".join(local_names), + ".", + ] + session.run("flake8", *args) + + +# +# Black +# + + +@nox.session +def blacken(session: nox.sessions.Session) -> None: + session.install(BLACK_VERSION) + python_files = [path for path in os.listdir(".") if path.endswith(".py")] + + session.run("black", *python_files) + + +# +# Sample Tests +# + + +PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml"] + + +def _session_tests( + session: nox.sessions.Session, post_install: Callable = None +) -> None: + # check for presence of tests + test_list = glob.glob("*_test.py") + glob.glob("test_*.py") + if len(test_list) == 0: + print("No tests found, skipping directory.") + else: + if TEST_CONFIG["pip_version_override"]: + pip_version = TEST_CONFIG["pip_version_override"] + session.install(f"pip=={pip_version}") + """Runs py.test for a particular project.""" + if os.path.exists("requirements.txt"): + if os.path.exists("constraints.txt"): + session.install("-r", "requirements.txt", "-c", "constraints.txt") + else: + session.install("-r", "requirements.txt") + + if os.path.exists("requirements-test.txt"): + if os.path.exists("constraints-test.txt"): + session.install( + "-r", "requirements-test.txt", "-c", "constraints-test.txt" + ) + else: + session.install("-r", "requirements-test.txt") + + if INSTALL_LIBRARY_FROM_SOURCE: + session.install("-e", _get_repo_root()) + + if post_install: + post_install(session) + + session.run( + "pytest", + *(PYTEST_COMMON_ARGS + session.posargs), + # Pytest will return 5 when no tests are collected. This can happen + # on travis where slow and flaky tests are excluded. + # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html + success_codes=[0, 5], + env=get_pytest_env_vars(), + ) + + +@nox.session(python=ALL_VERSIONS) +def py(session: nox.sessions.Session) -> None: + """Runs py.test for a sample using the specified version of Python.""" + if session.python in TESTED_VERSIONS: + _session_tests(session) + else: + session.skip( + "SKIPPED: {} tests are disabled for this sample.".format(session.python) + ) + + +# +# Readmegen +# + + +def _get_repo_root() -> Optional[str]: + """ Returns the root folder of the project. """ + # Get root of this repository. Assume we don't have directories nested deeper than 10 items. + p = Path(os.getcwd()) + for i in range(10): + if p is None: + break + if Path(p / ".git").exists(): + return str(p) + # .git is not available in repos cloned via Cloud Build + # setup.py is always in the library's root, so use that instead + # https://github.com/googleapis/synthtool/issues/792 + if Path(p / "setup.py").exists(): + return str(p) + p = p.parent + raise Exception("Unable to detect repository root.") + + +GENERATED_READMES = sorted([x for x in Path(".").rglob("*.rst.in")]) + + +@nox.session +@nox.parametrize("path", GENERATED_READMES) +def readmegen(session: nox.sessions.Session, path: str) -> None: + """(Re-)generates the readme for a sample.""" + session.install("jinja2", "pyyaml") + dir_ = os.path.dirname(path) + + if os.path.exists(os.path.join(dir_, "requirements.txt")): + session.install("-r", os.path.join(dir_, "requirements.txt")) + + in_file = os.path.join(dir_, "README.rst.in") + session.run( + "python", _get_repo_root() + "/scripts/readme-gen/readme_gen.py", in_file + ) diff --git a/video/transcoder/requirements-test.txt b/video/transcoder/requirements-test.txt new file mode 100644 index 00000000000..52c66823c1a --- /dev/null +++ b/video/transcoder/requirements-test.txt @@ -0,0 +1,3 @@ +backoff==1.11.1 +google-cloud-storage==1.43.0 +pytest==6.2.4 diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt new file mode 100644 index 00000000000..7011d0bfa9a --- /dev/null +++ b/video/transcoder/requirements.txt @@ -0,0 +1,3 @@ +google-api-python-client==2.34.0 +grpcio==1.43.0 +google-cloud-video-transcoder==1.2.1 From dca163cbe6a931d8d385385b76418492fe372e34 Mon Sep 17 00:00:00 2001 From: nicain Date: Mon, 24 Jan 2022 13:52:20 -0800 Subject: [PATCH 02/86] chore: set cdpe-cloudai as codeowner (#128) --- video/transcoder/noxfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/video/transcoder/noxfile.py b/video/transcoder/noxfile.py index 3bbef5d54f4..20cdfc62013 100644 --- a/video/transcoder/noxfile.py +++ b/video/transcoder/noxfile.py @@ -187,6 +187,7 @@ def _session_tests( ) -> None: # check for presence of tests test_list = glob.glob("*_test.py") + glob.glob("test_*.py") + test_list.extend(glob.glob("tests")) if len(test_list) == 0: print("No tests found, skipping directory.") else: From a355ac47806de5ae8c613b2c1743f40ec6258741 Mon Sep 17 00:00:00 2001 From: Nicholas Cook Date: Fri, 4 Feb 2022 10:47:25 -0800 Subject: [PATCH 03/86] feat: add samples and tests for adding captions to a job (#131) * feat: add samples and tests for adding captions to a job * remove space * remove extraneous explanation --- .../create_job_with_embedded_captions.py | 195 ++++++++++++++++++ .../create_job_with_standalone_captions.py | 192 +++++++++++++++++ video/transcoder/job_test.py | 113 +++++++++- 3 files changed, 494 insertions(+), 6 deletions(-) create mode 100644 video/transcoder/create_job_with_embedded_captions.py create mode 100644 video/transcoder/create_job_with_standalone_captions.py diff --git a/video/transcoder/create_job_with_embedded_captions.py b/video/transcoder/create_job_with_embedded_captions.py new file mode 100644 index 00000000000..31e4216ce9b --- /dev/null +++ b/video/transcoder/create_job_with_embedded_captions.py @@ -0,0 +1,195 @@ +#!/usr/bin/env python + +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Transcoder sample for creating a job that embeds captions in the output video. + +Example usage: + python create_job_with_embedded_captions.py --project_id --location \ + --input_video_uri --input_captions_uri --output_uri +""" + +# [START transcoder_create_job_with_embedded_captions] + +import argparse + +from google.cloud.video import transcoder_v1 +from google.cloud.video.transcoder_v1.services.transcoder_service import ( + TranscoderServiceClient, +) + + +def create_job_with_embedded_captions( + project_id, + location, + input_video_uri, + input_captions_uri, + output_uri, +): + """Creates a job based on an ad-hoc job configuration that embeds captions in the output video. + + Args: + project_id (str): The GCP project ID. + location (str): The location to start the job in. + input_video_uri (str): Uri of the input video in the Cloud Storage + bucket. + input_captions_uri (str): Uri of the input captions file in the Cloud + Storage bucket. + output_uri (str): Uri of the video output folder in the Cloud Storage + bucket.""" + + client = TranscoderServiceClient() + + parent = f"projects/{project_id}/locations/{location}" + job = transcoder_v1.types.Job() + job.output_uri = output_uri + job.config = transcoder_v1.types.JobConfig( + inputs=[ + transcoder_v1.types.Input( + key="input0", + uri=input_video_uri, + ), + transcoder_v1.types.Input( + key="caption-input0", + uri=input_captions_uri, + ), + ], + edit_list=[ + transcoder_v1.types.EditAtom( + key="atom0", + inputs=["input0", "caption-input0"], + ), + ], + elementary_streams=[ + transcoder_v1.types.ElementaryStream( + key="video-stream0", + video_stream=transcoder_v1.types.VideoStream( + h264=transcoder_v1.types.VideoStream.H264CodecSettings( + height_pixels=360, + width_pixels=640, + bitrate_bps=550000, + frame_rate=60, + ), + ), + ), + transcoder_v1.types.ElementaryStream( + key="audio-stream0", + audio_stream=transcoder_v1.types.AudioStream( + codec="aac", bitrate_bps=64000 + ), + ), + transcoder_v1.types.ElementaryStream( + key="cea-stream0", + # The following doesn't work because "mapping" is a reserved + # argument name in GCP python client libraries (see + # https://github.com/googleapis/proto-plus-python/blob/main/proto/message.py#L447): + # + # text_stream=transcoder_v1.types.TextStream( + # codec="cea608", + # mapping=[ + # transcoder_v1.types.TextStream.TextMapping( + # atom_key="atom0", + # input_key="caption-input0", + # input_track=0, + # ), + # ], + # ), + # Use a python dictionary as a workaround: + text_stream={ + "codec": "cea608", + "mapping": [ + { + "atom_key": "atom0", + "input_key": "caption-input0", + "input_track": 0, + } + ], + }, + ), + ], + mux_streams=[ + transcoder_v1.types.MuxStream( + key="sd", + container="mp4", + elementary_streams=["video-stream0", "audio-stream0"], + ), + transcoder_v1.types.MuxStream( + key="sd-hls", + container="ts", + elementary_streams=["video-stream0", "audio-stream0"], + ), + transcoder_v1.types.MuxStream( + key="sd-dash", + container="fmp4", + elementary_streams=["video-stream0"], + ), + transcoder_v1.types.MuxStream( + key="audio-dash", + container="fmp4", + elementary_streams=["audio-stream0"], + ), + ], + manifests=[ + transcoder_v1.types.Manifest( + file_name="manifest.m3u8", + type_="HLS", + mux_streams=["sd-hls"], + ), + transcoder_v1.types.Manifest( + file_name="manifest.mpd", + type_="DASH", + mux_streams=["sd-dash", "audio-dash"], + ), + ], + ) + response = client.create_job(parent=parent, job=job) + print(f"Job: {response.name}") + return response + + +# [END transcoder_create_job_with_embedded_captions] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", + help="The location to start this job in.", + default="us-central1", + ) + parser.add_argument( + "--input_video_uri", + help="Uri of the input video in the Cloud Storage bucket.", + required=True, + ) + parser.add_argument( + "--input_captions_uri", + help="Uri of the input captions file in the Cloud Storage bucket.", + required=True, + ) + parser.add_argument( + "--output_uri", + help="Uri of the video output folder in the Cloud Storage bucket. " + + "Must end in '/'.", + required=True, + ) + args = parser.parse_args() + create_job_with_embedded_captions( + args.project_id, + args.location, + args.input_video_uri, + args.input_captions_uri, + args.output_uri, + ) diff --git a/video/transcoder/create_job_with_standalone_captions.py b/video/transcoder/create_job_with_standalone_captions.py new file mode 100644 index 00000000000..5ed546763c9 --- /dev/null +++ b/video/transcoder/create_job_with_standalone_captions.py @@ -0,0 +1,192 @@ +#!/usr/bin/env python + +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Transcoder sample for creating a job that can use captions from a standalone file. + +Example usage: + python create_job_with_standalone_captions.py --project_id --location \ + --input_video_uri --input_captions_uri --output_uri +""" + +# [START transcoder_create_job_with_standalone_captions] + +import argparse + +from google.cloud.video import transcoder_v1 +from google.cloud.video.transcoder_v1.services.transcoder_service import ( + TranscoderServiceClient, +) +from google.protobuf import duration_pb2 as duration + + +def create_job_with_standalone_captions( + project_id, + location, + input_video_uri, + input_captions_uri, + output_uri, +): + """Creates a job based on an ad-hoc job configuration that can use captions from a standalone file. + + Args: + project_id (str): The GCP project ID. + location (str): The location to start the job in. + input_video_uri (str): Uri of the input video in the Cloud Storage + bucket. + input_captions_uri (str): Uri of the input captions file in the Cloud + Storage bucket. + output_uri (str): Uri of the video output folder in the Cloud Storage + bucket.""" + + client = TranscoderServiceClient() + + parent = f"projects/{project_id}/locations/{location}" + job = transcoder_v1.types.Job() + job.output_uri = output_uri + job.config = transcoder_v1.types.JobConfig( + inputs=[ + transcoder_v1.types.Input( + key="input0", + uri=input_video_uri, + ), + transcoder_v1.types.Input( + key="caption-input0", + uri=input_captions_uri, + ), + ], + edit_list=[ + transcoder_v1.types.EditAtom( + key="atom0", + inputs=["input0", "caption-input0"], + ), + ], + elementary_streams=[ + transcoder_v1.types.ElementaryStream( + key="video-stream0", + video_stream=transcoder_v1.types.VideoStream( + h264=transcoder_v1.types.VideoStream.H264CodecSettings( + height_pixels=360, + width_pixels=640, + bitrate_bps=550000, + frame_rate=60, + ), + ), + ), + transcoder_v1.types.ElementaryStream( + key="audio-stream0", + audio_stream=transcoder_v1.types.AudioStream( + codec="aac", bitrate_bps=64000 + ), + ), + transcoder_v1.types.ElementaryStream( + key="vtt-stream0", + # The following doesn't work because "mapping" is a reserved + # argument name in GCP python client libraries (see + # https://github.com/googleapis/proto-plus-python/blob/main/proto/message.py#L447): + # + # text_stream=transcoder_v1.types.TextStream( + # codec="webvtt", + # mapping=[ + # transcoder_v1.types.TextStream.TextMapping( + # atom_key="atom0", + # input_key="caption-input0", + # input_track=0, + # ), + # ], + # ), + # Use a python dictionary as a workaround: + text_stream={ + "codec": "webvtt", + "mapping": [ + { + "atom_key": "atom0", + "input_key": "caption-input0", + "input_track": 0, + } + ], + }, + ), + ], + mux_streams=[ + transcoder_v1.types.MuxStream( + key="sd-hls-fmp4", + container="fmp4", + elementary_streams=["video-stream0"], + ), + transcoder_v1.types.MuxStream( + key="audio-hls-fmp4", + container="fmp4", + elementary_streams=["audio-stream0"], + ), + transcoder_v1.types.MuxStream( + key="text-vtt", + container="vtt", + elementary_streams=["vtt-stream0"], + segment_settings=transcoder_v1.types.SegmentSettings( + segment_duration=duration.Duration( + seconds=6, + ), + individual_segments=True, + ), + ), + ], + manifests=[ + transcoder_v1.types.Manifest( + file_name="manifest.m3u8", + type_="HLS", + mux_streams=["sd-hls-fmp4", "audio-hls-fmp4", "text-vtt"], + ), + ], + ) + response = client.create_job(parent=parent, job=job) + print(f"Job: {response.name}") + return response + + +# [END transcoder_create_job_with_standalone_captions] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", + help="The location to start this job in.", + default="us-central1", + ) + parser.add_argument( + "--input_video_uri", + help="Uri of the input video in the Cloud Storage bucket.", + required=True, + ) + parser.add_argument( + "--input_captions_uri", + help="Uri of the input captions file in the Cloud Storage bucket.", + required=True, + ) + parser.add_argument( + "--output_uri", + help="Uri of the video output folder in the Cloud Storage bucket. " + + "Must end in '/'.", + required=True, + ) + args = parser.parse_args() + create_job_with_standalone_captions( + args.project_id, + args.location, + args.input_video_uri, + args.input_captions_uri, + args.output_uri, + ) diff --git a/video/transcoder/job_test.py b/video/transcoder/job_test.py index 2d9a6bab3ea..fa9a93e0f89 100644 --- a/video/transcoder/job_test.py +++ b/video/transcoder/job_test.py @@ -27,8 +27,10 @@ import create_job_template import create_job_with_animated_overlay import create_job_with_concatenated_inputs +import create_job_with_embedded_captions import create_job_with_periodic_images_spritesheet import create_job_with_set_number_images_spritesheet +import create_job_with_standalone_captions import create_job_with_static_overlay import delete_job import delete_job_template @@ -47,11 +49,13 @@ test_overlay_image_file_name = "overlay.jpg" test_concat1_file_name = "ForBiggerEscapes.mp4" test_concat2_file_name = "ForBiggerJoyrides.mp4" +test_captions_file_name = "caption.srt" input_uri = f"gs://{input_bucket_name}{test_video_file_name}" overlay_image_uri = f"gs://{input_bucket_name}{test_overlay_image_file_name}" concat1_uri = f"gs://{input_bucket_name}{test_concat1_file_name}" concat2_uri = f"gs://{input_bucket_name}{test_concat2_file_name}" +captions_uri = f"gs://{input_bucket_name}{test_captions_file_name}" output_uri_for_preset = f"gs://{output_bucket_name}/test-output-preset/" output_uri_for_template = f"gs://{output_bucket_name}/test-output-template/" output_uri_for_adhoc = f"gs://{output_bucket_name}/test-output-adhoc/" @@ -59,6 +63,9 @@ output_uri_for_animated_overlay = ( f"gs://{output_bucket_name}/test-output-animated-overlay/" ) +output_uri_for_embedded_captions = f"gs://{output_bucket_name}/test-output-embedded-captions/" +output_uri_for_standalone_captions = f"gs://{output_bucket_name}/test-output-standalone-captions/" + small_spritesheet_file_prefix = "small-sprite-sheet" large_spritesheet_file_prefix = "large-sprite-sheet" spritesheet_file_suffix = "0000000000.jpeg" @@ -75,6 +82,7 @@ preset = "preset/web-hd" job_succeeded_state = "ProcessingState.SUCCEEDED" +job_running_state = "ProcessingState.RUNNING" @pytest.fixture(scope="module") @@ -105,7 +113,7 @@ def test_create_job_from_preset(capsys, test_bucket): time.sleep(30) - _assert_job_state_succeeded(capsys, job_id) + _assert_job_state_succeeded_or_running(capsys, job_id) list_jobs.list_jobs(project_id, location) out, _ = capsys.readouterr() @@ -144,7 +152,7 @@ def test_create_job_from_template(capsys, test_bucket): time.sleep(30) - _assert_job_state_succeeded(capsys, job_id) + _assert_job_state_succeeded_or_running(capsys, job_id) list_jobs.list_jobs(project_id, location) out, _ = capsys.readouterr() @@ -178,7 +186,7 @@ def test_create_job_from_ad_hoc(capsys, test_bucket): time.sleep(30) - _assert_job_state_succeeded(capsys, job_id) + _assert_job_state_succeeded_or_running(capsys, job_id) list_jobs.list_jobs(project_id, location) out, _ = capsys.readouterr() @@ -259,7 +267,10 @@ def test_create_job_with_animated_overlay(capsys, test_bucket): def test_create_job_with_set_number_spritesheet(capsys, test_bucket): create_job_with_set_number_images_spritesheet.create_job_with_set_number_images_spritesheet( - project_id, location, input_uri, output_uri_for_set_number_spritesheet, + project_id, + location, + input_uri, + output_uri_for_set_number_spritesheet, ) out, _ = capsys.readouterr() job_name_prefix = f"projects/{project_number}/locations/{location}/jobs/" @@ -307,7 +318,10 @@ def test_create_job_with_set_number_spritesheet(capsys, test_bucket): def test_create_job_with_periodic_spritesheet(capsys, test_bucket): create_job_with_periodic_images_spritesheet.create_job_with_periodic_images_spritesheet( - project_id, location, input_uri, output_uri_for_periodic_spritesheet, + project_id, + location, + input_uri, + output_uri_for_periodic_spritesheet, ) out, _ = capsys.readouterr() job_name_prefix = f"projects/{project_number}/locations/{location}/jobs/" @@ -393,7 +407,80 @@ def test_create_job_with_concatenated_inputs(capsys, test_bucket): assert "Deleted job" in out -# Retrying up to 10 mins. +def test_create_job_with_embedded_captions(capsys, test_bucket): + create_job_with_embedded_captions.create_job_with_embedded_captions( + project_id, + location, + input_uri, + captions_uri, + output_uri_for_embedded_captions, + ) + out, _ = capsys.readouterr() + job_name_prefix = f"projects/{project_number}/locations/{location}/jobs/" + assert job_name_prefix in out + + str_slice = out.split("/") + job_id = str_slice[len(str_slice) - 1].rstrip("\n") + job_name = f"projects/{project_number}/locations/{location}/jobs/{job_id}" + assert job_name in out + + get_job.get_job(project_id, location, job_id) + out, _ = capsys.readouterr() + assert job_name in out + + time.sleep( + 30 + ) # Transcoding jobs need time to complete. Once the job completes, check the job state. + + _assert_job_state_succeeded(capsys, job_id) + + list_jobs.list_jobs(project_id, location) + out, _ = capsys.readouterr() + assert job_name in out + + delete_job.delete_job(project_id, location, job_id) + out, _ = capsys.readouterr() + assert "Deleted job" in out + + +def test_create_job_with_standalone_captions(capsys, test_bucket): + create_job_with_standalone_captions.create_job_with_standalone_captions( + project_id, + location, + input_uri, + captions_uri, + output_uri_for_standalone_captions, + ) + out, _ = capsys.readouterr() + job_name_prefix = f"projects/{project_number}/locations/{location}/jobs/" + assert job_name_prefix in out + + str_slice = out.split("/") + job_id = str_slice[len(str_slice) - 1].rstrip("\n") + job_name = f"projects/{project_number}/locations/{location}/jobs/{job_id}" + assert job_name in out + + get_job.get_job(project_id, location, job_id) + out, _ = capsys.readouterr() + assert job_name in out + + time.sleep( + 30 + ) # Transcoding jobs need time to complete. Once the job completes, check the job state. + + _assert_job_state_succeeded(capsys, job_id) + + list_jobs.list_jobs(project_id, location) + out, _ = capsys.readouterr() + assert job_name in out + + delete_job.delete_job(project_id, location, job_id) + out, _ = capsys.readouterr() + assert "Deleted job" in out + + +# Retrying up to 10 mins. This function checks if the job completed +# successfully. @backoff.on_exception(backoff.expo, AssertionError, max_time=600) def _assert_job_state_succeeded(capsys, job_id): try: @@ -405,6 +492,20 @@ def _assert_job_state_succeeded(capsys, job_id): assert job_succeeded_state in out +# Retrying up to 10 mins. This function checks if the job is running or has +# completed. Both of these conditions signal the API is functioning. The test +# can list or delete a job that is running or completed with no ill effects. +@backoff.on_exception(backoff.expo, AssertionError, max_time=600) +def _assert_job_state_succeeded_or_running(capsys, job_id): + try: + get_job_state.get_job_state(project_id, location, job_id) + except HttpError as err: + raise AssertionError(f"Could not get job state: {err.resp.status}") + + out, _ = capsys.readouterr() + assert (job_succeeded_state in out) or (job_running_state in out) + + def _assert_file_in_bucket(capsys, test_bucket, directory_and_filename): blob = test_bucket.blob(directory_and_filename) assert blob.exists() From 4c4623d5800d39a67670ebcf4544b6851c35b248 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Mon, 14 Feb 2022 20:49:17 -0500 Subject: [PATCH 04/86] fix: rename mapping attribute of AudioStream to mapping_ (#121) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: resolve issue where mapping attribute of AudioStream could not be set fix(deps): require proto-plus >= 1.20.1 * chore: use gapic-generator-python 0.58.4 committer: dovs PiperOrigin-RevId: 419025932 Source-Link: https://github.com/googleapis/googleapis/commit/73da6697f598f1ba30618924936a59f8e457ec89 Source-Link: https://github.com/googleapis/googleapis-gen/commit/46df624a54b9ed47c1a7eefb7a49413cf7b82f98 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDZkZjYyNGE1NGI5ZWQ0N2MxYTdlZWZiN2E0OTQxM2NmN2I4MmY5OCJ9 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix(deps): require proto-plus >= 1.20.1 * ensure proto-plus>=1.20.1 is used for testing Co-authored-by: Owl Bot Co-authored-by: Dov Shlachter Co-authored-by: Anthonios Partheniou --- .../create_job_with_embedded_captions.py | 31 +++++-------------- .../create_job_with_standalone_captions.py | 27 ++++------------ video/transcoder/job_test.py | 24 ++++++-------- video/transcoder/requirements-test.txt | 1 + 4 files changed, 23 insertions(+), 60 deletions(-) diff --git a/video/transcoder/create_job_with_embedded_captions.py b/video/transcoder/create_job_with_embedded_captions.py index 31e4216ce9b..a81e6688818 100644 --- a/video/transcoder/create_job_with_embedded_captions.py +++ b/video/transcoder/create_job_with_embedded_captions.py @@ -32,11 +32,7 @@ def create_job_with_embedded_captions( - project_id, - location, - input_video_uri, - input_captions_uri, - output_uri, + project_id, location, input_video_uri, input_captions_uri, output_uri, ): """Creates a job based on an ad-hoc job configuration that embeds captions in the output video. @@ -57,19 +53,12 @@ def create_job_with_embedded_captions( job.output_uri = output_uri job.config = transcoder_v1.types.JobConfig( inputs=[ - transcoder_v1.types.Input( - key="input0", - uri=input_video_uri, - ), - transcoder_v1.types.Input( - key="caption-input0", - uri=input_captions_uri, - ), + transcoder_v1.types.Input(key="input0", uri=input_video_uri,), + transcoder_v1.types.Input(key="caption-input0", uri=input_captions_uri,), ], edit_list=[ transcoder_v1.types.EditAtom( - key="atom0", - inputs=["input0", "caption-input0"], + key="atom0", inputs=["input0", "caption-input0"], ), ], elementary_streams=[ @@ -131,9 +120,7 @@ def create_job_with_embedded_captions( elementary_streams=["video-stream0", "audio-stream0"], ), transcoder_v1.types.MuxStream( - key="sd-dash", - container="fmp4", - elementary_streams=["video-stream0"], + key="sd-dash", container="fmp4", elementary_streams=["video-stream0"], ), transcoder_v1.types.MuxStream( key="audio-dash", @@ -143,9 +130,7 @@ def create_job_with_embedded_captions( ], manifests=[ transcoder_v1.types.Manifest( - file_name="manifest.m3u8", - type_="HLS", - mux_streams=["sd-hls"], + file_name="manifest.m3u8", type_="HLS", mux_streams=["sd-hls"], ), transcoder_v1.types.Manifest( file_name="manifest.mpd", @@ -165,9 +150,7 @@ def create_job_with_embedded_captions( parser = argparse.ArgumentParser() parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) parser.add_argument( - "--location", - help="The location to start this job in.", - default="us-central1", + "--location", help="The location to start this job in.", default="us-central1", ) parser.add_argument( "--input_video_uri", diff --git a/video/transcoder/create_job_with_standalone_captions.py b/video/transcoder/create_job_with_standalone_captions.py index 5ed546763c9..de32f49b176 100644 --- a/video/transcoder/create_job_with_standalone_captions.py +++ b/video/transcoder/create_job_with_standalone_captions.py @@ -33,11 +33,7 @@ def create_job_with_standalone_captions( - project_id, - location, - input_video_uri, - input_captions_uri, - output_uri, + project_id, location, input_video_uri, input_captions_uri, output_uri, ): """Creates a job based on an ad-hoc job configuration that can use captions from a standalone file. @@ -58,19 +54,12 @@ def create_job_with_standalone_captions( job.output_uri = output_uri job.config = transcoder_v1.types.JobConfig( inputs=[ - transcoder_v1.types.Input( - key="input0", - uri=input_video_uri, - ), - transcoder_v1.types.Input( - key="caption-input0", - uri=input_captions_uri, - ), + transcoder_v1.types.Input(key="input0", uri=input_video_uri,), + transcoder_v1.types.Input(key="caption-input0", uri=input_captions_uri,), ], edit_list=[ transcoder_v1.types.EditAtom( - key="atom0", - inputs=["input0", "caption-input0"], + key="atom0", inputs=["input0", "caption-input0"], ), ], elementary_streams=[ @@ -136,9 +125,7 @@ def create_job_with_standalone_captions( container="vtt", elementary_streams=["vtt-stream0"], segment_settings=transcoder_v1.types.SegmentSettings( - segment_duration=duration.Duration( - seconds=6, - ), + segment_duration=duration.Duration(seconds=6,), individual_segments=True, ), ), @@ -162,9 +149,7 @@ def create_job_with_standalone_captions( parser = argparse.ArgumentParser() parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) parser.add_argument( - "--location", - help="The location to start this job in.", - default="us-central1", + "--location", help="The location to start this job in.", default="us-central1", ) parser.add_argument( "--input_video_uri", diff --git a/video/transcoder/job_test.py b/video/transcoder/job_test.py index fa9a93e0f89..d924472c858 100644 --- a/video/transcoder/job_test.py +++ b/video/transcoder/job_test.py @@ -63,8 +63,12 @@ output_uri_for_animated_overlay = ( f"gs://{output_bucket_name}/test-output-animated-overlay/" ) -output_uri_for_embedded_captions = f"gs://{output_bucket_name}/test-output-embedded-captions/" -output_uri_for_standalone_captions = f"gs://{output_bucket_name}/test-output-standalone-captions/" +output_uri_for_embedded_captions = ( + f"gs://{output_bucket_name}/test-output-embedded-captions/" +) +output_uri_for_standalone_captions = ( + f"gs://{output_bucket_name}/test-output-standalone-captions/" +) small_spritesheet_file_prefix = "small-sprite-sheet" large_spritesheet_file_prefix = "large-sprite-sheet" @@ -267,10 +271,7 @@ def test_create_job_with_animated_overlay(capsys, test_bucket): def test_create_job_with_set_number_spritesheet(capsys, test_bucket): create_job_with_set_number_images_spritesheet.create_job_with_set_number_images_spritesheet( - project_id, - location, - input_uri, - output_uri_for_set_number_spritesheet, + project_id, location, input_uri, output_uri_for_set_number_spritesheet, ) out, _ = capsys.readouterr() job_name_prefix = f"projects/{project_number}/locations/{location}/jobs/" @@ -318,10 +319,7 @@ def test_create_job_with_set_number_spritesheet(capsys, test_bucket): def test_create_job_with_periodic_spritesheet(capsys, test_bucket): create_job_with_periodic_images_spritesheet.create_job_with_periodic_images_spritesheet( - project_id, - location, - input_uri, - output_uri_for_periodic_spritesheet, + project_id, location, input_uri, output_uri_for_periodic_spritesheet, ) out, _ = capsys.readouterr() job_name_prefix = f"projects/{project_number}/locations/{location}/jobs/" @@ -409,11 +407,7 @@ def test_create_job_with_concatenated_inputs(capsys, test_bucket): def test_create_job_with_embedded_captions(capsys, test_bucket): create_job_with_embedded_captions.create_job_with_embedded_captions( - project_id, - location, - input_uri, - captions_uri, - output_uri_for_embedded_captions, + project_id, location, input_uri, captions_uri, output_uri_for_embedded_captions, ) out, _ = capsys.readouterr() job_name_prefix = f"projects/{project_number}/locations/{location}/jobs/" diff --git a/video/transcoder/requirements-test.txt b/video/transcoder/requirements-test.txt index 52c66823c1a..2996534ce7a 100644 --- a/video/transcoder/requirements-test.txt +++ b/video/transcoder/requirements-test.txt @@ -1,3 +1,4 @@ backoff==1.11.1 google-cloud-storage==1.43.0 pytest==6.2.4 +proto-plus>=1.20.1 From c21a3ea6af170af0a69295f153b56fa096a297be Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 24 Feb 2022 17:00:41 +0100 Subject: [PATCH 05/86] chore(deps): update all dependencies (#132) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps): update all dependencies * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- video/transcoder/requirements-test.txt | 5 ++--- video/transcoder/requirements.txt | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/video/transcoder/requirements-test.txt b/video/transcoder/requirements-test.txt index 2996534ce7a..4255a6091dd 100644 --- a/video/transcoder/requirements-test.txt +++ b/video/transcoder/requirements-test.txt @@ -1,4 +1,3 @@ backoff==1.11.1 -google-cloud-storage==1.43.0 -pytest==6.2.4 -proto-plus>=1.20.1 +google-cloud-storage==2.1.0 +pytest==7.0.0 diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 7011d0bfa9a..3286e50daa7 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.34.0 +google-api-python-client==2.36.0 grpcio==1.43.0 google-cloud-video-transcoder==1.2.1 From 281138de8b78d69cdf746bb6c1dbc1dba8f5d690 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 24 Feb 2022 17:12:16 +0100 Subject: [PATCH 06/86] chore(deps): update all dependencies (#141) --- video/transcoder/requirements-test.txt | 2 +- video/transcoder/requirements.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/video/transcoder/requirements-test.txt b/video/transcoder/requirements-test.txt index 4255a6091dd..bc29a4922f0 100644 --- a/video/transcoder/requirements-test.txt +++ b/video/transcoder/requirements-test.txt @@ -1,3 +1,3 @@ backoff==1.11.1 google-cloud-storage==2.1.0 -pytest==7.0.0 +pytest==7.0.1 diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 3286e50daa7..f219cbaa109 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.36.0 -grpcio==1.43.0 +google-api-python-client==2.38.0 +grpcio==1.44.0 google-cloud-video-transcoder==1.2.1 From 6700802ca1fa650885b98b2d373f517de1ec2a12 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 24 Feb 2022 17:38:56 +0000 Subject: [PATCH 07/86] fix: Remove deprecated v1beta1 API that is no longer available (#138) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - [ ] Regenerate this pull request now. Merge branch 'owl-bot-copy' of https://github.com/googleapis/python-video-transcoder into owl-bot-copy 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md chore: use gapic-generator-python 0.63.2 docs: add generated snippets PiperOrigin-RevId: 427792504 Source-Link: https://github.com/googleapis/googleapis/commit/55b9e1e0b3106c850d13958352bc0751147b6b15 Source-Link: https://github.com/googleapis/googleapis-gen/commit/bf4e86b753f42cb0edb1fd51fbe840d7da0a1cde Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYmY0ZTg2Yjc1M2Y0MmNiMGVkYjFmZDUxZmJlODQwZDdkYTBhMWNkZSJ9 --- video/transcoder/create_job_with_periodic_images_spritesheet.py | 2 +- .../transcoder/create_job_with_set_number_images_spritesheet.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/video/transcoder/create_job_with_periodic_images_spritesheet.py b/video/transcoder/create_job_with_periodic_images_spritesheet.py index 5028a278f02..95621e2b9ef 100644 --- a/video/transcoder/create_job_with_periodic_images_spritesheet.py +++ b/video/transcoder/create_job_with_periodic_images_spritesheet.py @@ -50,7 +50,7 @@ def create_job_with_periodic_images_spritesheet( job.output_uri = output_uri job.config = transcoder_v1.types.JobConfig( # Create an ad-hoc job. For more information, see https://cloud.google.com/transcoder/docs/how-to/jobs#create_jobs_ad_hoc. - # See all options for the job config at https://cloud.google.com/transcoder/docs/reference/rest/v1beta1/JobConfig. + # See all options for the job config at https://cloud.google.com/transcoder/docs/reference/rest/v1/JobConfig. elementary_streams=[ # This section defines the output video stream. transcoder_v1.types.ElementaryStream( diff --git a/video/transcoder/create_job_with_set_number_images_spritesheet.py b/video/transcoder/create_job_with_set_number_images_spritesheet.py index d416eecc7de..b25c872dd24 100644 --- a/video/transcoder/create_job_with_set_number_images_spritesheet.py +++ b/video/transcoder/create_job_with_set_number_images_spritesheet.py @@ -49,7 +49,7 @@ def create_job_with_set_number_images_spritesheet( job.output_uri = output_uri job.config = transcoder_v1.types.JobConfig( # Create an ad-hoc job. For more information, see https://cloud.google.com/transcoder/docs/how-to/jobs#create_jobs_ad_hoc. - # See all options for the job config at https://cloud.google.com/transcoder/docs/reference/rest/v1beta1/JobConfig. + # See all options for the job config at https://cloud.google.com/transcoder/docs/reference/rest/v1/JobConfig. elementary_streams=[ # This section defines the output video stream. transcoder_v1.types.ElementaryStream( From eb99d5f235683d15e1df52093a16b60c59804505 Mon Sep 17 00:00:00 2001 From: Nicholas Cook Date: Thu, 24 Feb 2022 13:46:48 -0800 Subject: [PATCH 08/86] docs(samples): update samples to use mapping_ attribute of AudioStream (#142) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: revise samples with fix from #138 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- .../create_job_with_embedded_captions.py | 31 +++++-------------- .../create_job_with_standalone_captions.py | 31 +++++-------------- 2 files changed, 14 insertions(+), 48 deletions(-) diff --git a/video/transcoder/create_job_with_embedded_captions.py b/video/transcoder/create_job_with_embedded_captions.py index a81e6688818..c28a0668f01 100644 --- a/video/transcoder/create_job_with_embedded_captions.py +++ b/video/transcoder/create_job_with_embedded_captions.py @@ -81,31 +81,14 @@ def create_job_with_embedded_captions( ), transcoder_v1.types.ElementaryStream( key="cea-stream0", - # The following doesn't work because "mapping" is a reserved - # argument name in GCP python client libraries (see - # https://github.com/googleapis/proto-plus-python/blob/main/proto/message.py#L447): - # - # text_stream=transcoder_v1.types.TextStream( - # codec="cea608", - # mapping=[ - # transcoder_v1.types.TextStream.TextMapping( - # atom_key="atom0", - # input_key="caption-input0", - # input_track=0, - # ), - # ], - # ), - # Use a python dictionary as a workaround: - text_stream={ - "codec": "cea608", - "mapping": [ - { - "atom_key": "atom0", - "input_key": "caption-input0", - "input_track": 0, - } + text_stream=transcoder_v1.types.TextStream( + codec="cea608", + mapping_=[ + transcoder_v1.types.TextStream.TextMapping( + atom_key="atom0", input_key="caption-input0", input_track=0, + ), ], - }, + ), ), ], mux_streams=[ diff --git a/video/transcoder/create_job_with_standalone_captions.py b/video/transcoder/create_job_with_standalone_captions.py index de32f49b176..49ccfc8b23f 100644 --- a/video/transcoder/create_job_with_standalone_captions.py +++ b/video/transcoder/create_job_with_standalone_captions.py @@ -82,31 +82,14 @@ def create_job_with_standalone_captions( ), transcoder_v1.types.ElementaryStream( key="vtt-stream0", - # The following doesn't work because "mapping" is a reserved - # argument name in GCP python client libraries (see - # https://github.com/googleapis/proto-plus-python/blob/main/proto/message.py#L447): - # - # text_stream=transcoder_v1.types.TextStream( - # codec="webvtt", - # mapping=[ - # transcoder_v1.types.TextStream.TextMapping( - # atom_key="atom0", - # input_key="caption-input0", - # input_track=0, - # ), - # ], - # ), - # Use a python dictionary as a workaround: - text_stream={ - "codec": "webvtt", - "mapping": [ - { - "atom_key": "atom0", - "input_key": "caption-input0", - "input_track": 0, - } + text_stream=transcoder_v1.types.TextStream( + codec="webvtt", + mapping_=[ + transcoder_v1.types.TextStream.TextMapping( + atom_key="atom0", input_key="caption-input0", input_track=0, + ), ], - }, + ), ), ], mux_streams=[ From c2abc00f58efa0f66db45747c19181403a67cb2b Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 25 Feb 2022 19:40:28 +0100 Subject: [PATCH 09/86] chore(deps): update dependency google-cloud-video-transcoder to v1.3.0 (#143) Co-authored-by: Leah E. Cole <6719667+leahecole@users.noreply.github.com> --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index f219cbaa109..efcb806ed3e 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ google-api-python-client==2.38.0 grpcio==1.44.0 -google-cloud-video-transcoder==1.2.1 +google-cloud-video-transcoder==1.3.0 From a47c8c3c829bff9300cb6e16f49da16b420441ea Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 1 Mar 2022 16:15:09 +0100 Subject: [PATCH 10/86] chore(deps): update all dependencies (#148) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps): update all dependencies * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index efcb806ed3e..9d4974ee307 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.38.0 +google-api-python-client==2.39.0 grpcio==1.44.0 google-cloud-video-transcoder==1.3.0 From 8a169ec9a93580c210ffe81c92bf4e274c04d793 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 4 Mar 2022 13:15:41 -0500 Subject: [PATCH 11/86] chore: Adding support for pytest-xdist and pytest-parallel (#154) Source-Link: https://github.com/googleapis/synthtool/commit/82f5cb283efffe96e1b6cd634738e0e7de2cd90a Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:5d8da01438ece4021d135433f2cf3227aa39ef0eaccc941d62aa35e6902832ae Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- video/transcoder/noxfile.py | 78 +++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/video/transcoder/noxfile.py b/video/transcoder/noxfile.py index 20cdfc62013..85f5836dba3 100644 --- a/video/transcoder/noxfile.py +++ b/video/transcoder/noxfile.py @@ -188,42 +188,52 @@ def _session_tests( # check for presence of tests test_list = glob.glob("*_test.py") + glob.glob("test_*.py") test_list.extend(glob.glob("tests")) + if len(test_list) == 0: print("No tests found, skipping directory.") - else: - if TEST_CONFIG["pip_version_override"]: - pip_version = TEST_CONFIG["pip_version_override"] - session.install(f"pip=={pip_version}") - """Runs py.test for a particular project.""" - if os.path.exists("requirements.txt"): - if os.path.exists("constraints.txt"): - session.install("-r", "requirements.txt", "-c", "constraints.txt") - else: - session.install("-r", "requirements.txt") - - if os.path.exists("requirements-test.txt"): - if os.path.exists("constraints-test.txt"): - session.install( - "-r", "requirements-test.txt", "-c", "constraints-test.txt" - ) - else: - session.install("-r", "requirements-test.txt") - - if INSTALL_LIBRARY_FROM_SOURCE: - session.install("-e", _get_repo_root()) - - if post_install: - post_install(session) - - session.run( - "pytest", - *(PYTEST_COMMON_ARGS + session.posargs), - # Pytest will return 5 when no tests are collected. This can happen - # on travis where slow and flaky tests are excluded. - # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html - success_codes=[0, 5], - env=get_pytest_env_vars(), - ) + return + + if TEST_CONFIG["pip_version_override"]: + pip_version = TEST_CONFIG["pip_version_override"] + session.install(f"pip=={pip_version}") + """Runs py.test for a particular project.""" + concurrent_args = [] + if os.path.exists("requirements.txt"): + if os.path.exists("constraints.txt"): + session.install("-r", "requirements.txt", "-c", "constraints.txt") + else: + session.install("-r", "requirements.txt") + with open("requirements.txt") as rfile: + packages = rfile.read() + + if os.path.exists("requirements-test.txt"): + if os.path.exists("constraints-test.txt"): + session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt") + else: + session.install("-r", "requirements-test.txt") + with open("requirements-test.txt") as rtfile: + packages += rtfile.read() + + if INSTALL_LIBRARY_FROM_SOURCE: + session.install("-e", _get_repo_root()) + + if post_install: + post_install(session) + + if "pytest-parallel" in packages: + concurrent_args.extend(["--workers", "auto", "--tests-per-worker", "auto"]) + elif "pytest-xdist" in packages: + concurrent_args.extend(["-n", "auto"]) + + session.run( + "pytest", + *(PYTEST_COMMON_ARGS + session.posargs + concurrent_args), + # Pytest will return 5 when no tests are collected. This can happen + # on travis where slow and flaky tests are excluded. + # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html + success_codes=[0, 5], + env=get_pytest_env_vars(), + ) @nox.session(python=ALL_VERSIONS) From 5c764d68275ee68a45df0d0014160c8e10cd5932 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 7 Mar 2022 20:05:29 +0100 Subject: [PATCH 12/86] chore(deps): update dependency google-cloud-video-transcoder to v1.3.1 (#157) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 9d4974ee307..ce96c5b3d3f 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ google-api-python-client==2.39.0 grpcio==1.44.0 -google-cloud-video-transcoder==1.3.0 +google-cloud-video-transcoder==1.3.1 From 3b6e1c97b9c528e6814570c698c1870bacc9987e Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Sat, 12 Mar 2022 17:09:14 +0100 Subject: [PATCH 13/86] chore(deps): update dependency google-api-python-client to v2.40.0 (#158) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index ce96c5b3d3f..ff77e7e3fd5 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.39.0 +google-api-python-client==2.40.0 grpcio==1.44.0 google-cloud-video-transcoder==1.3.1 From 6f77043d56533b865e0d669d53b7d85267c546aa Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Sun, 13 Mar 2022 17:12:20 +0100 Subject: [PATCH 14/86] chore(deps): update dependency pytest to v7.1.0 (#159) --- video/transcoder/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements-test.txt b/video/transcoder/requirements-test.txt index bc29a4922f0..73f0135f628 100644 --- a/video/transcoder/requirements-test.txt +++ b/video/transcoder/requirements-test.txt @@ -1,3 +1,3 @@ backoff==1.11.1 google-cloud-storage==2.1.0 -pytest==7.0.1 +pytest==7.1.0 From ab82df7bef0b3b45f3be9f9ff404ce0d0884f9a7 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 14 Mar 2022 21:07:38 +0100 Subject: [PATCH 15/86] chore(deps): update dependency google-cloud-storage to v2.2.0 (#160) --- video/transcoder/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements-test.txt b/video/transcoder/requirements-test.txt index 73f0135f628..2570677339d 100644 --- a/video/transcoder/requirements-test.txt +++ b/video/transcoder/requirements-test.txt @@ -1,3 +1,3 @@ backoff==1.11.1 -google-cloud-storage==2.1.0 +google-cloud-storage==2.2.0 pytest==7.1.0 From fe555fdb7f6be976134bbfbf673eab59f6ebb7fe Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 15 Mar 2022 17:21:30 +0100 Subject: [PATCH 16/86] chore(deps): update dependency google-api-python-client to v2.41.0 (#161) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index ff77e7e3fd5..3ec4043b8d8 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.40.0 +google-api-python-client==2.41.0 grpcio==1.44.0 google-cloud-video-transcoder==1.3.1 From 7ac07a6f21137fcf6fb2a7aa9f4edfc796d3bd61 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 15 Mar 2022 21:57:04 +0100 Subject: [PATCH 17/86] chore(deps): update dependency google-cloud-storage to v2.2.1 (#162) --- video/transcoder/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements-test.txt b/video/transcoder/requirements-test.txt index 2570677339d..f5b7003e0de 100644 --- a/video/transcoder/requirements-test.txt +++ b/video/transcoder/requirements-test.txt @@ -1,3 +1,3 @@ backoff==1.11.1 -google-cloud-storage==2.2.0 +google-cloud-storage==2.2.1 pytest==7.1.0 From fc57043ef2cd083d904911382d2c0b4b407ea52b Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Sat, 19 Mar 2022 11:34:41 +0100 Subject: [PATCH 18/86] chore(deps): update dependency pytest to v7.1.1 (#163) --- video/transcoder/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements-test.txt b/video/transcoder/requirements-test.txt index f5b7003e0de..c668431b76b 100644 --- a/video/transcoder/requirements-test.txt +++ b/video/transcoder/requirements-test.txt @@ -1,3 +1,3 @@ backoff==1.11.1 google-cloud-storage==2.2.1 -pytest==7.1.0 +pytest==7.1.1 From 6eb2ae248894d6bb371825a3041a491547669f77 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 23 Mar 2022 09:59:28 +0100 Subject: [PATCH 19/86] chore(deps): update dependency google-api-python-client to v2.42.0 (#164) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 3ec4043b8d8..67f3d1bed2a 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.41.0 +google-api-python-client==2.42.0 grpcio==1.44.0 google-cloud-video-transcoder==1.3.1 From 97790ff0ad713ad3edd420e3e50a14f0743272f4 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Mon, 28 Mar 2022 23:54:31 +0000 Subject: [PATCH 20/86] chore(python): use black==22.3.0 (#167) Source-Link: https://github.com/googleapis/synthtool/commit/6fab84af09f2cf89a031fd8671d1def6b2931b11 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe --- video/transcoder/create_job_from_ad_hoc.py | 9 +++-- video/transcoder/create_job_from_preset.py | 10 ++++-- video/transcoder/create_job_from_template.py | 4 ++- .../create_job_with_animated_overlay.py | 29 ++++++++++----- .../create_job_with_concatenated_inputs.py | 14 ++++++-- .../create_job_with_embedded_captions.py | 35 ++++++++++++++----- ...te_job_with_periodic_images_spritesheet.py | 17 ++++++--- ..._job_with_set_number_images_spritesheet.py | 9 +++-- .../create_job_with_standalone_captions.py | 31 ++++++++++++---- .../create_job_with_static_overlay.py | 18 +++++++--- video/transcoder/job_test.py | 16 +++++++-- video/transcoder/noxfile.py | 4 +-- 12 files changed, 149 insertions(+), 47 deletions(-) diff --git a/video/transcoder/create_job_from_ad_hoc.py b/video/transcoder/create_job_from_ad_hoc.py index 2e08c612c2f..7fc6dce832e 100644 --- a/video/transcoder/create_job_from_ad_hoc.py +++ b/video/transcoder/create_job_from_ad_hoc.py @@ -100,7 +100,9 @@ def create_job_from_ad_hoc(project_id, location, input_uri, output_uri): parser = argparse.ArgumentParser() parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) parser.add_argument( - "--location", help="The location to start this job in.", default="us-central1", + "--location", + help="The location to start this job in.", + default="us-central1", ) parser.add_argument( "--input_uri", @@ -114,5 +116,8 @@ def create_job_from_ad_hoc(project_id, location, input_uri, output_uri): ) args = parser.parse_args() create_job_from_ad_hoc( - args.project_id, args.location, args.input_uri, args.output_uri, + args.project_id, + args.location, + args.input_uri, + args.output_uri, ) diff --git a/video/transcoder/create_job_from_preset.py b/video/transcoder/create_job_from_preset.py index 3539b32550e..67c167241e0 100644 --- a/video/transcoder/create_job_from_preset.py +++ b/video/transcoder/create_job_from_preset.py @@ -59,7 +59,9 @@ def create_job_from_preset(project_id, location, input_uri, output_uri, preset): parser = argparse.ArgumentParser() parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) parser.add_argument( - "--location", help="The location to start this job in.", default="us-central1", + "--location", + help="The location to start this job in.", + default="us-central1", ) parser.add_argument( "--input_uri", @@ -78,5 +80,9 @@ def create_job_from_preset(project_id, location, input_uri, output_uri, preset): ) args = parser.parse_args() create_job_from_preset( - args.project_id, args.location, args.input_uri, args.output_uri, args.preset, + args.project_id, + args.location, + args.input_uri, + args.output_uri, + args.preset, ) diff --git a/video/transcoder/create_job_from_template.py b/video/transcoder/create_job_from_template.py index 0a69704a440..685c3f67999 100644 --- a/video/transcoder/create_job_from_template.py +++ b/video/transcoder/create_job_from_template.py @@ -59,7 +59,9 @@ def create_job_from_template(project_id, location, input_uri, output_uri, templa parser = argparse.ArgumentParser() parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) parser.add_argument( - "--location", help="The location to start this job in.", default="us-central1", + "--location", + help="The location to start this job in.", + default="us-central1", ) parser.add_argument( "--input_uri", diff --git a/video/transcoder/create_job_with_animated_overlay.py b/video/transcoder/create_job_with_animated_overlay.py index a90c542efa5..a3f3cbb3603 100644 --- a/video/transcoder/create_job_with_animated_overlay.py +++ b/video/transcoder/create_job_with_animated_overlay.py @@ -81,7 +81,8 @@ def create_job_with_animated_overlay( image=transcoder_v1.types.Overlay.Image( uri=overlay_image_uri, resolution=transcoder_v1.types.Overlay.NormalizedCoordinate( - x=0, y=0, + x=0, + y=0, ), alpha=1, ), @@ -90,20 +91,30 @@ def create_job_with_animated_overlay( animation_fade=transcoder_v1.types.Overlay.AnimationFade( fade_type=transcoder_v1.types.Overlay.FadeType.FADE_IN, xy=transcoder_v1.types.Overlay.NormalizedCoordinate( - x=0.5, y=0.5, + x=0.5, + y=0.5, + ), + start_time_offset=duration.Duration( + seconds=5, + ), + end_time_offset=duration.Duration( + seconds=10, ), - start_time_offset=duration.Duration(seconds=5,), - end_time_offset=duration.Duration(seconds=10,), ), ), transcoder_v1.types.Overlay.Animation( animation_fade=transcoder_v1.types.Overlay.AnimationFade( fade_type=transcoder_v1.types.Overlay.FadeType.FADE_OUT, xy=transcoder_v1.types.Overlay.NormalizedCoordinate( - x=0.5, y=0.5, + x=0.5, + y=0.5, + ), + start_time_offset=duration.Duration( + seconds=12, + ), + end_time_offset=duration.Duration( + seconds=15, ), - start_time_offset=duration.Duration(seconds=12,), - end_time_offset=duration.Duration(seconds=15,), ), ), ], @@ -121,7 +132,9 @@ def create_job_with_animated_overlay( parser = argparse.ArgumentParser() parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) parser.add_argument( - "--location", help="The location to start this job in.", default="us-central1", + "--location", + help="The location to start this job in.", + default="us-central1", ) parser.add_argument( "--input_uri", diff --git a/video/transcoder/create_job_with_concatenated_inputs.py b/video/transcoder/create_job_with_concatenated_inputs.py index 0a2d3ad8ba7..4a64f88e114 100644 --- a/video/transcoder/create_job_with_concatenated_inputs.py +++ b/video/transcoder/create_job_with_concatenated_inputs.py @@ -80,8 +80,14 @@ def create_job_with_concatenated_inputs( job.output_uri = output_uri job.config = transcoder_v1.types.JobConfig( inputs=[ - transcoder_v1.types.Input(key="input1", uri=input1_uri,), - transcoder_v1.types.Input(key="input2", uri=input2_uri,), + transcoder_v1.types.Input( + key="input1", + uri=input1_uri, + ), + transcoder_v1.types.Input( + key="input2", + uri=input2_uri, + ), ], edit_list=[ transcoder_v1.types.EditAtom( @@ -135,7 +141,9 @@ def create_job_with_concatenated_inputs( parser = argparse.ArgumentParser() parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) parser.add_argument( - "--location", help="The location to start this job in.", default="us-central1", + "--location", + help="The location to start this job in.", + default="us-central1", ) parser.add_argument( "--input1_uri", diff --git a/video/transcoder/create_job_with_embedded_captions.py b/video/transcoder/create_job_with_embedded_captions.py index c28a0668f01..9943889635a 100644 --- a/video/transcoder/create_job_with_embedded_captions.py +++ b/video/transcoder/create_job_with_embedded_captions.py @@ -32,7 +32,11 @@ def create_job_with_embedded_captions( - project_id, location, input_video_uri, input_captions_uri, output_uri, + project_id, + location, + input_video_uri, + input_captions_uri, + output_uri, ): """Creates a job based on an ad-hoc job configuration that embeds captions in the output video. @@ -53,12 +57,19 @@ def create_job_with_embedded_captions( job.output_uri = output_uri job.config = transcoder_v1.types.JobConfig( inputs=[ - transcoder_v1.types.Input(key="input0", uri=input_video_uri,), - transcoder_v1.types.Input(key="caption-input0", uri=input_captions_uri,), + transcoder_v1.types.Input( + key="input0", + uri=input_video_uri, + ), + transcoder_v1.types.Input( + key="caption-input0", + uri=input_captions_uri, + ), ], edit_list=[ transcoder_v1.types.EditAtom( - key="atom0", inputs=["input0", "caption-input0"], + key="atom0", + inputs=["input0", "caption-input0"], ), ], elementary_streams=[ @@ -85,7 +96,9 @@ def create_job_with_embedded_captions( codec="cea608", mapping_=[ transcoder_v1.types.TextStream.TextMapping( - atom_key="atom0", input_key="caption-input0", input_track=0, + atom_key="atom0", + input_key="caption-input0", + input_track=0, ), ], ), @@ -103,7 +116,9 @@ def create_job_with_embedded_captions( elementary_streams=["video-stream0", "audio-stream0"], ), transcoder_v1.types.MuxStream( - key="sd-dash", container="fmp4", elementary_streams=["video-stream0"], + key="sd-dash", + container="fmp4", + elementary_streams=["video-stream0"], ), transcoder_v1.types.MuxStream( key="audio-dash", @@ -113,7 +128,9 @@ def create_job_with_embedded_captions( ], manifests=[ transcoder_v1.types.Manifest( - file_name="manifest.m3u8", type_="HLS", mux_streams=["sd-hls"], + file_name="manifest.m3u8", + type_="HLS", + mux_streams=["sd-hls"], ), transcoder_v1.types.Manifest( file_name="manifest.mpd", @@ -133,7 +150,9 @@ def create_job_with_embedded_captions( parser = argparse.ArgumentParser() parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) parser.add_argument( - "--location", help="The location to start this job in.", default="us-central1", + "--location", + help="The location to start this job in.", + default="us-central1", ) parser.add_argument( "--input_video_uri", diff --git a/video/transcoder/create_job_with_periodic_images_spritesheet.py b/video/transcoder/create_job_with_periodic_images_spritesheet.py index 95621e2b9ef..1690ba6444f 100644 --- a/video/transcoder/create_job_with_periodic_images_spritesheet.py +++ b/video/transcoder/create_job_with_periodic_images_spritesheet.py @@ -88,14 +88,18 @@ def create_job_with_periodic_images_spritesheet( file_prefix="small-sprite-sheet", sprite_width_pixels=64, sprite_height_pixels=32, - interval=duration.Duration(seconds=7,), + interval=duration.Duration( + seconds=7, + ), ), # Generate a sprite sheet with 128x72px images. An image is taken every 7 seconds from the video. transcoder_v1.types.SpriteSheet( file_prefix="large-sprite-sheet", sprite_width_pixels=128, sprite_height_pixels=72, - interval=duration.Duration(seconds=7,), + interval=duration.Duration( + seconds=7, + ), ), ], ) @@ -110,7 +114,9 @@ def create_job_with_periodic_images_spritesheet( parser = argparse.ArgumentParser() parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) parser.add_argument( - "--location", help="The location to start this job in.", default="us-central1", + "--location", + help="The location to start this job in.", + default="us-central1", ) parser.add_argument( "--input_uri", @@ -124,5 +130,8 @@ def create_job_with_periodic_images_spritesheet( ) args = parser.parse_args() create_job_with_periodic_images_spritesheet( - args.project_id, args.location, args.input_uri, args.output_uri, + args.project_id, + args.location, + args.input_uri, + args.output_uri, ) diff --git a/video/transcoder/create_job_with_set_number_images_spritesheet.py b/video/transcoder/create_job_with_set_number_images_spritesheet.py index b25c872dd24..bc196fb46cc 100644 --- a/video/transcoder/create_job_with_set_number_images_spritesheet.py +++ b/video/transcoder/create_job_with_set_number_images_spritesheet.py @@ -113,7 +113,9 @@ def create_job_with_set_number_images_spritesheet( parser = argparse.ArgumentParser() parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) parser.add_argument( - "--location", help="The location to start this job in.", default="us-central1", + "--location", + help="The location to start this job in.", + default="us-central1", ) parser.add_argument( "--input_uri", @@ -127,5 +129,8 @@ def create_job_with_set_number_images_spritesheet( ) args = parser.parse_args() create_job_with_set_number_images_spritesheet( - args.project_id, args.location, args.input_uri, args.output_uri, + args.project_id, + args.location, + args.input_uri, + args.output_uri, ) diff --git a/video/transcoder/create_job_with_standalone_captions.py b/video/transcoder/create_job_with_standalone_captions.py index 49ccfc8b23f..e8196602b73 100644 --- a/video/transcoder/create_job_with_standalone_captions.py +++ b/video/transcoder/create_job_with_standalone_captions.py @@ -33,7 +33,11 @@ def create_job_with_standalone_captions( - project_id, location, input_video_uri, input_captions_uri, output_uri, + project_id, + location, + input_video_uri, + input_captions_uri, + output_uri, ): """Creates a job based on an ad-hoc job configuration that can use captions from a standalone file. @@ -54,12 +58,19 @@ def create_job_with_standalone_captions( job.output_uri = output_uri job.config = transcoder_v1.types.JobConfig( inputs=[ - transcoder_v1.types.Input(key="input0", uri=input_video_uri,), - transcoder_v1.types.Input(key="caption-input0", uri=input_captions_uri,), + transcoder_v1.types.Input( + key="input0", + uri=input_video_uri, + ), + transcoder_v1.types.Input( + key="caption-input0", + uri=input_captions_uri, + ), ], edit_list=[ transcoder_v1.types.EditAtom( - key="atom0", inputs=["input0", "caption-input0"], + key="atom0", + inputs=["input0", "caption-input0"], ), ], elementary_streams=[ @@ -86,7 +97,9 @@ def create_job_with_standalone_captions( codec="webvtt", mapping_=[ transcoder_v1.types.TextStream.TextMapping( - atom_key="atom0", input_key="caption-input0", input_track=0, + atom_key="atom0", + input_key="caption-input0", + input_track=0, ), ], ), @@ -108,7 +121,9 @@ def create_job_with_standalone_captions( container="vtt", elementary_streams=["vtt-stream0"], segment_settings=transcoder_v1.types.SegmentSettings( - segment_duration=duration.Duration(seconds=6,), + segment_duration=duration.Duration( + seconds=6, + ), individual_segments=True, ), ), @@ -132,7 +147,9 @@ def create_job_with_standalone_captions( parser = argparse.ArgumentParser() parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) parser.add_argument( - "--location", help="The location to start this job in.", default="us-central1", + "--location", + help="The location to start this job in.", + default="us-central1", ) parser.add_argument( "--input_video_uri", diff --git a/video/transcoder/create_job_with_static_overlay.py b/video/transcoder/create_job_with_static_overlay.py index 5386a8a79ef..37ce26b670d 100644 --- a/video/transcoder/create_job_with_static_overlay.py +++ b/video/transcoder/create_job_with_static_overlay.py @@ -81,7 +81,8 @@ def create_job_with_static_overlay( image=transcoder_v1.types.Overlay.Image( uri=overlay_image_uri, resolution=transcoder_v1.types.Overlay.NormalizedCoordinate( - x=1, y=0.5, + x=1, + y=0.5, ), alpha=1, ), @@ -89,14 +90,19 @@ def create_job_with_static_overlay( transcoder_v1.types.Overlay.Animation( animation_static=transcoder_v1.types.Overlay.AnimationStatic( xy=transcoder_v1.types.Overlay.NormalizedCoordinate( - x=0, y=0, + x=0, + y=0, + ), + start_time_offset=duration.Duration( + seconds=0, ), - start_time_offset=duration.Duration(seconds=0,), ), ), transcoder_v1.types.Overlay.Animation( animation_end=transcoder_v1.types.Overlay.AnimationEnd( - start_time_offset=duration.Duration(seconds=10,), + start_time_offset=duration.Duration( + seconds=10, + ), ), ), ], @@ -114,7 +120,9 @@ def create_job_with_static_overlay( parser = argparse.ArgumentParser() parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) parser.add_argument( - "--location", help="The location to start this job in.", default="us-central1", + "--location", + help="The location to start this job in.", + default="us-central1", ) parser.add_argument( "--input_uri", diff --git a/video/transcoder/job_test.py b/video/transcoder/job_test.py index d924472c858..3cc8e6ade12 100644 --- a/video/transcoder/job_test.py +++ b/video/transcoder/job_test.py @@ -271,7 +271,10 @@ def test_create_job_with_animated_overlay(capsys, test_bucket): def test_create_job_with_set_number_spritesheet(capsys, test_bucket): create_job_with_set_number_images_spritesheet.create_job_with_set_number_images_spritesheet( - project_id, location, input_uri, output_uri_for_set_number_spritesheet, + project_id, + location, + input_uri, + output_uri_for_set_number_spritesheet, ) out, _ = capsys.readouterr() job_name_prefix = f"projects/{project_number}/locations/{location}/jobs/" @@ -319,7 +322,10 @@ def test_create_job_with_set_number_spritesheet(capsys, test_bucket): def test_create_job_with_periodic_spritesheet(capsys, test_bucket): create_job_with_periodic_images_spritesheet.create_job_with_periodic_images_spritesheet( - project_id, location, input_uri, output_uri_for_periodic_spritesheet, + project_id, + location, + input_uri, + output_uri_for_periodic_spritesheet, ) out, _ = capsys.readouterr() job_name_prefix = f"projects/{project_number}/locations/{location}/jobs/" @@ -407,7 +413,11 @@ def test_create_job_with_concatenated_inputs(capsys, test_bucket): def test_create_job_with_embedded_captions(capsys, test_bucket): create_job_with_embedded_captions.create_job_with_embedded_captions( - project_id, location, input_uri, captions_uri, output_uri_for_embedded_captions, + project_id, + location, + input_uri, + captions_uri, + output_uri_for_embedded_captions, ) out, _ = capsys.readouterr() job_name_prefix = f"projects/{project_number}/locations/{location}/jobs/" diff --git a/video/transcoder/noxfile.py b/video/transcoder/noxfile.py index 85f5836dba3..25f87a215d4 100644 --- a/video/transcoder/noxfile.py +++ b/video/transcoder/noxfile.py @@ -29,7 +29,7 @@ # WARNING - WARNING - WARNING - WARNING - WARNING # WARNING - WARNING - WARNING - WARNING - WARNING -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" # Copy `noxfile_config.py` to your directory and modify it instead. @@ -253,7 +253,7 @@ def py(session: nox.sessions.Session) -> None: def _get_repo_root() -> Optional[str]: - """ Returns the root folder of the project. """ + """Returns the root folder of the project.""" # Get root of this repository. Assume we don't have directories nested deeper than 10 items. p = Path(os.getcwd()) for i in range(10): From c609ca2f78c6b5c9e09f6162d662743b1baf3f84 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 5 Apr 2022 22:26:59 +0200 Subject: [PATCH 21/86] chore(deps): update dependency google-api-python-client to v2.43.0 (#172) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 67f3d1bed2a..b84cf4e2c62 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.42.0 +google-api-python-client==2.43.0 grpcio==1.44.0 google-cloud-video-transcoder==1.3.1 From 0b51ca0151f621d02fecd19a64da02c0967b27af Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 21 Apr 2022 16:20:17 +0000 Subject: [PATCH 22/86] chore(python): use ubuntu 22.04 in docs image (#181) Source-Link: https://github.com/googleapis/synthtool/commit/f15cc72fb401b4861cedebb10af74afe428fb1f8 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:bc5eed3804aec2f05fad42aacf973821d9500c174015341f721a984a0825b6fd --- video/transcoder/noxfile.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/video/transcoder/noxfile.py b/video/transcoder/noxfile.py index 25f87a215d4..3b3ffa5d2b0 100644 --- a/video/transcoder/noxfile.py +++ b/video/transcoder/noxfile.py @@ -22,7 +22,6 @@ import nox - # WARNING - WARNING - WARNING - WARNING - WARNING # WARNING - WARNING - WARNING - WARNING - WARNING # DO NOT EDIT THIS FILE EVER! @@ -30,6 +29,7 @@ # WARNING - WARNING - WARNING - WARNING - WARNING BLACK_VERSION = "black==22.3.0" +ISORT_VERSION = "isort==5.10.1" # Copy `noxfile_config.py` to your directory and modify it instead. @@ -168,12 +168,33 @@ def lint(session: nox.sessions.Session) -> None: @nox.session def blacken(session: nox.sessions.Session) -> None: + """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) python_files = [path for path in os.listdir(".") if path.endswith(".py")] session.run("black", *python_files) +# +# format = isort + black +# + + +@nox.session +def format(session: nox.sessions.Session) -> None: + """ + Run isort to sort imports. Then run black + to format code to uniform standard. + """ + session.install(BLACK_VERSION, ISORT_VERSION) + python_files = [path for path in os.listdir(".") if path.endswith(".py")] + + # Use the --fss option to sort imports using strict alphabetical order. + # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections + session.run("isort", "--fss", *python_files) + session.run("black", *python_files) + + # # Sample Tests # From b720e990b8ae4ad82d668e193728b0fa514477f8 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 21 Apr 2022 21:52:30 +0200 Subject: [PATCH 23/86] chore(deps): update all dependencies (#177) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps): update all dependencies * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- video/transcoder/requirements-test.txt | 2 +- video/transcoder/requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/video/transcoder/requirements-test.txt b/video/transcoder/requirements-test.txt index c668431b76b..9abbcc6a5cd 100644 --- a/video/transcoder/requirements-test.txt +++ b/video/transcoder/requirements-test.txt @@ -1,3 +1,3 @@ backoff==1.11.1 -google-cloud-storage==2.2.1 +google-cloud-storage==2.3.0 pytest==7.1.1 diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index b84cf4e2c62..8195b78bfc2 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.43.0 +google-api-python-client==2.45.0 grpcio==1.44.0 google-cloud-video-transcoder==1.3.1 From c9fc2aeddaca398b62f64928a01ef3fe1405fb5f Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 25 Apr 2022 17:07:10 +0200 Subject: [PATCH 24/86] chore(deps): update dependency pytest to v7.1.2 (#182) --- video/transcoder/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements-test.txt b/video/transcoder/requirements-test.txt index 9abbcc6a5cd..04b0ba93c5e 100644 --- a/video/transcoder/requirements-test.txt +++ b/video/transcoder/requirements-test.txt @@ -1,3 +1,3 @@ backoff==1.11.1 google-cloud-storage==2.3.0 -pytest==7.1.1 +pytest==7.1.2 From 42e378f8c1b444c6cda6aa70c6c9c8b1918fb9ce Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 26 Apr 2022 20:44:54 +0200 Subject: [PATCH 25/86] chore(deps): update all dependencies (#183) --- video/transcoder/requirements-test.txt | 2 +- video/transcoder/requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/video/transcoder/requirements-test.txt b/video/transcoder/requirements-test.txt index 04b0ba93c5e..bc367b005b2 100644 --- a/video/transcoder/requirements-test.txt +++ b/video/transcoder/requirements-test.txt @@ -1,3 +1,3 @@ -backoff==1.11.1 +backoff==2.0.0 google-cloud-storage==2.3.0 pytest==7.1.2 diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 8195b78bfc2..b9fd4c4b984 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.45.0 +google-api-python-client==2.46.0 grpcio==1.44.0 google-cloud-video-transcoder==1.3.1 From 71dfee9726ec567f14fa3ac3c808e05ae0476bf2 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 27 Apr 2022 19:31:05 +0200 Subject: [PATCH 26/86] chore(deps): update dependency backoff to v2.0.1 (#185) --- video/transcoder/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements-test.txt b/video/transcoder/requirements-test.txt index bc367b005b2..abd7bd02604 100644 --- a/video/transcoder/requirements-test.txt +++ b/video/transcoder/requirements-test.txt @@ -1,3 +1,3 @@ -backoff==2.0.0 +backoff==2.0.1 google-cloud-storage==2.3.0 pytest==7.1.2 From 62c30681e6087566417a03f2d8441edb7fe263cb Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 3 May 2022 20:19:41 +0200 Subject: [PATCH 27/86] chore(deps): update dependency google-api-python-client to v2.47.0 (#186) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index b9fd4c4b984..0d43bc76aa5 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.46.0 +google-api-python-client==2.47.0 grpcio==1.44.0 google-cloud-video-transcoder==1.3.1 From de15758021b2e083907990dee3a76eeda0e7eeea Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 5 May 2022 02:44:46 +0200 Subject: [PATCH 28/86] chore(deps): update dependency grpcio to v1.46.0 (#187) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 0d43bc76aa5..3efbc0ae279 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ google-api-python-client==2.47.0 -grpcio==1.44.0 +grpcio==1.46.0 google-cloud-video-transcoder==1.3.1 From 8d165f34f9e4816c9b5f65adb9e44699181c26e8 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 12 May 2022 20:17:18 +0200 Subject: [PATCH 29/86] chore(deps): update dependency grpcio to v1.46.1 (#190) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 3efbc0ae279..16787060c54 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ google-api-python-client==2.47.0 -grpcio==1.46.0 +grpcio==1.46.1 google-cloud-video-transcoder==1.3.1 From a5cbd6b21b303d9d54b0fbece680ba54adca597a Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 17 May 2022 20:49:34 +0200 Subject: [PATCH 30/86] chore(deps): update dependency google-api-python-client to v2.48.0 (#191) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 16787060c54..bb383d1238e 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.47.0 +google-api-python-client==2.48.0 grpcio==1.46.1 google-cloud-video-transcoder==1.3.1 From 3bdb002c86cf02a1356217d9f56e76144761c618 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Sun, 22 May 2022 20:08:33 +0200 Subject: [PATCH 31/86] chore(deps): update dependency grpcio to v1.46.3 (#192) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index bb383d1238e..3fe42cdaf39 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ google-api-python-client==2.48.0 -grpcio==1.46.1 +grpcio==1.46.3 google-cloud-video-transcoder==1.3.1 From e06202af38afddc62621705cd237937517ce6ce2 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 27 May 2022 19:50:12 +0200 Subject: [PATCH 32/86] chore(deps): update dependency google-api-python-client to v2.49.0 (#193) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 3fe42cdaf39..6bd06b828c7 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.48.0 +google-api-python-client==2.49.0 grpcio==1.46.3 google-cloud-video-transcoder==1.3.1 From a7327cf4991d5998fe7945beb7cff2bbcacdf2c1 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sat, 9 Jul 2022 06:47:21 -0400 Subject: [PATCH 33/86] fix: require python 3.7+ (#208) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(python): drop python 3.6 Source-Link: https://github.com/googleapis/synthtool/commit/4f89b13af10d086458f9b379e56a614f9d6dab7b Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:e7bb19d47c13839fe8c147e50e02e8b6cf5da8edd1af8b82208cd6f66cc2829c * add api_description to .repo-metadata.json * require python 3.7+ in setup.py * remove python 3.6 sample configs * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- video/transcoder/noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/noxfile.py b/video/transcoder/noxfile.py index 3b3ffa5d2b0..e9eb1cbfa5d 100644 --- a/video/transcoder/noxfile.py +++ b/video/transcoder/noxfile.py @@ -88,7 +88,7 @@ def get_pytest_env_vars() -> Dict[str, str]: # DO NOT EDIT - automatically generated. # All versions used to test samples. -ALL_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"] +ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10"] # Any default versions that should be ignored. IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"] From b210a4e79cdae34a4bc313739d5deb6c5b49bca3 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Sat, 16 Jul 2022 17:17:17 +0200 Subject: [PATCH 34/86] chore(deps): update all dependencies (#200) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps): update all dependencies * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * revert Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- video/transcoder/requirements-test.txt | 2 +- video/transcoder/requirements.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/video/transcoder/requirements-test.txt b/video/transcoder/requirements-test.txt index abd7bd02604..5eb2469ae0f 100644 --- a/video/transcoder/requirements-test.txt +++ b/video/transcoder/requirements-test.txt @@ -1,3 +1,3 @@ -backoff==2.0.1 +backoff==2.1.2 google-cloud-storage==2.3.0 pytest==7.1.2 diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 6bd06b828c7..37a02c8bc16 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.49.0 +google-api-python-client==2.50.0 grpcio==1.46.3 -google-cloud-video-transcoder==1.3.1 +google-cloud-video-transcoder==1.3.2 From c4ba198c32636fa0da2281528bbcbf2517c0b31c Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 2 Aug 2022 14:44:08 +0200 Subject: [PATCH 35/86] chore(deps): update all dependencies (#212) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps): update all dependencies * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * revert Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- video/transcoder/requirements-test.txt | 2 +- video/transcoder/requirements.txt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/video/transcoder/requirements-test.txt b/video/transcoder/requirements-test.txt index 5eb2469ae0f..410fb32441c 100644 --- a/video/transcoder/requirements-test.txt +++ b/video/transcoder/requirements-test.txt @@ -1,3 +1,3 @@ backoff==2.1.2 -google-cloud-storage==2.3.0 +google-cloud-storage==2.4.0 pytest==7.1.2 diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 37a02c8bc16..335f00275e2 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.50.0 -grpcio==1.46.3 -google-cloud-video-transcoder==1.3.2 +google-api-python-client==2.55.0 +grpcio==1.47.0 +google-cloud-video-transcoder==1.4.0 From 7563479139eb50eee9540f8d84dede75e523a74d Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 5 Aug 2022 21:46:58 +0200 Subject: [PATCH 36/86] chore(deps): update all dependencies (#214) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps): update all dependencies * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * revert Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- video/transcoder/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements-test.txt b/video/transcoder/requirements-test.txt index 410fb32441c..8179829852e 100644 --- a/video/transcoder/requirements-test.txt +++ b/video/transcoder/requirements-test.txt @@ -1,3 +1,3 @@ backoff==2.1.2 -google-cloud-storage==2.4.0 +google-cloud-storage==2.5.0 pytest==7.1.2 From 31f09fc231de46a65869547fc600dd92fccbdd50 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 10 Aug 2022 18:57:41 +0200 Subject: [PATCH 37/86] chore(deps): update all dependencies to v2.56.0 (#216) * chore(deps): update all dependencies to v2.56.0 * revert Co-authored-by: Anthonios Partheniou --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 335f00275e2..50e9cfee5ab 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.55.0 +google-api-python-client==2.56.0 grpcio==1.47.0 google-cloud-video-transcoder==1.4.0 From 158e29637ed238f035e009a77f249d93ad3fdfb7 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 16 Aug 2022 16:40:52 +0200 Subject: [PATCH 38/86] chore(deps): update dependency google-cloud-video-transcoder to v1.4.1 (#220) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 50e9cfee5ab..085647ee97a 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ google-api-python-client==2.56.0 grpcio==1.47.0 -google-cloud-video-transcoder==1.4.0 +google-cloud-video-transcoder==1.4.1 From a149eb50bcd9d47c2ade2350011db8d0b5f4c123 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 16 Aug 2022 16:58:36 +0200 Subject: [PATCH 39/86] chore(deps): update dependency google-api-python-client to v2.57.0 (#221) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 085647ee97a..d21e3822637 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.56.0 +google-api-python-client==2.57.0 grpcio==1.47.0 google-cloud-video-transcoder==1.4.1 From 778c40f5b854dc4c10cba972eb09be924621078a Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 23 Aug 2022 19:04:06 +0200 Subject: [PATCH 40/86] chore(deps): update dependency google-api-python-client to v2.58.0 (#222) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index d21e3822637..5b78eb744dd 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.57.0 +google-api-python-client==2.58.0 grpcio==1.47.0 google-cloud-video-transcoder==1.4.1 From 33c959270b7036ce15032928fc3c8943d46fea60 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 2 Sep 2022 13:16:36 +0200 Subject: [PATCH 41/86] chore(deps): update dependency grpcio to v1.48.1 (#228) Co-authored-by: Anthonios Partheniou --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 5b78eb744dd..5453363a4b2 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ google-api-python-client==2.58.0 -grpcio==1.47.0 +grpcio==1.48.1 google-cloud-video-transcoder==1.4.1 From 901a4e7034ce5500f529600fe0c2bdf96d299621 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 6 Sep 2022 17:16:52 +0200 Subject: [PATCH 42/86] chore(deps): update dependency pytest to v7.1.3 (#231) * chore(deps): update all dependencies * revert Co-authored-by: Anthonios Partheniou --- video/transcoder/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements-test.txt b/video/transcoder/requirements-test.txt index 8179829852e..57f6f4c2b66 100644 --- a/video/transcoder/requirements-test.txt +++ b/video/transcoder/requirements-test.txt @@ -1,3 +1,3 @@ backoff==2.1.2 google-cloud-storage==2.5.0 -pytest==7.1.2 +pytest==7.1.3 From 9a37c84fef37bf4a27a4f53c1506e25f9cf8913a Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 7 Sep 2022 15:44:59 +0200 Subject: [PATCH 43/86] chore(deps): update dependency google-api-python-client to v2.60.0 (#232) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 5453363a4b2..dbc055c5eae 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.58.0 +google-api-python-client==2.60.0 grpcio==1.48.1 google-cloud-video-transcoder==1.4.1 From eaffba55fe224c829b1fb5f5b6c9814217aedcc4 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 13 Sep 2022 16:14:11 +0000 Subject: [PATCH 44/86] chore: detect samples tests in nested directories (#236) Source-Link: https://github.com/googleapis/synthtool/commit/50db768f450a50d7c1fd62513c113c9bb96fd434 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:e09366bdf0fd9c8976592988390b24d53583dd9f002d476934da43725adbb978 --- video/transcoder/noxfile.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/video/transcoder/noxfile.py b/video/transcoder/noxfile.py index e9eb1cbfa5d..c1715136d64 100644 --- a/video/transcoder/noxfile.py +++ b/video/transcoder/noxfile.py @@ -207,8 +207,10 @@ def _session_tests( session: nox.sessions.Session, post_install: Callable = None ) -> None: # check for presence of tests - test_list = glob.glob("*_test.py") + glob.glob("test_*.py") - test_list.extend(glob.glob("tests")) + test_list = glob.glob("**/*_test.py", recursive=True) + glob.glob( + "**/test_*.py", recursive=True + ) + test_list.extend(glob.glob("**/tests", recursive=True)) if len(test_list) == 0: print("No tests found, skipping directory.") From 880a2cbc83d475f17cce84dc7b110b0c334dfc7b Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 14 Sep 2022 15:51:01 +0200 Subject: [PATCH 45/86] chore(deps): update dependency google-api-python-client to v2.61.0 (#237) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index dbc055c5eae..4e38d1473bf 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.60.0 +google-api-python-client==2.61.0 grpcio==1.48.1 google-cloud-video-transcoder==1.4.1 From a9afbb0bc22e8b57e84037e9ea518d51f12e05a5 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 16 Sep 2022 17:52:59 +0200 Subject: [PATCH 46/86] chore(deps): update dependency grpcio to v1.49.0 (#238) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 4e38d1473bf..df3b1b86ef3 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ google-api-python-client==2.61.0 -grpcio==1.48.1 +grpcio==1.49.0 google-cloud-video-transcoder==1.4.1 From f9b0b720bcd3b1b302bc447a2ce867c8df03ab40 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 20 Sep 2022 14:58:44 +0200 Subject: [PATCH 47/86] chore(deps): update dependency google-api-python-client to v2.62.0 (#239) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index df3b1b86ef3..abdf68efd3b 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.61.0 +google-api-python-client==2.62.0 grpcio==1.49.0 google-cloud-video-transcoder==1.4.1 From 56b56cbddf6cf79553963e7ea9e90f36388f07cb Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 4 Oct 2022 02:58:54 +0200 Subject: [PATCH 48/86] chore(deps): update all dependencies (#240) Co-authored-by: Anthonios Partheniou --- video/transcoder/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index abdf68efd3b..1a6209085c6 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.62.0 -grpcio==1.49.0 +google-api-python-client==2.63.0 +grpcio==1.49.1 google-cloud-video-transcoder==1.4.1 From 8cbace60227079f8608c6509907336d8f8a857b9 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 4 Oct 2022 03:17:52 +0200 Subject: [PATCH 49/86] chore(deps): update dependency google-cloud-video-transcoder to v1.4.2 (#243) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 1a6209085c6..92eb11edd36 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ google-api-python-client==2.63.0 grpcio==1.49.1 -google-cloud-video-transcoder==1.4.1 +google-cloud-video-transcoder==1.4.2 From 3eb476089afcdef4f0b4b90d65353a8aef1823dd Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 4 Oct 2022 18:15:57 +0200 Subject: [PATCH 50/86] chore(deps): update dependency google-api-python-client to v2.64.0 (#244) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 92eb11edd36..57f3b6c1cc1 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.63.0 +google-api-python-client==2.64.0 grpcio==1.49.1 google-cloud-video-transcoder==1.4.2 From 3c10a4240756d8b2c5fd316ebcc8f9c0f8b752a5 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 6 Oct 2022 15:35:07 +0200 Subject: [PATCH 51/86] chore(deps): update dependency backoff to v2.2.1 (#245) --- video/transcoder/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements-test.txt b/video/transcoder/requirements-test.txt index 57f6f4c2b66..c94d751026f 100644 --- a/video/transcoder/requirements-test.txt +++ b/video/transcoder/requirements-test.txt @@ -1,3 +1,3 @@ -backoff==2.1.2 +backoff==2.2.1 google-cloud-storage==2.5.0 pytest==7.1.3 From 89b2298efa6b4459b4ab23325e1711e6fe2e25cc Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 10 Oct 2022 20:15:30 +0200 Subject: [PATCH 52/86] chore(deps): update dependency google-cloud-video-transcoder to v1.4.3 (#248) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 57f3b6c1cc1..1004ec9940c 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ google-api-python-client==2.64.0 grpcio==1.49.1 -google-cloud-video-transcoder==1.4.2 +google-cloud-video-transcoder==1.4.3 From bd575b719a626ef496e88b13b6f1961b7f83247b Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 19 Oct 2022 16:05:35 +0200 Subject: [PATCH 53/86] chore(deps): update all dependencies (#249) --- video/transcoder/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 1004ec9940c..422ae145d36 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.64.0 -grpcio==1.49.1 +google-api-python-client==2.65.0 +grpcio==1.50.0 google-cloud-video-transcoder==1.4.3 From 24017e5ac03c0688f2f56d6a07584d5b471876cf Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 26 Oct 2022 12:56:33 +0200 Subject: [PATCH 54/86] chore(deps): update dependency pytest to v7.2.0 (#250) --- video/transcoder/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements-test.txt b/video/transcoder/requirements-test.txt index c94d751026f..f72a4b1c1b7 100644 --- a/video/transcoder/requirements-test.txt +++ b/video/transcoder/requirements-test.txt @@ -1,3 +1,3 @@ backoff==2.2.1 google-cloud-storage==2.5.0 -pytest==7.1.3 +pytest==7.2.0 From cc900efee86e7a18be989000209801a0ef3e6314 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sat, 26 Nov 2022 07:12:41 -0500 Subject: [PATCH 55/86] chore(python): drop flake8-import-order in samples noxfile (#256) Source-Link: https://github.com/googleapis/synthtool/commit/6ed3a831cb9ff69ef8a504c353e098ec0192ad93 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:3abfa0f1886adaf0b83f07cb117b24a639ea1cb9cffe56d43280b977033563eb Co-authored-by: Owl Bot --- video/transcoder/noxfile.py | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/video/transcoder/noxfile.py b/video/transcoder/noxfile.py index c1715136d64..0577084695f 100644 --- a/video/transcoder/noxfile.py +++ b/video/transcoder/noxfile.py @@ -18,7 +18,7 @@ import os from pathlib import Path import sys -from typing import Callable, Dict, List, Optional +from typing import Callable, Dict, Optional import nox @@ -108,22 +108,6 @@ def get_pytest_env_vars() -> Dict[str, str]: # -def _determine_local_import_names(start_dir: str) -> List[str]: - """Determines all import names that should be considered "local". - - This is used when running the linter to insure that import order is - properly checked. - """ - file_ext_pairs = [os.path.splitext(path) for path in os.listdir(start_dir)] - return [ - basename - for basename, extension in file_ext_pairs - if extension == ".py" - or os.path.isdir(os.path.join(start_dir, basename)) - and basename not in ("__pycache__") - ] - - # Linting with flake8. # # We ignore the following rules: @@ -138,7 +122,6 @@ def _determine_local_import_names(start_dir: str) -> List[str]: "--show-source", "--builtin=gettext", "--max-complexity=20", - "--import-order-style=google", "--exclude=.nox,.cache,env,lib,generated_pb2,*_pb2.py,*_pb2_grpc.py", "--ignore=E121,E123,E126,E203,E226,E24,E266,E501,E704,W503,W504,I202", "--max-line-length=88", @@ -148,14 +131,11 @@ def _determine_local_import_names(start_dir: str) -> List[str]: @nox.session def lint(session: nox.sessions.Session) -> None: if not TEST_CONFIG["enforce_type_hints"]: - session.install("flake8", "flake8-import-order") + session.install("flake8") else: - session.install("flake8", "flake8-import-order", "flake8-annotations") + session.install("flake8", "flake8-annotations") - local_names = _determine_local_import_names(".") args = FLAKE8_COMMON_ARGS + [ - "--application-import-names", - ",".join(local_names), ".", ] session.run("flake8", *args) From 42c0f1cf72c4fe932a04533ceee46614f3269f80 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Sat, 26 Nov 2022 13:23:55 +0100 Subject: [PATCH 56/86] chore(deps): update all dependencies (#253) Co-authored-by: Anthonios Partheniou --- video/transcoder/requirements-test.txt | 2 +- video/transcoder/requirements.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/video/transcoder/requirements-test.txt b/video/transcoder/requirements-test.txt index f72a4b1c1b7..706186f292f 100644 --- a/video/transcoder/requirements-test.txt +++ b/video/transcoder/requirements-test.txt @@ -1,3 +1,3 @@ backoff==2.2.1 -google-cloud-storage==2.5.0 +google-cloud-storage==2.6.0 pytest==7.2.0 diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 422ae145d36..d187ba69af6 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.65.0 -grpcio==1.50.0 +google-api-python-client==2.66.0 +grpcio==1.51.0 google-cloud-video-transcoder==1.4.3 From 58f67e654c6db8179d46c1c6171d573884bf05e7 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Thu, 15 Dec 2022 19:55:30 +0100 Subject: [PATCH 57/86] chore(deps): update all dependencies (#258) Co-authored-by: Anthonios Partheniou --- video/transcoder/requirements-test.txt | 2 +- video/transcoder/requirements.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/video/transcoder/requirements-test.txt b/video/transcoder/requirements-test.txt index 706186f292f..1a8a4ffc16c 100644 --- a/video/transcoder/requirements-test.txt +++ b/video/transcoder/requirements-test.txt @@ -1,3 +1,3 @@ backoff==2.2.1 -google-cloud-storage==2.6.0 +google-cloud-storage==2.7.0 pytest==7.2.0 diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index d187ba69af6..cc03ca62d99 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.66.0 -grpcio==1.51.0 +google-api-python-client==2.69.0 +grpcio==1.51.1 google-cloud-video-transcoder==1.4.3 From c254f280fe6da55c3842205caa2cd7969ac43165 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Thu, 15 Dec 2022 20:12:17 +0100 Subject: [PATCH 58/86] chore(deps): update dependency google-api-python-client to v2.70.0 (#261) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index cc03ca62d99..8a601ad7c3a 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.69.0 +google-api-python-client==2.70.0 grpcio==1.51.1 google-cloud-video-transcoder==1.4.3 From e0977b5e523f58675b1fb7074b23b7099e041ac6 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Fri, 16 Dec 2022 03:25:44 +0100 Subject: [PATCH 59/86] chore(deps): update dependency google-cloud-video-transcoder to v1.5.0 (#262) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 8a601ad7c3a..80c4b41d759 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ google-api-python-client==2.70.0 grpcio==1.51.1 -google-cloud-video-transcoder==1.4.3 +google-cloud-video-transcoder==1.5.0 From 9441e98ea6f08ceec4d0d431f4c7e042171316b0 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Wed, 4 Jan 2023 21:47:24 +0100 Subject: [PATCH 60/86] chore(deps): update dependency google-api-python-client to v2.71.0 (#263) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 80c4b41d759..82ed99f023f 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.70.0 +google-api-python-client==2.71.0 grpcio==1.51.1 google-cloud-video-transcoder==1.5.0 From 07d9645367f431e501aa4a94a7980189f3b876e8 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 6 Jan 2023 13:16:57 -0500 Subject: [PATCH 61/86] chore(python): add support for python 3.11 (#264) Source-Link: https://github.com/googleapis/synthtool/commit/7197a001ffb6d8ce7b0b9b11c280f0c536c1033a Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:c43f1d918bcf817d337aa29ff833439494a158a0831508fda4ec75dc4c0d0320 Co-authored-by: Owl Bot --- video/transcoder/noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/noxfile.py b/video/transcoder/noxfile.py index 0577084695f..de104dbc64d 100644 --- a/video/transcoder/noxfile.py +++ b/video/transcoder/noxfile.py @@ -88,7 +88,7 @@ def get_pytest_env_vars() -> Dict[str, str]: # DO NOT EDIT - automatically generated. # All versions used to test samples. -ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10"] +ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11"] # Any default versions that should be ignored. IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"] From a34a82374c60bf076481e50b87271c00e498c6f2 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Tue, 10 Jan 2023 18:33:14 +0000 Subject: [PATCH 62/86] chore(deps): update dependency google-api-python-client to v2.72.0 (#267) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 82ed99f023f..821cdeddfe1 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.71.0 +google-api-python-client==2.72.0 grpcio==1.51.1 google-cloud-video-transcoder==1.5.0 From 56ad435abe0b80b5a6351c95881b168f7f15b780 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Tue, 10 Jan 2023 19:00:26 +0000 Subject: [PATCH 63/86] chore(deps): update dependency google-cloud-video-transcoder to v1.6.0 (#268) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 821cdeddfe1..c863076b901 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ google-api-python-client==2.72.0 grpcio==1.51.1 -google-cloud-video-transcoder==1.5.0 +google-cloud-video-transcoder==1.6.0 From 375ee453521e070e5fd0c6e7976ab97d981f39cc Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Sat, 14 Jan 2023 18:14:43 +0000 Subject: [PATCH 64/86] chore(deps): update dependency pytest to v7.2.1 (#269) --- video/transcoder/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements-test.txt b/video/transcoder/requirements-test.txt index 1a8a4ffc16c..0f8c1f97ee8 100644 --- a/video/transcoder/requirements-test.txt +++ b/video/transcoder/requirements-test.txt @@ -1,3 +1,3 @@ backoff==2.2.1 google-cloud-storage==2.7.0 -pytest==7.2.0 +pytest==7.2.1 From bd0fbd40fb31fecdc0f58beda99da10c4372c85c Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Tue, 17 Jan 2023 17:25:09 +0000 Subject: [PATCH 65/86] chore(deps): update dependency google-api-python-client to v2.73.0 (#270) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index c863076b901..4cc009adcb1 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.72.0 +google-api-python-client==2.73.0 grpcio==1.51.1 google-cloud-video-transcoder==1.6.0 From 94742ae29f40bdee023f9c40d3bd4cc3ad5bb387 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Mon, 23 Jan 2023 16:36:46 +0000 Subject: [PATCH 66/86] chore(deps): update dependency google-cloud-video-transcoder to v1.6.1 (#273) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 4cc009adcb1..cee1a80931e 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ google-api-python-client==2.73.0 grpcio==1.51.1 -google-cloud-video-transcoder==1.6.0 +google-cloud-video-transcoder==1.6.1 From 81d6f73f9b099037f4bdd148c5d7d659c2608f7a Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Wed, 25 Jan 2023 18:43:38 +0000 Subject: [PATCH 67/86] chore(deps): update dependency google-api-python-client to v2.74.0 (#275) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index cee1a80931e..164ab5a3f01 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.73.0 +google-api-python-client==2.74.0 grpcio==1.51.1 google-cloud-video-transcoder==1.6.1 From 562c8b49b6e4596229fa60184bc081bc600aee7a Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Tue, 31 Jan 2023 17:43:36 +0000 Subject: [PATCH 68/86] chore(deps): update dependency google-api-python-client to v2.75.0 (#277) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 164ab5a3f01..b3d5187b132 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.74.0 +google-api-python-client==2.75.0 grpcio==1.51.1 google-cloud-video-transcoder==1.6.1 From 281c461762d279d2b77c6ca40fde231acfe186ea Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Fri, 3 Feb 2023 11:17:12 +0000 Subject: [PATCH 69/86] chore(deps): update dependency google-api-python-client to v2.76.0 (#278) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index b3d5187b132..5f11225c047 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.75.0 +google-api-python-client==2.76.0 grpcio==1.51.1 google-cloud-video-transcoder==1.6.1 From d2546a7e20adb996ee68fa32f375150e78f830b6 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Wed, 8 Feb 2023 20:15:04 +0000 Subject: [PATCH 70/86] chore(deps): update dependency google-api-python-client to v2.77.0 (#281) Co-authored-by: Anthonios Partheniou --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 5f11225c047..0b83089839a 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.76.0 +google-api-python-client==2.77.0 grpcio==1.51.1 google-cloud-video-transcoder==1.6.1 From 0b31ff210352bbf09b05a425ec824bd134447ced Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Wed, 15 Feb 2023 22:42:42 +0000 Subject: [PATCH 71/86] chore(deps): update dependency google-api-python-client to v2.78.0 (#284) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 0b83089839a..ef3da3ee38a 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.77.0 +google-api-python-client==2.78.0 grpcio==1.51.1 google-cloud-video-transcoder==1.6.1 From 294ca238017ec93803a94260341d75c02ff8a96c Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Wed, 1 Mar 2023 10:26:55 +0000 Subject: [PATCH 72/86] chore(deps): update all dependencies (#285) Co-authored-by: Anthonios Partheniou --- video/transcoder/requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index ef3da3ee38a..d8b984abd28 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.78.0 -grpcio==1.51.1 -google-cloud-video-transcoder==1.6.1 +google-api-python-client==2.79.0 +grpcio==1.51.3 +google-cloud-video-transcoder==1.7.0 From 05aff29e6a5ec57f7e525497531d0eda3079c7fc Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Wed, 1 Mar 2023 13:49:41 +0000 Subject: [PATCH 73/86] chore(deps): update dependency google-api-python-client to v2.80.0 (#290) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index d8b984abd28..72b55627339 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.79.0 +google-api-python-client==2.80.0 grpcio==1.51.3 google-cloud-video-transcoder==1.7.0 From cb545ce5a696c8aa899379b7c6e7cc7f652ab668 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Wed, 1 Mar 2023 20:42:46 +0000 Subject: [PATCH 74/86] chore(deps): update dependency google-cloud-video-transcoder to v1.8.0 (#291) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 72b55627339..71f7a44212e 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ google-api-python-client==2.80.0 grpcio==1.51.3 -google-cloud-video-transcoder==1.7.0 +google-cloud-video-transcoder==1.8.0 From 2c62daeb681187de02073109d778faa872307999 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Sat, 4 Mar 2023 11:30:13 +0000 Subject: [PATCH 75/86] chore(deps): update dependency pytest to v7.2.2 (#293) --- video/transcoder/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements-test.txt b/video/transcoder/requirements-test.txt index 0f8c1f97ee8..810fe2da3c8 100644 --- a/video/transcoder/requirements-test.txt +++ b/video/transcoder/requirements-test.txt @@ -1,3 +1,3 @@ backoff==2.2.1 google-cloud-storage==2.7.0 -pytest==7.2.1 +pytest==7.2.2 From dd37186a4b15e5bb02bee69374a0e7c3d2578298 Mon Sep 17 00:00:00 2001 From: Nicholas Cook Date: Tue, 11 Apr 2023 15:28:41 -0700 Subject: [PATCH 76/86] =?UTF-8?q?feat(Transcoder):=20update=20captions=20c?= =?UTF-8?q?ode=20samples=20for=20display=20name=20and=20l=E2=80=A6=20(#292?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(Transcoder): update captions code samples for display name and language * test bucket should be deleted * Trigger Build --- .../create_job_with_embedded_captions.py | 12 ++- .../create_job_with_standalone_captions.py | 81 ++++++++++++++----- video/transcoder/job_test.py | 9 ++- 3 files changed, 75 insertions(+), 27 deletions(-) diff --git a/video/transcoder/create_job_with_embedded_captions.py b/video/transcoder/create_job_with_embedded_captions.py index 9943889635a..58f985dbaf6 100644 --- a/video/transcoder/create_job_with_embedded_captions.py +++ b/video/transcoder/create_job_with_embedded_captions.py @@ -38,7 +38,7 @@ def create_job_with_embedded_captions( input_captions_uri, output_uri, ): - """Creates a job based on an ad-hoc job configuration that embeds captions in the output video. + """Creates a job based on an ad-hoc job configuration that embeds closed captions in the output video. Args: project_id (str): The GCP project ID. @@ -87,7 +87,8 @@ def create_job_with_embedded_captions( transcoder_v1.types.ElementaryStream( key="audio-stream0", audio_stream=transcoder_v1.types.AudioStream( - codec="aac", bitrate_bps=64000 + codec="aac", + bitrate_bps=64000, ), ), transcoder_v1.types.ElementaryStream( @@ -101,15 +102,12 @@ def create_job_with_embedded_captions( input_track=0, ), ], + language_code="en-US", + display_name="English", ), ), ], mux_streams=[ - transcoder_v1.types.MuxStream( - key="sd", - container="mp4", - elementary_streams=["video-stream0", "audio-stream0"], - ), transcoder_v1.types.MuxStream( key="sd-hls", container="ts", diff --git a/video/transcoder/create_job_with_standalone_captions.py b/video/transcoder/create_job_with_standalone_captions.py index e8196602b73..4524185d673 100644 --- a/video/transcoder/create_job_with_standalone_captions.py +++ b/video/transcoder/create_job_with_standalone_captions.py @@ -14,11 +14,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Google Cloud Transcoder sample for creating a job that can use captions from a standalone file. +"""Google Cloud Transcoder sample for creating a job that can use subtitles from a standalone file. Example usage: python create_job_with_standalone_captions.py --project_id --location \ - --input_video_uri --input_captions_uri --output_uri + --input_video_uri --input_subtitles1_uri --input_subtitles2_uri --output_uri """ # [START transcoder_create_job_with_standalone_captions] @@ -36,17 +36,20 @@ def create_job_with_standalone_captions( project_id, location, input_video_uri, - input_captions_uri, + input_subtitles1_uri, + input_subtitles2_uri, output_uri, ): - """Creates a job based on an ad-hoc job configuration that can use captions from a standalone file. + """Creates a job based on an ad-hoc job configuration that can use subtitles from a standalone file. Args: project_id (str): The GCP project ID. location (str): The location to start the job in. input_video_uri (str): Uri of the input video in the Cloud Storage bucket. - input_captions_uri (str): Uri of the input captions file in the Cloud + input_subtitles1_uri (str): Uri of an input subtitles file in the Cloud + Storage bucket. + input_subtitles2_uri (str): Uri of an input subtitles file in the Cloud Storage bucket. output_uri (str): Uri of the video output folder in the Cloud Storage bucket.""" @@ -63,14 +66,18 @@ def create_job_with_standalone_captions( uri=input_video_uri, ), transcoder_v1.types.Input( - key="caption-input0", - uri=input_captions_uri, + key="subtitle-input-en", + uri=input_subtitles1_uri, + ), + transcoder_v1.types.Input( + key="subtitle-input-es", + uri=input_subtitles2_uri, ), ], edit_list=[ transcoder_v1.types.EditAtom( key="atom0", - inputs=["input0", "caption-input0"], + inputs=["input0", "subtitle-input-en", "subtitle-input-es"], ), ], elementary_streams=[ @@ -88,18 +95,34 @@ def create_job_with_standalone_captions( transcoder_v1.types.ElementaryStream( key="audio-stream0", audio_stream=transcoder_v1.types.AudioStream( - codec="aac", bitrate_bps=64000 + codec="aac", + bitrate_bps=64000, + ), + ), + transcoder_v1.types.ElementaryStream( + key="vtt-stream-en", + text_stream=transcoder_v1.types.TextStream( + codec="webvtt", + language_code="en-US", + display_name="English", + mapping_=[ + transcoder_v1.types.TextStream.TextMapping( + atom_key="atom0", + input_key="subtitle-input-en", + ), + ], ), ), transcoder_v1.types.ElementaryStream( - key="vtt-stream0", + key="vtt-stream-es", text_stream=transcoder_v1.types.TextStream( codec="webvtt", + language_code="es-ES", + display_name="Spanish", mapping_=[ transcoder_v1.types.TextStream.TextMapping( atom_key="atom0", - input_key="caption-input0", - input_track=0, + input_key="subtitle-input-es", ), ], ), @@ -117,9 +140,20 @@ def create_job_with_standalone_captions( elementary_streams=["audio-stream0"], ), transcoder_v1.types.MuxStream( - key="text-vtt", + key="text-vtt-en", container="vtt", - elementary_streams=["vtt-stream0"], + elementary_streams=["vtt-stream-en"], + segment_settings=transcoder_v1.types.SegmentSettings( + segment_duration=duration.Duration( + seconds=6, + ), + individual_segments=True, + ), + ), + transcoder_v1.types.MuxStream( + key="text-vtt-es", + container="vtt", + elementary_streams=["vtt-stream-es"], segment_settings=transcoder_v1.types.SegmentSettings( segment_duration=duration.Duration( seconds=6, @@ -132,7 +166,12 @@ def create_job_with_standalone_captions( transcoder_v1.types.Manifest( file_name="manifest.m3u8", type_="HLS", - mux_streams=["sd-hls-fmp4", "audio-hls-fmp4", "text-vtt"], + mux_streams=[ + "sd-hls-fmp4", + "audio-hls-fmp4", + "text-vtt-en", + "text-vtt-es", + ], ), ], ) @@ -157,8 +196,13 @@ def create_job_with_standalone_captions( required=True, ) parser.add_argument( - "--input_captions_uri", - help="Uri of the input captions file in the Cloud Storage bucket.", + "--input_subtitles1_uri", + help="Uri of an input subtitles file in the Cloud Storage bucket.", + required=True, + ) + parser.add_argument( + "--input_subtitles2_uri", + help="Uri of an input subtitles file in the Cloud Storage bucket.", required=True, ) parser.add_argument( @@ -172,6 +216,7 @@ def create_job_with_standalone_captions( args.project_id, args.location, args.input_video_uri, - args.input_captions_uri, + args.input_subtitles1_uri, + args.input_subtitles2_uri, args.output_uri, ) diff --git a/video/transcoder/job_test.py b/video/transcoder/job_test.py index 3cc8e6ade12..6dbf8cd1fb3 100644 --- a/video/transcoder/job_test.py +++ b/video/transcoder/job_test.py @@ -49,13 +49,17 @@ test_overlay_image_file_name = "overlay.jpg" test_concat1_file_name = "ForBiggerEscapes.mp4" test_concat2_file_name = "ForBiggerJoyrides.mp4" -test_captions_file_name = "caption.srt" +test_captions_file_name = "captions.srt" +test_subtitles1_file_name = "subtitles-en.srt" +test_subtitles2_file_name = "subtitles-es.srt" input_uri = f"gs://{input_bucket_name}{test_video_file_name}" overlay_image_uri = f"gs://{input_bucket_name}{test_overlay_image_file_name}" concat1_uri = f"gs://{input_bucket_name}{test_concat1_file_name}" concat2_uri = f"gs://{input_bucket_name}{test_concat2_file_name}" captions_uri = f"gs://{input_bucket_name}{test_captions_file_name}" +subtitles1_uri = f"gs://{input_bucket_name}{test_subtitles1_file_name}" +subtitles2_uri = f"gs://{input_bucket_name}{test_subtitles2_file_name}" output_uri_for_preset = f"gs://{output_bucket_name}/test-output-preset/" output_uri_for_template = f"gs://{output_bucket_name}/test-output-template/" output_uri_for_adhoc = f"gs://{output_bucket_name}/test-output-adhoc/" @@ -452,7 +456,8 @@ def test_create_job_with_standalone_captions(capsys, test_bucket): project_id, location, input_uri, - captions_uri, + subtitles1_uri, + subtitles2_uri, output_uri_for_standalone_captions, ) out, _ = capsys.readouterr() From 7b08d18c9a47c01c9fd8c5a778a0c03f0fd97ff8 Mon Sep 17 00:00:00 2001 From: Nicholas Cook Date: Wed, 12 Apr 2023 07:01:52 -0700 Subject: [PATCH 77/86] docs(samples): remove restriction of JPEGs only for overlay images (#299) --- video/transcoder/create_job_with_animated_overlay.py | 4 ++-- video/transcoder/create_job_with_static_overlay.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/video/transcoder/create_job_with_animated_overlay.py b/video/transcoder/create_job_with_animated_overlay.py index a3f3cbb3603..52940e85805 100644 --- a/video/transcoder/create_job_with_animated_overlay.py +++ b/video/transcoder/create_job_with_animated_overlay.py @@ -40,7 +40,7 @@ def create_job_with_animated_overlay( project_id: The GCP project ID. location: The location to start the job in. input_uri: Uri of the video in the Cloud Storage bucket. - overlay_image_uri: Uri of the JPEG image for the overlay in the Cloud Storage bucket. Must be a JPEG. + overlay_image_uri: Uri of the image for the overlay in the Cloud Storage bucket. output_uri: Uri of the video output folder in the Cloud Storage bucket.""" client = TranscoderServiceClient() @@ -143,7 +143,7 @@ def create_job_with_animated_overlay( ) parser.add_argument( "--overlay_image_uri", - help="Uri of the overlay JPEG image in the Cloud Storage bucket. Must be a JPEG.", + help="Uri of the overlay image in the Cloud Storage bucket.", required=True, ) parser.add_argument( diff --git a/video/transcoder/create_job_with_static_overlay.py b/video/transcoder/create_job_with_static_overlay.py index 37ce26b670d..67839bb3330 100644 --- a/video/transcoder/create_job_with_static_overlay.py +++ b/video/transcoder/create_job_with_static_overlay.py @@ -40,7 +40,7 @@ def create_job_with_static_overlay( project_id: The GCP project ID. location: The location to start the job in. input_uri: Uri of the video in the Cloud Storage bucket. - overlay_image_uri: Uri of the JPEG image for the overlay in the Cloud Storage bucket. Must be a JPEG. + overlay_image_uri: Uri of the image for the overlay in the Cloud Storage bucket. output_uri: Uri of the video output folder in the Cloud Storage bucket.""" client = TranscoderServiceClient() @@ -131,7 +131,7 @@ def create_job_with_static_overlay( ) parser.add_argument( "--overlay_image_uri", - help="Uri of the overlay JPEG image in the Cloud Storage bucket. Must be a JPEG.", + help="Uri of the overlay image in the Cloud Storage bucket.", required=True, ) parser.add_argument( From eca6ce2feec9d70cd384efe79ed7f7cea27f4f00 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Sat, 15 Apr 2023 16:03:55 +0100 Subject: [PATCH 78/86] chore(deps): update all dependencies (#294) --- video/transcoder/requirements-test.txt | 4 ++-- video/transcoder/requirements.txt | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/video/transcoder/requirements-test.txt b/video/transcoder/requirements-test.txt index 810fe2da3c8..e9861d56ccf 100644 --- a/video/transcoder/requirements-test.txt +++ b/video/transcoder/requirements-test.txt @@ -1,3 +1,3 @@ backoff==2.2.1 -google-cloud-storage==2.7.0 -pytest==7.2.2 +google-cloud-storage==2.8.0 +pytest==7.3.1 diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 71f7a44212e..7402a9652ef 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.80.0 -grpcio==1.51.3 -google-cloud-video-transcoder==1.8.0 +google-api-python-client==2.85.0 +grpcio==1.53.0 +google-cloud-video-transcoder==1.9.0 From f1bf3bc62b8af278d1b8ff1300326a8d62b90901 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Tue, 18 Apr 2023 17:58:34 +0200 Subject: [PATCH 79/86] chore(deps): update all dependencies (#302) --- video/transcoder/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 7402a9652ef..630e74a111a 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.85.0 -grpcio==1.53.0 +google-api-python-client==2.86.0 +grpcio==1.54.0 google-cloud-video-transcoder==1.9.0 From 3bc895b88a0b4e7eb2971972bfe921738bc886b2 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Thu, 4 May 2023 21:01:24 +0200 Subject: [PATCH 80/86] chore(deps): update dependency google-cloud-storage to v2.9.0 (#303) --- video/transcoder/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements-test.txt b/video/transcoder/requirements-test.txt index e9861d56ccf..0852b43c2d3 100644 --- a/video/transcoder/requirements-test.txt +++ b/video/transcoder/requirements-test.txt @@ -1,3 +1,3 @@ backoff==2.2.1 -google-cloud-storage==2.8.0 +google-cloud-storage==2.9.0 pytest==7.3.1 From 69e2c8de5df3fb05ff3c1f8eb69a2f1e0d9eb014 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Wed, 31 May 2023 21:15:01 +0200 Subject: [PATCH 81/86] chore(deps): update all dependencies (#305) Co-authored-by: Anthonios Partheniou --- video/transcoder/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 630e74a111a..6f3778ba410 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.86.0 -grpcio==1.54.0 +google-api-python-client==2.87.0 +grpcio==1.54.2 google-cloud-video-transcoder==1.9.0 From 726e97c2c99cc5013b9aed3983a7b3dc775eab75 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Wed, 31 May 2023 21:31:35 +0200 Subject: [PATCH 82/86] chore(deps): update dependency google-api-python-client to v2.88.0 (#306) --- video/transcoder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/transcoder/requirements.txt b/video/transcoder/requirements.txt index 6f3778ba410..4c8f7dfb8eb 100644 --- a/video/transcoder/requirements.txt +++ b/video/transcoder/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.87.0 +google-api-python-client==2.88.0 grpcio==1.54.2 google-cloud-video-transcoder==1.9.0 From dc7e1b2ca385beed719eb1c08abaf1fd0ef897d2 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 8 Jun 2023 16:02:19 +0000 Subject: [PATCH 83/86] add noxfile_config.py --- video/transcoder/noxfile.py | 292 ----------------------------- video/transcoder/noxfile_config.py | 42 +++++ 2 files changed, 42 insertions(+), 292 deletions(-) delete mode 100644 video/transcoder/noxfile.py create mode 100644 video/transcoder/noxfile_config.py diff --git a/video/transcoder/noxfile.py b/video/transcoder/noxfile.py deleted file mode 100644 index de104dbc64d..00000000000 --- a/video/transcoder/noxfile.py +++ /dev/null @@ -1,292 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from __future__ import print_function - -import glob -import os -from pathlib import Path -import sys -from typing import Callable, Dict, Optional - -import nox - -# WARNING - WARNING - WARNING - WARNING - WARNING -# WARNING - WARNING - WARNING - WARNING - WARNING -# DO NOT EDIT THIS FILE EVER! -# WARNING - WARNING - WARNING - WARNING - WARNING -# WARNING - WARNING - WARNING - WARNING - WARNING - -BLACK_VERSION = "black==22.3.0" -ISORT_VERSION = "isort==5.10.1" - -# Copy `noxfile_config.py` to your directory and modify it instead. - -# `TEST_CONFIG` dict is a configuration hook that allows users to -# modify the test configurations. The values here should be in sync -# with `noxfile_config.py`. Users will copy `noxfile_config.py` into -# their directory and modify it. - -TEST_CONFIG = { - # You can opt out from the test for specific Python versions. - "ignored_versions": [], - # Old samples are opted out of enforcing Python type hints - # All new samples should feature them - "enforce_type_hints": False, - # An envvar key for determining the project id to use. Change it - # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a - # build specific Cloud project. You can also use your own string - # to use your own Cloud project. - "gcloud_project_env": "GOOGLE_CLOUD_PROJECT", - # 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT', - # If you need to use a specific version of pip, - # change pip_version_override to the string representation - # of the version number, for example, "20.2.4" - "pip_version_override": None, - # A dictionary you want to inject into your test. Don't put any - # secrets here. These values will override predefined values. - "envs": {}, -} - - -try: - # Ensure we can import noxfile_config in the project's directory. - sys.path.append(".") - from noxfile_config import TEST_CONFIG_OVERRIDE -except ImportError as e: - print("No user noxfile_config found: detail: {}".format(e)) - TEST_CONFIG_OVERRIDE = {} - -# Update the TEST_CONFIG with the user supplied values. -TEST_CONFIG.update(TEST_CONFIG_OVERRIDE) - - -def get_pytest_env_vars() -> Dict[str, str]: - """Returns a dict for pytest invocation.""" - ret = {} - - # Override the GCLOUD_PROJECT and the alias. - env_key = TEST_CONFIG["gcloud_project_env"] - # This should error out if not set. - ret["GOOGLE_CLOUD_PROJECT"] = os.environ[env_key] - - # Apply user supplied envs. - ret.update(TEST_CONFIG["envs"]) - return ret - - -# DO NOT EDIT - automatically generated. -# All versions used to test samples. -ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11"] - -# Any default versions that should be ignored. -IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"] - -TESTED_VERSIONS = sorted([v for v in ALL_VERSIONS if v not in IGNORED_VERSIONS]) - -INSTALL_LIBRARY_FROM_SOURCE = os.environ.get("INSTALL_LIBRARY_FROM_SOURCE", False) in ( - "True", - "true", -) - -# Error if a python version is missing -nox.options.error_on_missing_interpreters = True - -# -# Style Checks -# - - -# Linting with flake8. -# -# We ignore the following rules: -# E203: whitespace before ‘:’ -# E266: too many leading ‘#’ for block comment -# E501: line too long -# I202: Additional newline in a section of imports -# -# We also need to specify the rules which are ignored by default: -# ['E226', 'W504', 'E126', 'E123', 'W503', 'E24', 'E704', 'E121'] -FLAKE8_COMMON_ARGS = [ - "--show-source", - "--builtin=gettext", - "--max-complexity=20", - "--exclude=.nox,.cache,env,lib,generated_pb2,*_pb2.py,*_pb2_grpc.py", - "--ignore=E121,E123,E126,E203,E226,E24,E266,E501,E704,W503,W504,I202", - "--max-line-length=88", -] - - -@nox.session -def lint(session: nox.sessions.Session) -> None: - if not TEST_CONFIG["enforce_type_hints"]: - session.install("flake8") - else: - session.install("flake8", "flake8-annotations") - - args = FLAKE8_COMMON_ARGS + [ - ".", - ] - session.run("flake8", *args) - - -# -# Black -# - - -@nox.session -def blacken(session: nox.sessions.Session) -> None: - """Run black. Format code to uniform standard.""" - session.install(BLACK_VERSION) - python_files = [path for path in os.listdir(".") if path.endswith(".py")] - - session.run("black", *python_files) - - -# -# format = isort + black -# - - -@nox.session -def format(session: nox.sessions.Session) -> None: - """ - Run isort to sort imports. Then run black - to format code to uniform standard. - """ - session.install(BLACK_VERSION, ISORT_VERSION) - python_files = [path for path in os.listdir(".") if path.endswith(".py")] - - # Use the --fss option to sort imports using strict alphabetical order. - # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections - session.run("isort", "--fss", *python_files) - session.run("black", *python_files) - - -# -# Sample Tests -# - - -PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml"] - - -def _session_tests( - session: nox.sessions.Session, post_install: Callable = None -) -> None: - # check for presence of tests - test_list = glob.glob("**/*_test.py", recursive=True) + glob.glob( - "**/test_*.py", recursive=True - ) - test_list.extend(glob.glob("**/tests", recursive=True)) - - if len(test_list) == 0: - print("No tests found, skipping directory.") - return - - if TEST_CONFIG["pip_version_override"]: - pip_version = TEST_CONFIG["pip_version_override"] - session.install(f"pip=={pip_version}") - """Runs py.test for a particular project.""" - concurrent_args = [] - if os.path.exists("requirements.txt"): - if os.path.exists("constraints.txt"): - session.install("-r", "requirements.txt", "-c", "constraints.txt") - else: - session.install("-r", "requirements.txt") - with open("requirements.txt") as rfile: - packages = rfile.read() - - if os.path.exists("requirements-test.txt"): - if os.path.exists("constraints-test.txt"): - session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt") - else: - session.install("-r", "requirements-test.txt") - with open("requirements-test.txt") as rtfile: - packages += rtfile.read() - - if INSTALL_LIBRARY_FROM_SOURCE: - session.install("-e", _get_repo_root()) - - if post_install: - post_install(session) - - if "pytest-parallel" in packages: - concurrent_args.extend(["--workers", "auto", "--tests-per-worker", "auto"]) - elif "pytest-xdist" in packages: - concurrent_args.extend(["-n", "auto"]) - - session.run( - "pytest", - *(PYTEST_COMMON_ARGS + session.posargs + concurrent_args), - # Pytest will return 5 when no tests are collected. This can happen - # on travis where slow and flaky tests are excluded. - # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html - success_codes=[0, 5], - env=get_pytest_env_vars(), - ) - - -@nox.session(python=ALL_VERSIONS) -def py(session: nox.sessions.Session) -> None: - """Runs py.test for a sample using the specified version of Python.""" - if session.python in TESTED_VERSIONS: - _session_tests(session) - else: - session.skip( - "SKIPPED: {} tests are disabled for this sample.".format(session.python) - ) - - -# -# Readmegen -# - - -def _get_repo_root() -> Optional[str]: - """Returns the root folder of the project.""" - # Get root of this repository. Assume we don't have directories nested deeper than 10 items. - p = Path(os.getcwd()) - for i in range(10): - if p is None: - break - if Path(p / ".git").exists(): - return str(p) - # .git is not available in repos cloned via Cloud Build - # setup.py is always in the library's root, so use that instead - # https://github.com/googleapis/synthtool/issues/792 - if Path(p / "setup.py").exists(): - return str(p) - p = p.parent - raise Exception("Unable to detect repository root.") - - -GENERATED_READMES = sorted([x for x in Path(".").rglob("*.rst.in")]) - - -@nox.session -@nox.parametrize("path", GENERATED_READMES) -def readmegen(session: nox.sessions.Session, path: str) -> None: - """(Re-)generates the readme for a sample.""" - session.install("jinja2", "pyyaml") - dir_ = os.path.dirname(path) - - if os.path.exists(os.path.join(dir_, "requirements.txt")): - session.install("-r", os.path.join(dir_, "requirements.txt")) - - in_file = os.path.join(dir_, "README.rst.in") - session.run( - "python", _get_repo_root() + "/scripts/readme-gen/readme_gen.py", in_file - ) diff --git a/video/transcoder/noxfile_config.py b/video/transcoder/noxfile_config.py new file mode 100644 index 00000000000..ca446bfd315 --- /dev/null +++ b/video/transcoder/noxfile_config.py @@ -0,0 +1,42 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Default TEST_CONFIG_OVERRIDE for python repos. + +# You can copy this file into your directory, then it will be imported from +# the noxfile.py. + +# The source of truth: +# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/noxfile_config.py + +TEST_CONFIG_OVERRIDE = { + # You can opt out from the test for specific Python versions. + "ignored_versions": ["2.7", "3.6"], + # Old samples are opted out of enforcing Python type hints + # All new samples should feature them + "enforce_type_hints": False, + # An envvar key for determining the project id to use. Change it + # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a + # build specific Cloud project. You can also use your own string + # to use your own Cloud project. + "gcloud_project_env": "GOOGLE_CLOUD_PROJECT", + # 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT', + # If you need to use a specific version of pip, + # change pip_version_override to the string representation + # of the version number, for example, "20.2.4" + "pip_version_override": None, + # A dictionary you want to inject into your test. Don't put any + # secrets here. These values will override predefined values. + "envs": {}, +} From 7bbab25cc9326e4756c53beaca03d2b71bd82e04 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 8 Jun 2023 16:02:38 +0000 Subject: [PATCH 84/86] update codeowners;blunderbuss --- .github/CODEOWNERS | 1 + .github/blunderbuss.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 80aa33f2443..10be3471846 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -70,6 +70,7 @@ /speech/**/* @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/python-samples-reviewers /texttospeech/**/* @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/python-samples-reviewers /translate/**/* @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/python-samples-reviewers +/video/transcoder/* @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/python-samples-reviewers # Cloud SDK Databases & Data Analytics teams # ---* Cloud Native DB diff --git a/.github/blunderbuss.yml b/.github/blunderbuss.yml index ef971b7a08f..94bd237f9f9 100644 --- a/.github/blunderbuss.yml +++ b/.github/blunderbuss.yml @@ -219,6 +219,7 @@ assign_prs_by: - "api: speech" - "api: talent" - "api: texttospeech" + - "api: transcoder" - "api: translate" - "api: vision" to: From b89769e527fa452f16979d2758a6e94b6e0dee04 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 8 Jun 2023 16:09:14 +0000 Subject: [PATCH 85/86] update copyright headers --- video/transcoder/create_job_from_ad_hoc.py | 2 +- video/transcoder/create_job_from_preset.py | 2 +- video/transcoder/create_job_from_template.py | 2 +- video/transcoder/create_job_template.py | 2 +- video/transcoder/delete_job.py | 2 +- video/transcoder/delete_job_template.py | 2 +- video/transcoder/get_job.py | 2 +- video/transcoder/get_job_state.py | 2 +- video/transcoder/get_job_template.py | 2 +- video/transcoder/job_template_test.py | 2 +- video/transcoder/job_test.py | 2 +- video/transcoder/list_job_templates.py | 2 +- video/transcoder/list_jobs.py | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/video/transcoder/create_job_from_ad_hoc.py b/video/transcoder/create_job_from_ad_hoc.py index 7fc6dce832e..60832dde609 100644 --- a/video/transcoder/create_job_from_ad_hoc.py +++ b/video/transcoder/create_job_from_ad_hoc.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2020 Google Inc. All Rights Reserved. +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/transcoder/create_job_from_preset.py b/video/transcoder/create_job_from_preset.py index 67c167241e0..0bfbcb4c0ee 100644 --- a/video/transcoder/create_job_from_preset.py +++ b/video/transcoder/create_job_from_preset.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2020 Google Inc. All Rights Reserved. +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/transcoder/create_job_from_template.py b/video/transcoder/create_job_from_template.py index 685c3f67999..331f5962140 100644 --- a/video/transcoder/create_job_from_template.py +++ b/video/transcoder/create_job_from_template.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2020 Google Inc. All Rights Reserved. +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/transcoder/create_job_template.py b/video/transcoder/create_job_template.py index 95ed05d8409..78e16014177 100644 --- a/video/transcoder/create_job_template.py +++ b/video/transcoder/create_job_template.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2020 Google Inc. All Rights Reserved. +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/transcoder/delete_job.py b/video/transcoder/delete_job.py index 5f139f9ed55..156d67c6d2c 100644 --- a/video/transcoder/delete_job.py +++ b/video/transcoder/delete_job.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2020 Google Inc. All Rights Reserved. +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/transcoder/delete_job_template.py b/video/transcoder/delete_job_template.py index ccce70f71c5..cdd3d710046 100644 --- a/video/transcoder/delete_job_template.py +++ b/video/transcoder/delete_job_template.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2020 Google Inc. All Rights Reserved. +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/transcoder/get_job.py b/video/transcoder/get_job.py index ec5d7f1fa7e..ff594bf342c 100644 --- a/video/transcoder/get_job.py +++ b/video/transcoder/get_job.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2020 Google Inc. All Rights Reserved. +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/transcoder/get_job_state.py b/video/transcoder/get_job_state.py index 6b73acfc6c4..86e2b341066 100644 --- a/video/transcoder/get_job_state.py +++ b/video/transcoder/get_job_state.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2020 Google Inc. All Rights Reserved. +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/transcoder/get_job_template.py b/video/transcoder/get_job_template.py index 4d6ccf70915..92e3dbf6add 100644 --- a/video/transcoder/get_job_template.py +++ b/video/transcoder/get_job_template.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2020 Google Inc. All Rights Reserved. +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/transcoder/job_template_test.py b/video/transcoder/job_template_test.py index 259595a4b55..7cc70d0df46 100644 --- a/video/transcoder/job_template_test.py +++ b/video/transcoder/job_template_test.py @@ -1,4 +1,4 @@ -# Copyright 2020 Google Inc. All Rights Reserved. +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/transcoder/job_test.py b/video/transcoder/job_test.py index 6dbf8cd1fb3..998555d8d35 100644 --- a/video/transcoder/job_test.py +++ b/video/transcoder/job_test.py @@ -1,4 +1,4 @@ -# Copyright 2020 Google Inc. All Rights Reserved. +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/transcoder/list_job_templates.py b/video/transcoder/list_job_templates.py index 020f7a32973..8a30af133b8 100644 --- a/video/transcoder/list_job_templates.py +++ b/video/transcoder/list_job_templates.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2020 Google Inc. All Rights Reserved. +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/transcoder/list_jobs.py b/video/transcoder/list_jobs.py index cf1fdbd2347..880e234335b 100644 --- a/video/transcoder/list_jobs.py +++ b/video/transcoder/list_jobs.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2020 Google Inc. All Rights Reserved. +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. From 386cf6c92cb822af568dcb07f940bd0911dc9270 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 8 Jun 2023 12:17:48 -0400 Subject: [PATCH 86/86] Delete README.md --- video/transcoder/README.md | 40 -------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 video/transcoder/README.md diff --git a/video/transcoder/README.md b/video/transcoder/README.md deleted file mode 100644 index ce4ff9588db..00000000000 --- a/video/transcoder/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# Transcoder API Python Samples - -This directory contains samples for the Transcoder API. Use this API to transcode videos into a variety of formats. The Transcoder API benefits broadcasters, production companies, businesses, and individuals looking to transform their video content for use across a variety of user devices. For more information, see the [Transcoder API documentation](https://cloud.google.com/transcoder/). - -## Setup - -To run the samples, you need to first follow the steps in [Before you begin](https://cloud.google.com/transcoder/docs/how-to/before-you-begin). - -For more information on authentication, refer to the -[Authentication Getting Started Guide](https://cloud.google.com/docs/authentication/getting-started). - -## Install Dependencies - -1. Clone python-docs-samples and change directory to the sample directory you want to use. - - $ git clone https://github.com/googleapis/python-video-transcoder.git - -1. Install [pip](https://pip.pypa.io/) and [virtualenv](https://virtualenv.pypa.io/) if you do not already have them. You may want to refer to the [Python Development Environment Setup Guide](https://cloud.google.com/python/setup) for Google Cloud Platform for instructions. - -1. Create a virtualenv. Samples are compatible with Python 3.6+. - - $ virtualenv env - $ source env/bin/activate - -1. Install the dependencies needed to run the samples. - - $ pip install -r requirements.txt - -## The client library - -This sample uses the [Google Cloud Client Library for Python](https://googlecloudplatform.github.io/google-cloud-python/). -You can read the documentation for more details on API usage and use GitHub -to [browse the source](https://github.com/GoogleCloudPlatform/google-cloud-python) and [report issues](https://github.com/GoogleCloudPlatform/google-cloud-python/issues). - -## Testing - -Make sure to enable the Transcoder API on the test project. Set the following environment variables: - -* `GOOGLE_CLOUD_PROJECT` -* `GOOGLE_CLOUD_PROJECT_NUMBER`