MCPcopy
hub / github.com/zgsm-ai/costrict / processTask

Function processTask

packages/evals/src/cli/processTask.ts:13–65  ·  view source on GitHub ↗
({
	taskId,
	jobToken,
	logger,
}: {
	taskId: number
	jobToken: string | null
	logger?: Logger
})

Source from the content-addressed store, hash-verified

11import { runTaskInVscode } from "./runTaskInVscode"
12
13export const processTask = async ({
14 taskId,
15 jobToken,
16 logger,
17}: {
18 taskId: number
19 jobToken: string | null
20 logger?: Logger
21}) => {
22 const task = await findTask(taskId)
23 const { language, exercise } = task
24 const run = await findRun(task.runId)
25 await registerRunner({ runId: run.id, taskId, timeoutSeconds: (run.timeout || 5) * 60 })
26
27 const containerized = isDockerContainer()
28
29 logger =
30 logger ||
31 new Logger({
32 logDir: containerized ? `/var/log/evals/runs/${run.id}` : `/tmp/evals/runs/${run.id}`,
33 filename: `${language}-${exercise}.log`,
34 tag: getTag("runTask", { run, task }),
35 })
36
37 try {
38 const publish = async (e: TaskEvent) => {
39 const redis = await redisClient()
40 await redis.publish(getPubSubKey(run.id), JSON.stringify(e))
41 }
42
43 const executionMethod = run.executionMethod || "vscode"
44 logger.info(`running task ${task.id} (${language}/${exercise}) via ${executionMethod}...`)
45
46 if (executionMethod === "cli") {
47 await runTaskWithCli({ run, task, jobToken, publish, logger })
48 } else {
49 await runTaskInVscode({ run, task, jobToken, publish, logger })
50 }
51
52 logger.info(`testing task ${task.id} (${language}/${exercise})...`)
53 const passed = await runUnitTest({ task, logger })
54
55 logger.info(`task ${task.id} (${language}/${exercise}) -> ${passed}`)
56 await updateTask(task.id, { passed })
57
58 await publish({
59 eventName: passed ? RooCodeEventName.EvalPass : RooCodeEventName.EvalFail,
60 taskId: task.id,
61 })
62 } finally {
63 await deregisterRunner({ runId: run.id, taskId })
64 }
65}
66
67export const processTaskInContainer = async ({
68 taskId,

Callers 2

mainFunction · 0.90
createTaskRunnerFunction · 0.90

Calls 12

registerRunnerFunction · 0.90
isDockerContainerFunction · 0.90
getTagFunction · 0.90
runTaskWithCliFunction · 0.90
runTaskInVscodeFunction · 0.90
runUnitTestFunction · 0.90
deregisterRunnerFunction · 0.90
findTaskFunction · 0.85
findRunFunction · 0.85
updateTaskFunction · 0.85
publishFunction · 0.70
infoMethod · 0.65

Tested by

no test coverage detected