🎥 Make videos programmatically with React
fix documentation and expose remotionlambda errors on failures
Alex Fernandez3fd6d46d4ac0
diff --git a/packages/docs/docs/lambda/python.md b/packages/docs/docs/lambda/python.mdindex 4e18a5d3d4..0d17d1136d 100644--- a/packages/docs/docs/lambda/python.md+++ b/packages/docs/docs/lambda/python.md@@ -1,7 +1,7 @@---image: /generated/articles-docs-lambda-python.pngtitle: Triggering renders from Python-slug: /lambda/php+slug: /lambda/pythonsidebar_label: Rendering from Pythoncrumb: "@remotion/lambda"---@@ -21,7 +21,6 @@ Below is a snippet showing how to initiate a render request and get its status.```python title="testclient.py"-from remotion_lambda import RenderParams, RenderProgressParamsfrom remotion_lambda import RemotionClientimport os@@ -51,19 +50,21 @@ render_params = RenderParams()print("\n")-# Execute render requestrender_response = client.render_media_on_lambda(render_params)-print(render_response.renderId)-print(render_response.bucketName)+if render_response:+ # Execute render request-print("\n")+ print(render_response.renderId)+ print(render_response.bucketName)++ print("\n")-if render_response:# Execute progress requestprogress_response = client.get_render_progress(render_id=render_response.renderId, bucket_name=render_response.bucketName)- print("Overall progress")- print(progress_response.overallProgress)+ if progress_response:+ print("Overall progress")+ print(progress_response.overallProgress)print("\n")diff --git a/packages/it-tests/src/monorepo/python-package.test.ts b/packages/it-tests/src/monorepo/python-package.test.tsindex 97d1cb2288..c4d35ac20d 100644--- a/packages/it-tests/src/monorepo/python-package.test.ts+++ b/packages/it-tests/src/monorepo/python-package.test.ts@@ -31,13 +31,10 @@ test("Set the right version for pytest", () => {test("Python package should create the same renderMedia payload as normal Lambda package", async () => {const cwd = path.join(process.cwd(), "..", "lambda-python");- console.log("cwd", cwd);const pythonOutput = execSync("pytest -rP tests/test_render_client.py", {cwd,});-const output = pythonOutput.toString().split("\n");- console.log(output);const toParse = output[10];const nativeVersion = await LambdaInternals.makeLambdaRenderMediaPayload({region: "us-east-1",@@ -49,10 +46,7 @@ test("Python package should create the same renderMedia payload as normal Lambdahi: "there",},});- console.log("nativeVersion");- console.log(nativeVersion);const jsonOutput = toParse.substring(0, toParse.lastIndexOf("}") + 1);- console.log(jsonOutput);const parsedJson = JSON.parse(jsonOutput);expect(@@ -65,8 +59,6 @@ test("Python package should create the same renderMedia payload as normal Lambdatest("Python package should create the same progress payload as normal Lambda package", async () => {const cwd = path.join(process.cwd(), "..", "lambda-python");- console.log("cwd", cwd);-const pythonOutput = execSync("pytest -rP tests/test_get_render_progress_client.py",{@@ -74,7 +66,6 @@ test("Python package should create the same progress payload as normal Lambda pa});const output = pythonOutput.toString().split("\n");- console.log(output);const toParse = output[10];const nativeVersion = LambdaInternals.getRenderProgressPayload({region: "us-east-1",diff --git a/packages/lambda-python/remotion_lambda/remotionclient.py b/packages/lambda-python/remotion_lambda/remotionclient.pyindex b5f3d8a38a..e68a1813e7 100644--- a/packages/lambda-python/remotion_lambda/remotionclient.py+++ b/packages/lambda-python/remotion_lambda/remotionclient.py@@ -77,11 +77,11 @@ class RemotionClient:response = client.invoke(FunctionName=function_name, Payload=payload)result = response['Payload'].read().decode('utf-8')-decoded_result = json.loads(result)+ if 'errorMessage' in decoded_result:+ raise ValueError(decoded_result['errorMessage'])if decoded_result['statusCode'] != 200:raise ValueError('Failed to invoke Lambda function')-body_object = json.loads(decoded_result['body'])return body_object@@ -140,7 +140,10 @@ class RemotionClient:params = self.construct_render_request(render_params)body_object = self._invoke_lambda(function_name=self.function_name, payload=params)- return RenderResponse(**body_object)+ if body_object:+ return RenderResponse(**body_object)+ else:+ return Nonedef get_render_progress(self, render_id: str, bucket_name: str) -> RenderProgress:"""@@ -156,7 +159,9 @@ class RemotionClient:params = self.construct_render_progress_request(render_id, bucket_name)progress_response = self._invoke_lambda(function_name=self.function_name, payload=params)- # print(progress_response)- render_progress = RenderProgress()- render_progress.__dict__.update(progress_response)- return render_progress+ if progress_response:+ render_progress = RenderProgress()+ render_progress.__dict__.update(progress_response)+ return render_progress+ else:+ return Nonediff --git a/packages/lambda-python/testclient.py b/packages/lambda-python/testclient.pyindex 9a7aa9465d..9002d2c46b 100644--- a/packages/lambda-python/testclient.py+++ b/packages/lambda-python/testclient.py@@ -28,17 +28,19 @@ render_params = RenderParams()print("\n")-# Execute render requestrender_response = client.render_media_on_lambda(render_params)-print(render_response.renderId)-print(render_response.bucketName)+if render_response:+ # Execute render request-print("\n")+ print(render_response.renderId)+ print(render_response.bucketName)++ print("\n")-if render_response:# Execute progress requestprogress_response = client.get_render_progress(render_id=render_response.renderId, bucket_name=render_response.bucketName)- print("Overall progress")- print(progress_response.overallProgress)+ if progress_response:+ print("Overall progress")+ print(progress_response.overallProgress)print("\n")