Skip to content
This repository was archived by the owner on Sep 21, 2023. It is now read-only.

feat: add support for batch processing mode #300

Merged
merged 2 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 39 additions & 12 deletions google/cloud/video/transcoder_v1/types/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,10 @@ class Job(proto.Message):
formats <https://cloud.google.com/transcoder/docs/concepts/supported-input-and-output-formats>`__.
template_id (str):
Input only. Specify the ``template_id`` to use for
populating ``Job.config``. The default is ``preset/web-hd``.
populating ``Job.config``. The default is ``preset/web-hd``,
which is the only supported preset.

Preset Transcoder templates:

- ``preset/{preset_id}``

- User defined JobTemplate: ``{job_template_id}``
User defined JobTemplate: ``{job_template_id}``

This field is a member of `oneof`_ ``job_config``.
config (google.cloud.video.transcoder_v1.types.JobConfig):
Expand Down Expand Up @@ -114,6 +111,9 @@ class Job(proto.Message):
Output only. An error object that describes the reason for
the failure. This property is always present when ``state``
is ``FAILED``.
mode (google.cloud.video.transcoder_v1.types.Job.ProcessingMode):
The processing mode of the job. The default is
``PROCESSING_MODE_INTERACTIVE``.
"""

class ProcessingState(proto.Enum):
Expand All @@ -139,6 +139,24 @@ class ProcessingState(proto.Enum):
SUCCEEDED = 3
FAILED = 4

class ProcessingMode(proto.Enum):
r"""The processing mode of the job.

Values:
PROCESSING_MODE_UNSPECIFIED (0):
The job processing mode is not specified.
PROCESSING_MODE_INTERACTIVE (1):
The job processing mode is interactive mode.
Interactive job will either be ran or rejected
if quota does not allow for it.
PROCESSING_MODE_BATCH (2):
The job processing mode is batch mode.
Batch mode allows queuing of jobs.
"""
PROCESSING_MODE_UNSPECIFIED = 0
PROCESSING_MODE_INTERACTIVE = 1
PROCESSING_MODE_BATCH = 2

name: str = proto.Field(
proto.STRING,
number=1,
Expand Down Expand Up @@ -196,6 +214,11 @@ class ProcessingState(proto.Enum):
number=17,
message=status_pb2.Status,
)
mode: ProcessingMode = proto.Field(
proto.ENUM,
number=20,
enum=ProcessingMode,
)


class JobTemplate(proto.Message):
Expand Down Expand Up @@ -785,13 +808,13 @@ class NormalizedCoordinate(proto.Message):
)

class Image(proto.Message):
r"""Overlaid jpeg image.
r"""Overlaid image.

Attributes:
uri (str):
Required. URI of the JPEG image in Cloud Storage. For
example, ``gs://bucket/inputs/image.jpeg``. JPEG is the only
supported image type.
Required. URI of the image in Cloud Storage. For example,
``gs://bucket/inputs/image.png``. Only PNG and JPEG images
are supported.
resolution (google.cloud.video.transcoder_v1.types.Overlay.NormalizedCoordinate):
Normalized image resolution, based on output video
resolution. Valid values: ``0.0``–``1.0``. To respect the
Expand Down Expand Up @@ -2047,9 +2070,11 @@ class AudioStream(proto.Message):
The BCP-47 language code, such as ``en-US`` or ``sr-Latn``.
For more information, see
https://www.unicode.org/reports/tr35/#Unicode_locale_identifier.
Not supported in MP4 files.
display_name (str):
The name for this particular audio stream
that will be added to the HLS/DASH manifest.
that will be added to the HLS/DASH manifest. Not
supported in MP4 files.
"""

class AudioMapping(proto.Message):
Expand Down Expand Up @@ -2156,12 +2181,14 @@ class TextStream(proto.Message):
The BCP-47 language code, such as ``en-US`` or ``sr-Latn``.
For more information, see
https://www.unicode.org/reports/tr35/#Unicode_locale_identifier.
Not supported in MP4 files.
mapping_ (MutableSequence[google.cloud.video.transcoder_v1.types.TextStream.TextMapping]):
The mapping for the ``Job.edit_list`` atoms with text
``EditAtom.inputs``.
display_name (str):
The name for this particular text stream that
will be added to the HLS/DASH manifest.
will be added to the HLS/DASH manifest. Not
supported in MP4 files.
"""

class TextMapping(proto.Message):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-video-transcoder",
"version": "1.8.2"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/gapic/transcoder_v1/test_transcoder_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,7 @@ def test_create_job(request_type, transport: str = "grpc"):
output_uri="output_uri_value",
state=resources.Job.ProcessingState.PENDING,
ttl_after_completion_days=2670,
mode=resources.Job.ProcessingMode.PROCESSING_MODE_INTERACTIVE,
template_id="template_id_value",
)
response = client.create_job(request)
Expand All @@ -778,6 +779,7 @@ def test_create_job(request_type, transport: str = "grpc"):
assert response.output_uri == "output_uri_value"
assert response.state == resources.Job.ProcessingState.PENDING
assert response.ttl_after_completion_days == 2670
assert response.mode == resources.Job.ProcessingMode.PROCESSING_MODE_INTERACTIVE


def test_create_job_empty_call():
Expand Down Expand Up @@ -819,6 +821,7 @@ async def test_create_job_async(
output_uri="output_uri_value",
state=resources.Job.ProcessingState.PENDING,
ttl_after_completion_days=2670,
mode=resources.Job.ProcessingMode.PROCESSING_MODE_INTERACTIVE,
)
)
response = await client.create_job(request)
Expand All @@ -835,6 +838,7 @@ async def test_create_job_async(
assert response.output_uri == "output_uri_value"
assert response.state == resources.Job.ProcessingState.PENDING
assert response.ttl_after_completion_days == 2670
assert response.mode == resources.Job.ProcessingMode.PROCESSING_MODE_INTERACTIVE


@pytest.mark.asyncio
Expand Down Expand Up @@ -1441,6 +1445,7 @@ def test_get_job(request_type, transport: str = "grpc"):
output_uri="output_uri_value",
state=resources.Job.ProcessingState.PENDING,
ttl_after_completion_days=2670,
mode=resources.Job.ProcessingMode.PROCESSING_MODE_INTERACTIVE,
template_id="template_id_value",
)
response = client.get_job(request)
Expand All @@ -1457,6 +1462,7 @@ def test_get_job(request_type, transport: str = "grpc"):
assert response.output_uri == "output_uri_value"
assert response.state == resources.Job.ProcessingState.PENDING
assert response.ttl_after_completion_days == 2670
assert response.mode == resources.Job.ProcessingMode.PROCESSING_MODE_INTERACTIVE


def test_get_job_empty_call():
Expand Down Expand Up @@ -1498,6 +1504,7 @@ async def test_get_job_async(
output_uri="output_uri_value",
state=resources.Job.ProcessingState.PENDING,
ttl_after_completion_days=2670,
mode=resources.Job.ProcessingMode.PROCESSING_MODE_INTERACTIVE,
)
)
response = await client.get_job(request)
Expand All @@ -1514,6 +1521,7 @@ async def test_get_job_async(
assert response.output_uri == "output_uri_value"
assert response.state == resources.Job.ProcessingState.PENDING
assert response.ttl_after_completion_days == 2670
assert response.mode == resources.Job.ProcessingMode.PROCESSING_MODE_INTERACTIVE


@pytest.mark.asyncio
Expand Down Expand Up @@ -3302,6 +3310,7 @@ def test_create_job_rest(request_type):
}
],
},
"mode": 1,
}
request = request_type(**request_init)

Expand All @@ -3314,6 +3323,7 @@ def test_create_job_rest(request_type):
output_uri="output_uri_value",
state=resources.Job.ProcessingState.PENDING,
ttl_after_completion_days=2670,
mode=resources.Job.ProcessingMode.PROCESSING_MODE_INTERACTIVE,
template_id="template_id_value",
)

Expand All @@ -3334,6 +3344,7 @@ def test_create_job_rest(request_type):
assert response.output_uri == "output_uri_value"
assert response.state == resources.Job.ProcessingState.PENDING
assert response.ttl_after_completion_days == 2670
assert response.mode == resources.Job.ProcessingMode.PROCESSING_MODE_INTERACTIVE


def test_create_job_rest_required_fields(request_type=services.CreateJobRequest):
Expand Down Expand Up @@ -3721,6 +3732,7 @@ def test_create_job_rest_bad_request(
}
],
},
"mode": 1,
}
request = request_type(**request_init)

Expand Down Expand Up @@ -4164,6 +4176,7 @@ def test_get_job_rest(request_type):
output_uri="output_uri_value",
state=resources.Job.ProcessingState.PENDING,
ttl_after_completion_days=2670,
mode=resources.Job.ProcessingMode.PROCESSING_MODE_INTERACTIVE,
template_id="template_id_value",
)

Expand All @@ -4184,6 +4197,7 @@ def test_get_job_rest(request_type):
assert response.output_uri == "output_uri_value"
assert response.state == resources.Job.ProcessingState.PENDING
assert response.ttl_after_completion_days == 2670
assert response.mode == resources.Job.ProcessingMode.PROCESSING_MODE_INTERACTIVE


def test_get_job_rest_required_fields(request_type=services.GetJobRequest):
Expand Down