remotion-lambda 4.0.514__tar.gz → 4.0.515__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/PKG-INFO +1 -1
- {remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/remotion_lambda/models.py +2 -0
- {remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/remotion_lambda/remotionclient.py +33 -0
- {remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/remotion_lambda/version.py +1 -1
- {remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/remotion_lambda.egg-info/PKG-INFO +1 -1
- {remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/tests/test_render_client_render_media.py +42 -1
- {remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/LICENSE +0 -0
- {remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/README.md +0 -0
- {remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/remotion_lambda/__init__.py +0 -0
- {remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/remotion_lambda/exception.py +0 -0
- {remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/remotion_lambda.egg-info/SOURCES.txt +0 -0
- {remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/remotion_lambda.egg-info/dependency_links.txt +0 -0
- {remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/remotion_lambda.egg-info/requires.txt +0 -0
- {remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/remotion_lambda.egg-info/top_level.txt +0 -0
- {remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/setup.cfg +0 -0
- {remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/setup.py +0 -0
- {remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/tests/__init__.py +0 -0
- {remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/tests/conftest.py +0 -0
- {remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/tests/constants.py +0 -0
- {remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/tests/test_get_render_progress_client.py +0 -0
- {remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/tests/test_large_payload_compression.py +0 -0
- {remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/tests/test_remotion_client.py +0 -0
- {remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/tests/test_render_client_render_still.py +0 -0
|
@@ -282,6 +282,7 @@ class RenderMediaParams:
|
|
|
282
282
|
region: Optional[str] = None
|
|
283
283
|
out_name: Optional[Union[str, OutNameInputObject]] = None
|
|
284
284
|
prefer_lossless: Optional[bool] = False
|
|
285
|
+
enable_cancellation: bool = False
|
|
285
286
|
composition: str = ""
|
|
286
287
|
serve_url: str = ""
|
|
287
288
|
frames_per_lambda: Optional[int] = None
|
|
@@ -342,6 +343,7 @@ class RenderMediaParams:
|
|
|
342
343
|
Convert instance attributes to a dictionary for serialization.
|
|
343
344
|
"""
|
|
344
345
|
parameters = {
|
|
346
|
+
'enableCancellation': self.enable_cancellation,
|
|
345
347
|
'rendererFunctionName': self.renderer_function_name,
|
|
346
348
|
'framesPerLambda': self.frames_per_lambda,
|
|
347
349
|
'concurrency': self.concurrency,
|
|
@@ -4,6 +4,7 @@ from dataclasses import asdict
|
|
|
4
4
|
import random
|
|
5
5
|
import json
|
|
6
6
|
import hashlib
|
|
7
|
+
import time
|
|
7
8
|
from math import ceil
|
|
8
9
|
from typing import Optional, Union, List, Dict, Any
|
|
9
10
|
from enum import Enum
|
|
@@ -626,6 +627,38 @@ class RemotionClient:
|
|
|
626
627
|
|
|
627
628
|
return None
|
|
628
629
|
|
|
630
|
+
def cancel_render_on_lambda(self, render_id: str, bucket_name: str) -> None:
|
|
631
|
+
"""Cancel a render started with ``enable_cancellation=True``."""
|
|
632
|
+
s3_client = self._create_s3_client()
|
|
633
|
+
try:
|
|
634
|
+
progress_object = s3_client.get_object(
|
|
635
|
+
Bucket=bucket_name,
|
|
636
|
+
Key=f"renders/{render_id}/progress.json",
|
|
637
|
+
)
|
|
638
|
+
progress = json.loads(progress_object['Body'].read())
|
|
639
|
+
except (ClientError, KeyError, TypeError, json.JSONDecodeError) as error:
|
|
640
|
+
raise RemotionException(
|
|
641
|
+
f"Could not read progress for render {render_id}: {error}"
|
|
642
|
+
) from error
|
|
643
|
+
|
|
644
|
+
if progress.get('cancellationEnabled') is not True:
|
|
645
|
+
raise RemotionInvalidArgumentException(
|
|
646
|
+
f"Cannot cancel render {render_id}: The render was not started "
|
|
647
|
+
"with enableCancellation: true."
|
|
648
|
+
)
|
|
649
|
+
|
|
650
|
+
try:
|
|
651
|
+
s3_client.put_object(
|
|
652
|
+
Bucket=bucket_name,
|
|
653
|
+
Key=f"renders/{render_id}/cancel.json",
|
|
654
|
+
Body=json.dumps({'cancelledAt': int(time.time() * 1000)}),
|
|
655
|
+
ContentType='application/json',
|
|
656
|
+
)
|
|
657
|
+
except ClientError as error:
|
|
658
|
+
raise RemotionException(
|
|
659
|
+
f"Could not cancel render {render_id}: {error}"
|
|
660
|
+
) from error
|
|
661
|
+
|
|
629
662
|
def render_still_on_lambda(
|
|
630
663
|
self, render_params: RenderStillParams
|
|
631
664
|
) -> Optional[RenderStillResponse]:
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
# pylint: disable=missing-module-docstring, missing-final-newline
|
|
2
|
-
VERSION = "4.0.
|
|
2
|
+
VERSION = "4.0.515"
|
{remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/tests/test_render_client_render_media.py
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import json
|
|
1
2
|
from unittest import TestCase
|
|
2
|
-
from unittest.mock import patch
|
|
3
|
+
from unittest.mock import Mock, patch
|
|
3
4
|
|
|
4
5
|
from remotion_lambda.models import RenderMediaParams, ShouldDownload, Webhook
|
|
5
6
|
from remotion_lambda.remotionclient import RemotionClient
|
|
@@ -11,6 +12,46 @@ class TestRemotionClient(TestCase):
|
|
|
11
12
|
render_params = RenderMediaParams()
|
|
12
13
|
|
|
13
14
|
self.assertFalse(render_params.serialize_params()['overwrite'])
|
|
15
|
+
self.assertFalse(render_params.serialize_params()['enableCancellation'])
|
|
16
|
+
|
|
17
|
+
def test_enable_cancellation_is_serialized(self):
|
|
18
|
+
render_params = RenderMediaParams(enable_cancellation=True)
|
|
19
|
+
|
|
20
|
+
self.assertTrue(render_params.serialize_params()['enableCancellation'])
|
|
21
|
+
|
|
22
|
+
def test_cancel_render_on_lambda(self):
|
|
23
|
+
client = RemotionClient(
|
|
24
|
+
region="us-east-1", serve_url="testbed", function_name="remotion-render"
|
|
25
|
+
)
|
|
26
|
+
s3_client = Mock()
|
|
27
|
+
s3_client.get_object.return_value = {
|
|
28
|
+
'Body': Mock(read=Mock(return_value=b'{"cancellationEnabled": true}'))
|
|
29
|
+
}
|
|
30
|
+
client._create_s3_client = Mock(return_value=s3_client)
|
|
31
|
+
|
|
32
|
+
client.cancel_render_on_lambda('render-id', 'remotionlambda-test')
|
|
33
|
+
|
|
34
|
+
s3_client.get_object.assert_called_once_with(
|
|
35
|
+
Bucket='remotionlambda-test', Key='renders/render-id/progress.json'
|
|
36
|
+
)
|
|
37
|
+
put_input = s3_client.put_object.call_args.kwargs
|
|
38
|
+
self.assertEqual(put_input['Key'], 'renders/render-id/cancel.json')
|
|
39
|
+
self.assertGreater(json.loads(put_input['Body'])['cancelledAt'], 0)
|
|
40
|
+
|
|
41
|
+
def test_cancel_render_requires_opt_in(self):
|
|
42
|
+
client = RemotionClient(
|
|
43
|
+
region="us-east-1", serve_url="testbed", function_name="remotion-render"
|
|
44
|
+
)
|
|
45
|
+
s3_client = Mock()
|
|
46
|
+
s3_client.get_object.return_value = {'Body': Mock(read=Mock(return_value=b'{}'))}
|
|
47
|
+
client._create_s3_client = Mock(return_value=s3_client)
|
|
48
|
+
|
|
49
|
+
with self.assertRaisesRegex(
|
|
50
|
+
RemotionInvalidArgumentException, 'enableCancellation: true'
|
|
51
|
+
):
|
|
52
|
+
client.cancel_render_on_lambda('render-id', 'remotionlambda-test')
|
|
53
|
+
|
|
54
|
+
s3_client.put_object.assert_not_called()
|
|
14
55
|
|
|
15
56
|
@patch('remotion_lambda.models.VERSION', '5.0.0')
|
|
16
57
|
def test_overwrite_defaults_to_true_in_v5(self):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/remotion_lambda.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/tests/test_get_render_progress_client.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{remotion_lambda-4.0.514 → remotion_lambda-4.0.515}/tests/test_render_client_render_still.py
RENAMED
|
File without changes
|