Files
hyperframes/packages/cli/src/commands/lambda/progress.ts
T
Miguel Ángel 504ec2b307 feat(cli): lambda deploy renders on arm64 by default; --video-arch x86_64 keeps x86 (#6073)
* feat(aws-lambda): price arm64 chunk invocations at the arm64 rate

getRenderProgress takes chunkArchitecture, the architecture of the function
that renders chunks. RenderChunk invocations are priced at its per GB-second
rate, both inline and from a Distributed Map's output; plan, audio and
assemble stay at the x86 rate.

* feat(cli): render chunks on an arm64 function with lambda deploy --video-arch

--video-arch arm64 pushes the arm64 video function image to the stack's own
ECR repository and deploys the template with VideoImageUri set to its digest.
Outside a checkout the image is the one the installed adapter pins; inside a
checkout it must come from HYPERFRAMES_LAMBDA_VIDEO_IMAGE, built from that
checkout. The default stays x86_64, which always sends an empty VideoImageUri
so a redeploy drops a video function rather than keeping it.

destroy deletes the repository, render and progress price chunks at the arm64
rate, and policies lists the ECR actions.

* fix(cli): push the video image only to an ECR repository this stack tagged

* fix(cli): price the plan at the video function's rate now that it runs there

* feat(cli): lambda deploy renders on arm64 by default; --video-arch x86_64 keeps x86

* refactor(cli): drop two doc comments the names already carry
2026-10-23 05:45:49 +00:00

88 lines
3.1 KiB
TypeScript

import { setCommandExitCode } from "../../utils/commandResult.js";
/**
* `hyperframes lambda progress <executionArn>` — print a single progress
* snapshot for a render. Wraps {@link getRenderProgress}. Accepts a
* full executionArn or a renderId (in which case we resolve the arn
* from the stack's region + state-machine name).
*/
import { c } from "../../ui/colors.js";
import { videoArchitecture, requireStack } from "./state.js";
export interface ProgressArgs {
/** Full SFN execution ARN OR the renderId (== execution name). */
target: string;
stackName: string;
json: boolean;
}
export async function runProgress(args: ProgressArgs): Promise<void> {
const stack = requireStack(args.stackName);
// Allow callers to pass either the full ARN or the renderId/exec name.
// The state machine ARN is on the stack, so deriving the execution ARN
// from a bare name is a deterministic suffix swap.
const executionArn = args.target.startsWith("arn:")
? args.target
: executionArnFromName(stack.stateMachineArn, args.target);
// Dynamic-import the SDK so tsup keeps it out of the static-import head
// of the CLI bundle. See sites.ts loadSDK() for the full rationale.
const { getRenderProgress } = await import("@hyperframes/aws-lambda/sdk");
const progress = await getRenderProgress({
executionArn,
region: stack.region,
defaultMemorySizeMb: stack.lambdaMemoryMb,
videoArchitecture: videoArchitecture(stack),
});
if (args.json) {
console.log(JSON.stringify(progress, null, 2));
return;
}
for (const warning of progress.warnings) console.warn(c.warn(warning));
const pct = Math.round(progress.overallProgress * 100);
console.log(`${c.dim("Status:")} ${statusColor(progress.status)}`);
console.log(`${c.dim("Progress:")} ${pct}%`);
console.log(
`${c.dim("Frames:")} ${progress.framesRendered}${progress.totalFrames === null ? "" : ` / ${progress.totalFrames}`}`,
);
console.log(`${c.dim("Lambdas:")} ${progress.lambdasInvoked}`);
console.log(
`${c.dim("Cost:")} ${progress.costs.displayCost} (Lambda $${progress.costs.breakdown.lambdaUsd.toFixed(4)} + SFN $${progress.costs.breakdown.stepFunctionsUsd.toFixed(4)})`,
);
if (progress.outputFile) {
console.log(`${c.dim("Output:")} ${progress.outputFile.s3Uri}`);
}
if (progress.errors.length > 0) {
console.log();
console.log(c.error("Errors:"));
for (const err of progress.errors) {
console.log(` ${c.dim(err.state)}: ${err.error} — ${err.cause}`);
}
}
if (progress.fatalErrorEncountered) {
setCommandExitCode(1);
}
}
function executionArnFromName(stateMachineArn: string, name: string): string {
// `arn:aws:states:<region>:<account>:stateMachine:<sm-name>` →
// `arn:aws:states:<region>:<account>:execution:<sm-name>:<exec-name>`
return stateMachineArn.replace(":stateMachine:", ":execution:") + `:${name}`;
}
function statusColor(status: string): string {
switch (status) {
case "SUCCEEDED":
return c.success(status);
case "FAILED":
case "TIMED_OUT":
case "ABORTED":
return c.error(status);
default:
return status;
}
}