Skip to content

🎥 Make videos programmatically with React

fix types

Jonny Burger9628fd794fe3
diff --git a/packages/lambda/src/api/estimate-price.ts b/packages/lambda/src/api/estimate-price.ts
index 23e8ab452d..2eafa0f630 100644
--- a/packages/lambda/src/api/estimate-price.ts
+++ b/packages/lambda/src/api/estimate-price.ts
@@ -83,7 +83,6 @@ export const estimatePrice = ({
chargedDiskSize *
Number(diskSizePrice) *
(durationInMiliseconds / 1000 / 1024);
- console.log({diskSizeDollars, chargedDiskSize});
const invocationCost =
Number(pricing[region]['Lambda Requests'].price) * lambdasInvoked;
diff --git a/packages/lambda/src/functions/helpers/create-post-render-data.ts b/packages/lambda/src/functions/helpers/create-post-render-data.ts
index df9377d02e..126f90f51a 100644
--- a/packages/lambda/src/functions/helpers/create-post-render-data.ts
+++ b/packages/lambda/src/functions/helpers/create-post-render-data.ts
@@ -2,8 +2,8 @@ import {_Object} from '@aws-sdk/client-s3';
import {estimatePrice} from '../../api/estimate-price';
import {AwsRegion} from '../../pricing/aws-regions';
import {
- DEFAULT_EPHEMERAL_STORAGE_IN_MB,
lambdaTimingsPrefix,
+ MAX_EPHEMERAL_STORAGE_IN_MB,
PostRenderData,
RenderMetadata,
} from '../../shared/constants';
@@ -59,8 +59,9 @@ export const createPostRenderData = async ({
region,
architecture: getCurrentArchitecture(),
lambdasInvoked: renderMetadata.estimatedTotalLambdaInvokations,
- // TODO: Cannot yet access disk size via env variable
- diskSizeInMb: DEFAULT_EPHEMERAL_STORAGE_IN_MB,
+ // We cannot determine the ephemeral storage size, so we
+ // overestimate the price, but will only have a miniscule effect (~0.2%)
+ diskSizeInMb: MAX_EPHEMERAL_STORAGE_IN_MB,
});
if (!outputFile) {
diff --git a/packages/lambda/src/functions/helpers/get-progress.ts b/packages/lambda/src/functions/helpers/get-progress.ts
index 739440a1f2..73bf23b9a3 100644
--- a/packages/lambda/src/functions/helpers/get-progress.ts
+++ b/packages/lambda/src/functions/helpers/get-progress.ts
@@ -2,8 +2,8 @@ import {Internals} from 'remotion';
import {AwsRegion} from '../../pricing/aws-regions';
import {
chunkKey,
- DEFAULT_EPHEMERAL_STORAGE_IN_MB,
encodingProgressKey,
+ MAX_EPHEMERAL_STORAGE_IN_MB,
renderMetadataKey,
RenderProgress,
rendersPrefix,
@@ -151,8 +151,9 @@ export const getProgress = async ({
outputFileMetadata: outputFile,
architecture: getCurrentArchitecture(),
lambdasInvoked: renderMetadata?.estimatedRenderLambdaInvokations ?? 0,
- // TODO: Get from outside Lambda fn
- diskSizeInMb: DEFAULT_EPHEMERAL_STORAGE_IN_MB,
+ // We cannot determine the ephemeral storage size, so we
+ // overestimate the price, but will only have a miniscule effect (~0.2%)
+ diskSizeInMb: MAX_EPHEMERAL_STORAGE_IN_MB,
})
);
diff --git a/packages/lambda/src/functions/still.ts b/packages/lambda/src/functions/still.ts
index e79428991f..c22275842d 100644
--- a/packages/lambda/src/functions/still.ts
+++ b/packages/lambda/src/functions/still.ts
@@ -8,10 +8,10 @@ import {getOrCreateBucket} from '../api/get-or-create-bucket';
import {getLambdaClient} from '../shared/aws-clients';
import {
CURRENT_VERSION,
- DEFAULT_EPHEMERAL_STORAGE_IN_MB,
LambdaPayload,
LambdaPayloads,
LambdaRoutines,
+ MAX_EPHEMERAL_STORAGE_IN_MB,
RenderMetadata,
renderMetadataKey,
} from '../shared/constants';
@@ -142,8 +142,9 @@ const innerStillHandler = async (
region: getCurrentRegionInFunction(),
lambdasInvoked: 1,
architecture: getCurrentArchitecture(),
- // TODO: Get from outside function
- diskSizeInMb: DEFAULT_EPHEMERAL_STORAGE_IN_MB,
+ // We cannot determine the ephemeral storage size, so we
+ // overestimate the price, but will only have a miniscule effect (~0.2%)
+ diskSizeInMb: MAX_EPHEMERAL_STORAGE_IN_MB,
});
return {
diff --git a/packages/lambda/src/test/unit/price-calculation.test.ts b/packages/lambda/src/test/unit/price-calculation.test.ts
index 9a7b147ef0..b84f5bb3b2 100644
--- a/packages/lambda/src/test/unit/price-calculation.test.ts
+++ b/packages/lambda/src/test/unit/price-calculation.test.ts
@@ -46,6 +46,9 @@ test('Should not throw while calculating prices when time shifts occur', () => {
lastModified: Date.now() - 2000,
size: 1000000,
},
+ architecture: 'x86_64',
+ diskSizeInMb: 512,
+ lambdasInvoked: 1,
});
expect(price).toBeGreaterThanOrEqual(0);
});
diff --git a/packages/lambda/src/test/unit/pricing.test.ts b/packages/lambda/src/test/unit/pricing.test.ts
index 9d7b13e555..c6054ff1cb 100644
--- a/packages/lambda/src/test/unit/pricing.test.ts
+++ b/packages/lambda/src/test/unit/pricing.test.ts
@@ -4,31 +4,31 @@ test('Should calculate costs accurately', () => {
expect(
estimatePrice({
region: 'us-east-1',
- durationInMiliseconds: 20000,
+ durationInMiliseconds: 20000000,
memorySizeInMb: 2048,
architecture: 'x86_64',
diskSizeInMb: 512,
lambdasInvoked: 1,
})
- ).toEqual(0.00067);
+ ).toEqual(0.66667);
expect(
estimatePrice({
region: 'us-east-1',
- durationInMiliseconds: 20000,
+ durationInMiliseconds: 20000000,
memorySizeInMb: 2048,
architecture: 'x86_64',
diskSizeInMb: 10240,
lambdasInvoked: 1,
})
- ).toEqual(0.00067);
+ ).toEqual(0.67254);
expect(
estimatePrice({
region: 'us-east-1',
- durationInMiliseconds: 20000,
- memorySizeInMb: 1024,
- architecture: 'x86_64',
- diskSizeInMb: 512,
+ durationInMiliseconds: 20000000,
+ memorySizeInMb: 2048,
+ architecture: 'arm64',
+ diskSizeInMb: 10240,
lambdasInvoked: 1,
})
- ).toEqual(0.00033);
+ ).toEqual(0.53921);
});