Skip to content

Commit 90c1b90

Browse files
committed
evals: write trace to file when run in 'dev'
1 parent 9fa08b2 commit 90c1b90

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

evals/git-evals/run-git-evals.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,14 +233,26 @@ Explain your reasoning in detail. Do not ask Codebuff to git commit changes.`,
233233
const judgingResults = await judgeEvalRun(evalRun)
234234
console.log('Judging results:', judgingResults)
235235

236-
return {
236+
const result = {
237237
...evalRun,
238238
judging_results: judgingResults,
239239
computed_metrics: {
240240
runtime_sec: durationMs / 1000,
241241
cost_usd: totalCostUsd,
242242
},
243243
}
244+
245+
if (process.env.NEXT_PUBLIC_CB_ENVIRONMENT === 'dev') {
246+
const { eval_commit, gitDiff, ...rest } = result
247+
const { fileStates, ...rest2 } = eval_commit
248+
249+
writeJsonToFile(
250+
{ ...rest, ...rest2 },
251+
path.join(__dirname, `trace-${evalCommit.sha}.json`),
252+
)
253+
}
254+
255+
return result
244256
} catch (judgingError) {
245257
console.error('Error in judging:', judgingError)
246258
// Return without judging results if judging fails
@@ -269,6 +281,10 @@ Explain your reasoning in detail. Do not ask Codebuff to git commit changes.`,
269281
}
270282
}
271283

284+
function writeJsonToFile(json: any, path: string) {
285+
fs.writeFileSync(path, JSON.stringify(json, null, 2))
286+
}
287+
272288
function getCodebuffFileStates(
273289
evalCommitSha: string,
274290
projectPath: string,

0 commit comments

Comments
 (0)