-
Notifications
You must be signed in to change notification settings - Fork 6.5k
migrate code from googleapis/python-video-live-stream #10200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 51 commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
077f0da
docs(samples): add code samples (#21)
irataxy b479bb9
chore(deps): update all dependencies (#33)
renovate-bot c1acfec
chore(deps): update dependency google-cloud-video-live-stream to v0.1…
renovate-bot 4b51400
ci: try to stop channel again before deleting it in the test (#36)
irataxy 1fda5b3
docs(samples): add sample for creating a channel with a failover back…
irataxy 02c8682
chore(deps): update dependency google-cloud-video-live-stream to v0.1…
renovate-bot 73f80ce
chore: remove dependency google-api-python-client in samples (#40)
renovate-bot 0d2b02c
chore(deps): update dependency grpcio to v1.46.0 (#41)
renovate-bot 5d01257
chore(deps): update dependency grpcio to v1.46.1 (#44)
renovate-bot 35a6031
chore(deps): update dependency grpcio to v1.46.3 (#47)
renovate-bot bf58dbd
chore(deps): update dependency google-cloud-video-live-stream to v0.1…
renovate-bot fc76f67
docs: align channel config with best practices (#71)
irataxy 287fff2
chore(deps): update all dependencies (#70)
renovate-bot c979dc8
docs(samples): fix timeout for LROs; first call can take up to 10 min…
irataxy d11988e
docs(samples): fix timeout for create input and start channel LROs; f…
irataxy 49d73e7
chore(deps): update all dependencies (#87)
renovate-bot 2803de6
chore(deps): update all dependencies to v1.0.1 (#90)
renovate-bot 8351519
chore(deps): update dependency google-cloud-video-live-stream to v1.0…
renovate-bot 2767b94
chore(deps): update dependency grpcio to v1.48.1 (#101)
renovate-bot 009a47a
chore(deps): update dependency pytest to v7.1.3 (#106)
renovate-bot 4fff6e3
chore(deps): update dependency grpcio to v1.49.0 (#111)
renovate-bot e653cdd
chore(deps): update dependency grpcio to v1.49.1 (#112)
renovate-bot 47bb0cc
chore(deps): update dependency google-cloud-video-live-stream to v1.0…
renovate-bot 53e0482
chore(deps): update dependency google-cloud-video-live-stream to v1.0…
renovate-bot 58578e2
chore(deps): update dependency grpcio to v1.50.0 (#119)
renovate-bot b8fbb35
chore(deps): update dependency pytest to v7.2.0 (#120)
renovate-bot e9e0524
chore(deps): update dependency grpcio to v1.51.1 (#128)
renovate-bot 637882b
chore(deps): update dependency google-cloud-video-live-stream to v1.1…
renovate-bot e099ce7
chore(deps): update dependency google-cloud-video-live-stream to v1.2…
renovate-bot f5f1dad
chore(deps): update dependency pytest to v7.2.1 (#136)
renovate-bot 3199bef
chore(deps): update dependency google-cloud-video-live-stream to v1.2…
renovate-bot 1885872
chore(deps): update all dependencies (#146)
renovate-bot 99a2699
chore(deps): update dependency pytest to v7.2.2 (#149)
renovate-bot 384958c
chore(deps): update all dependencies (#155)
renovate-bot 2c46002
chore(deps): update dependency pytest to v7.3.0 (#156)
renovate-bot fd8ff02
chore(deps): update dependency pytest to v7.3.1 (#157)
renovate-bot b55bfb5
chore(deps): update dependency grpcio to v1.54.0 (#158)
renovate-bot 534330c
chore(deps): update dependency grpcio to v1.54.2 (#159)
renovate-bot 589a8e5
chore(deps): update dependency pytest to v7.3.2 (#163)
renovate-bot c49577c
chore(deps): update all dependencies (#164)
renovate-bot 454667d
chore(deps): update dependency google-cloud-video-live-stream to v1.4…
renovate-bot 709cae2
chore(deps): update dependency grpcio to v1.56.2 (#173)
renovate-bot 903b4f1
chore(deps): update dependency google-cloud-video-live-stream to v1.5…
renovate-bot 5f2a4b8
chore(deps): update dependency grpcio to v1.57.0 (#181)
renovate-bot 588147f
docs(samples): add samples and tests for pools and assets (#180)
irataxy fd63d97
chore(deps): update dependency google-cloud-video-live-stream to v1.5…
renovate-bot 1e0894a
fix licence headers
dizcology 05b57e2
Update video/live-stream/noxfile_config.py
dizcology 175e262
update CODEOWNERS and blunderbuss.yml
dizcology e880577
restrict requirements.txt by python version
dizcology 248c234
skip python version 2.7
dizcology b58a104
Update video/live-stream/noxfile_config.py
dizcology 62dca46
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] 0e596d5
Update video/live-stream/README.md
dizcology ab422ed
Update video/live-stream/README.md
dizcology File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Live Stream API Python Samples | ||
|
||
This directory contains samples for the Live Stream API. Use this API to | ||
transcode live, linear video streams into a variety of formats. The Live Stream | ||
API benefits broadcasters, production companies, businesses, and individuals | ||
looking to transform their live video content for use across a variety of user | ||
devices. For more information, see the | ||
[Live Stream API documentation](https://cloud.google.com/livestream/). | ||
|
||
## Setup | ||
|
||
To run the samples, you need to first follow the steps in | ||
[Before you begin](https://cloud.google.com/livestream/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-video-live-stream and change directories to the sample directory | ||
you want to use. | ||
|
||
$ git clone https://github.com/googleapis/python-video-live-stream.git | ||
dizcology marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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 | ||
|
||
## Testing | ||
|
||
Make sure to enable the Live Stream API on the test project. Set the following | ||
environment variable: | ||
|
||
* `GOOGLE_CLOUD_PROJECT` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Copyright 2023 Google LLC. 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 FailedPrecondition, NotFound | ||
from google.protobuf import empty_pb2 as empty | ||
import pytest | ||
|
||
import create_asset | ||
import delete_asset | ||
import get_asset | ||
import list_assets | ||
import utils | ||
|
||
project_name = os.environ["GOOGLE_CLOUD_PROJECT"] | ||
location = "us-central1" | ||
asset_id = f"my-python-test-asset-{uuid.uuid4()}" | ||
asset_uri = "gs://cloud-samples-data/media/ForBiggerEscapes.mp4" | ||
|
||
|
||
def test_asset_operations(capsys: pytest.fixture) -> None: | ||
# Clean up old resources in the test project | ||
responses = list_assets.list_assets(project_name, location) | ||
for response in responses: | ||
next_asset_id = response.name.rsplit("/", 1)[-1] | ||
if utils.is_resource_stale(response.create_time): | ||
try: | ||
delete_asset.delete_asset(project_name, location, next_asset_id) | ||
except FailedPrecondition as e: | ||
print(f"Ignoring FailedPrecondition, details: {e}") | ||
except NotFound as e: | ||
print(f"Ignoring NotFound, details: {e}") | ||
|
||
asset_name_project_id = ( | ||
f"projects/{project_name}/locations/{location}/assets/{asset_id}" | ||
) | ||
|
||
# Tests | ||
|
||
response = create_asset.create_asset(project_name, location, asset_id, asset_uri) | ||
assert asset_name_project_id in response.name | ||
|
||
list_assets.list_assets(project_name, location) | ||
out, _ = capsys.readouterr() | ||
assert asset_name_project_id in out | ||
|
||
response = get_asset.get_asset(project_name, location, asset_id) | ||
assert asset_name_project_id in response.name | ||
|
||
response = delete_asset.delete_asset(project_name, location, asset_id) | ||
assert response == empty.Empty() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Copyright 2022 Google LLC. 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 | ||
|
||
import pytest | ||
|
||
import create_channel | ||
import create_channel_event | ||
import create_input | ||
import delete_channel | ||
import delete_channel_event | ||
import delete_input | ||
import get_channel_event | ||
import list_channel_events | ||
import start_channel | ||
import stop_channel | ||
|
||
project_name = os.environ["GOOGLE_CLOUD_PROJECT"] | ||
location = "us-central1" | ||
input_id = f"python-test-input-{uuid.uuid4()}" | ||
channel_id = f"python-test-channel-{uuid.uuid4()}" | ||
event_id = f"python-test-event-{uuid.uuid4()}" | ||
output_bucket_name = f"python-test-bucket-{uuid.uuid4()}" | ||
output_uri = f"gs://{output_bucket_name}/channel-test/" | ||
|
||
|
||
def test_channel_event_operations(capsys: pytest.fixture) -> None: | ||
|
||
# Set up | ||
|
||
event_name_project_id = f"projects/{project_name}/locations/{location}/channels/{channel_id}/events/{event_id}" | ||
|
||
create_input.create_input(project_name, location, input_id) | ||
|
||
create_channel.create_channel( | ||
project_name, location, channel_id, input_id, output_uri | ||
) | ||
|
||
start_channel.start_channel(project_name, location, channel_id) | ||
|
||
# Tests | ||
|
||
response = create_channel_event.create_channel_event( | ||
project_name, location, channel_id, event_id | ||
) | ||
assert event_name_project_id in response.name | ||
|
||
response = get_channel_event.get_channel_event( | ||
project_name, location, channel_id, event_id | ||
) | ||
assert event_name_project_id in response.name | ||
|
||
list_channel_events.list_channel_events(project_name, location, channel_id) | ||
out, _ = capsys.readouterr() | ||
assert event_name_project_id in out | ||
|
||
response = delete_channel_event.delete_channel_event( | ||
project_name, location, channel_id, event_id | ||
) | ||
assert response is None | ||
|
||
# Clean up | ||
|
||
stop_channel.stop_channel(project_name, location, channel_id) | ||
delete_channel.delete_channel(project_name, location, channel_id) | ||
delete_input.delete_input(project_name, location, input_id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
# Copyright 2022 Google LLC. 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 FailedPrecondition, NotFound | ||
from google.protobuf import empty_pb2 as empty | ||
import pytest | ||
|
||
import create_channel | ||
import create_channel_with_backup_input | ||
import create_input | ||
import delete_channel | ||
import delete_channel_event | ||
import delete_input | ||
import get_channel | ||
import list_channel_events | ||
import list_channels | ||
import start_channel | ||
import stop_channel | ||
import update_channel | ||
import utils | ||
|
||
project_name = os.environ["GOOGLE_CLOUD_PROJECT"] | ||
location = "us-central1" | ||
input_id = f"python-test-input-{uuid.uuid4()}" | ||
updated_input_id = f"python-test-up-input-{uuid.uuid4()}" | ||
channel_id = f"python-test-channel-{uuid.uuid4()}" | ||
output_bucket_name = f"python-test-bucket-{uuid.uuid4()}" | ||
output_uri = f"gs://{output_bucket_name}/channel-test/" | ||
|
||
|
||
def test_channel_operations(capsys: pytest.fixture) -> None: | ||
|
||
# Clean up old resources in the test project | ||
channel_responses = list_channels.list_channels(project_name, location) | ||
|
||
for response in channel_responses: | ||
next_channel_id = response.name.rsplit("/", 1)[-1] | ||
input_attachments = response.input_attachments | ||
if utils.is_resource_stale(response.create_time): | ||
try: | ||
event_responses = list_channel_events.list_channel_events( | ||
project_name, location, next_channel_id | ||
) | ||
for response in event_responses: | ||
next_event_id = response.name.rsplit("/", 1)[-1] | ||
try: | ||
delete_channel_event.delete_channel_event( | ||
project_name, location, next_channel_id, next_event_id | ||
) | ||
except NotFound as e: | ||
print(f"Ignoring NotFound, details: {e}") | ||
try: | ||
stop_channel.stop_channel(project_name, location, next_channel_id) | ||
except FailedPrecondition as e: | ||
print(f"Ignoring FailedPrecondition, details: {e}") | ||
try: | ||
delete_channel.delete_channel( | ||
project_name, location, next_channel_id | ||
) | ||
except FailedPrecondition as e: | ||
print(f"Ignoring FailedPrecondition, try to stop channel: {e}") | ||
try: | ||
stop_channel.stop_channel( | ||
project_name, location, next_channel_id | ||
) | ||
except FailedPrecondition as e: | ||
print(f"Ignoring FailedPrecondition, details: {e}") | ||
except NotFound as e: | ||
print(f"Ignoring NotFound, details: {e}") | ||
except NotFound as e: | ||
print(f"Ignoring NotFound, details: {e}") | ||
|
||
for input_attachment in input_attachments: | ||
next_input_id = input_attachment.input.rsplit("/", 1)[-1] | ||
try: | ||
delete_input.delete_input(project_name, location, next_input_id) | ||
except NotFound as e: | ||
print(f"Ignoring NotFound, details: {e}") | ||
|
||
# Set up | ||
|
||
channel_name_project_id = ( | ||
f"projects/{project_name}/locations/{location}/channels/{channel_id}" | ||
) | ||
|
||
create_input.create_input(project_name, location, input_id) | ||
create_input.create_input(project_name, location, updated_input_id) | ||
|
||
# Tests | ||
|
||
response = create_channel.create_channel( | ||
project_name, location, channel_id, input_id, output_uri | ||
) | ||
assert channel_name_project_id in response.name | ||
|
||
list_channels.list_channels(project_name, location) | ||
out, _ = capsys.readouterr() | ||
assert channel_name_project_id in out | ||
|
||
response = update_channel.update_channel( | ||
project_name, location, channel_id, updated_input_id | ||
) | ||
assert channel_name_project_id in response.name | ||
for input_attachment in response.input_attachments: | ||
assert "updated-input" in input_attachment.key | ||
|
||
response = get_channel.get_channel(project_name, location, channel_id) | ||
assert channel_name_project_id in response.name | ||
|
||
start_channel.start_channel(project_name, location, channel_id) | ||
out, _ = capsys.readouterr() | ||
assert "Started channel" in out | ||
|
||
stop_channel.stop_channel(project_name, location, channel_id) | ||
out, _ = capsys.readouterr() | ||
assert "Stopped channel" in out | ||
|
||
response = delete_channel.delete_channel(project_name, location, channel_id) | ||
assert response == empty.Empty() | ||
|
||
response = create_channel_with_backup_input.create_channel_with_backup_input( | ||
project_name, location, channel_id, input_id, updated_input_id, output_uri | ||
) | ||
assert channel_name_project_id in response.name | ||
|
||
# Clean up | ||
|
||
delete_channel.delete_channel(project_name, location, channel_id) | ||
delete_input.delete_input(project_name, location, input_id) | ||
delete_input.delete_input(project_name, location, updated_input_id) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.