Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions evals/apps/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { getExercises } from "./exercises.js"
type TaskResult = { success: boolean; retry: boolean }
type TaskPromise = Promise<TaskResult>

const MAX_CONCURRENCY = 20
const MAX_CONCURRENCY = 5
const TASK_TIMEOUT = 10 * 60 * 1_000
const UNIT_TEST_TIMEOUT = 60 * 1_000

Expand Down Expand Up @@ -115,8 +115,9 @@ const run = async (toolbox: GluegunToolbox) => {

// Retries aren't implemented yet, but the return values are set up to
// support them.
const processTask = async (task: Task) => {
const processTask = async (task: Task, delay = 0) => {
if (task.finishedAt === null) {
await new Promise((resolve) => setTimeout(resolve, delay))
const { retry } = await runExercise({ run, task, server })

if (retry) {
Expand All @@ -141,12 +142,15 @@ const run = async (toolbox: GluegunToolbox) => {
}
}

let delay = 0
for (const task of tasks) {
const promise = processTask(task)
const promise = processTask(task, delay)
delay = delay + 5_000
runningPromises.push(promise)
promise.then(() => processTaskResult(task, promise))

if (runningPromises.length > MAX_CONCURRENCY) {
if (runningPromises.length >= MAX_CONCURRENCY) {
delay = 0
await Promise.race(runningPromises)
}
}
Expand Down