MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / runBatchRender

Function runBatchRender

packages/cli/src/commands/batchRender.ts:382–450  ·  view source on GitHub ↗
(options: RunBatchRenderOptions)

Source from the content-addressed store, hash-verified

380}
381
382export async function runBatchRender(options: RunBatchRenderOptions): Promise<BatchManifest> {
383 if (options.concurrency < 1) {
384 throw new BatchRenderInputError(
385 "Invalid batch-concurrency",
386 `Got "${options.concurrency}". Must be a positive integer.`,
387 );
388 }
389
390 const manifest = makeInitialManifest(options.prepared);
391 writeManifest(manifest);
392
393 if (!options.quiet && !options.json) {
394 console.log("");
395 console.log(
396 c.accent("◆") +
397 ` Batch rendering ${options.prepared.rows.length} rows` +
398 c.dim(` → ${options.prepared.manifestPath}`),
399 );
400 console.log(c.dim(` batch concurrency: ${options.concurrency}`));
401 console.log("");
402 }
403
404 let cursor = 0;
405 let stopLaunching = false;
406 const workerCount = Math.min(options.concurrency, options.prepared.rows.length);
407
408 await Promise.all(
409 Array.from({ length: workerCount }, async () => {
410 while (!stopLaunching) {
411 const row = options.prepared.rows[cursor];
412 if (!row) return;
413 cursor++;
414
415 const ok = await renderBatchRow(row, manifest, options);
416 if (!ok && options.failFast) {
417 stopLaunching = true;
418 }
419 }
420 }),
421 );
422
423 if (stopLaunching) markUnstartedRowsSkipped(manifest);
424 writeManifest(manifest);
425 emitJsonEvent(
426 {
427 type: "batch-complete",
428 manifestPath: manifest.manifestPath,
429 total: manifest.total,
430 completed: manifest.completed,
431 failed: manifest.failed,
432 skipped: manifest.skipped,
433 },
434 options.json,
435 );
436
437 if (!options.quiet && !options.json) {
438 console.log("");
439 console.log(

Callers 1

Calls 7

makeInitialManifestFunction · 0.85
renderBatchRowFunction · 0.85
markUnstartedRowsSkippedFunction · 0.85
emitJsonEventFunction · 0.85
fromMethod · 0.80
warnMethod · 0.80
writeManifestFunction · 0.70

Tested by

no test coverage detected