Skip to content

Commit 7bd902f

Browse files
authored
enforce package.json for grading fix (#777)
1 parent 91c3441 commit 7bd902f

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

harness/lib/collection.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export async function collectResults(resultsDir: string, suiteConfig: SuiteConfi
144144
console.warn("Failed to parse existing package.json, overwriting...");
145145
}
146146
}
147-
pkgJsonObj.scripts["run-grader"] = `node grade.mjs --id ${relativeId}`;
147+
pkgJsonObj.scripts["run-grader"] = `node --experimental-strip-types grade.mjs --id ${relativeId}`;
148148
fs.writeFileSync(targetPkgJson, JSON.stringify(pkgJsonObj, null, 2));
149149

150150
pnpmWorkspacePackages.push(relativeId);
@@ -153,15 +153,32 @@ export async function collectResults(resultsDir: string, suiteConfig: SuiteConfi
153153

154154
// --- PASS 1.5: Execute the accumulated grading runs in parallel ---
155155
if (pnpmWorkspacePackages.length > 0) {
156-
console.log(`\n>>> Discovered ${pnpmWorkspacePackages.length} un-graded tasks. Running parallel grading with pnpm -r run-grader...`);
156+
const rootPkgJsonPath = path.join(resultsDir, 'package.json');
157+
let wroteRootPkgJson = false;
158+
if (!fs.existsSync(rootPkgJsonPath)) {
159+
fs.writeFileSync(rootPkgJsonPath, JSON.stringify({
160+
name: "evaluation-suite-workspace",
161+
private: true
162+
}, null, 2));
163+
wroteRootPkgJson = true;
164+
}
165+
157166
const pnpmWorkspacePath = path.join(resultsDir, 'pnpm-workspace.yaml');
158167
fs.writeFileSync(pnpmWorkspacePath, 'packages:\n - \'**\'\n');
168+
159169
try {
170+
console.log(`\n>>> Bootstrapping dependencies inside results workspace with pnpm install...`);
171+
spawnSync('pnpm', ['install', '--no-frozen-lockfile'], { cwd: resultsDir, stdio: 'inherit' });
172+
173+
console.log(`\n>>> Discovered ${pnpmWorkspacePackages.length} un-graded tasks. Running parallel grading with pnpm -r run-grader...`);
160174
spawnSync('pnpm', ['-r', 'run-grader'], { cwd: resultsDir, stdio: 'inherit' });
161175
} finally {
162176
if (fs.existsSync(pnpmWorkspacePath)) {
163177
fs.unlinkSync(pnpmWorkspacePath);
164178
}
179+
if (wroteRootPkgJson && fs.existsSync(rootPkgJsonPath)) {
180+
fs.unlinkSync(rootPkgJsonPath);
181+
}
165182
}
166183
console.log(`✅ Completed parallel grading pass\n`);
167184
}

harness/run_suite.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ let graderStatus = null;
438438
439439
if (result.status === 0) {
440440
const gradeStart = Date.now();
441-
const gradeResult = spawnSync(process.execPath, ['grade.mjs'], { stdio: 'inherit', cwd: ${JSON.stringify(targetDir)} });
441+
const gradeResult = spawnSync(process.execPath, ['--experimental-strip-types', 'grade.mjs'], { stdio: 'inherit', cwd: ${JSON.stringify(targetDir)} });
442442
graderRuntime = Date.now() - gradeStart;
443443
graderStatus = gradeResult.status;
444444
}

0 commit comments

Comments
 (0)