-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcheck-missing-trajectory-id.ts
More file actions
executable file
·63 lines (51 loc) · 1.84 KB
/
check-missing-trajectory-id.ts
File metadata and controls
executable file
·63 lines (51 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env bun
import fs from 'fs/promises';
import path from 'path';
type TaskTrialEntry = {
job_name?: unknown;
trial_name?: unknown;
trajectory_id?: unknown;
};
async function main() {
const tasksPath = path.join(process.cwd(), 'site', 'tasks.json');
const raw = await fs.readFile(tasksPath, 'utf-8');
const parsed = JSON.parse(raw) as unknown;
if (typeof parsed !== 'object' || parsed === null) {
throw new Error(`Invalid tasks.json format: ${tasksPath}`);
}
const tasks = parsed as Record<string, unknown>;
const missing: Array<{ taskName: string; jobName: string; trialName: string }> = [];
for (const [taskName, entries] of Object.entries(tasks)) {
if (!Array.isArray(entries)) {
continue;
}
for (const entry of entries) {
if (typeof entry !== 'object' || entry === null) {
continue;
}
const trial = entry as TaskTrialEntry;
const jobName = typeof trial.job_name === 'string' ? trial.job_name : 'unknown-job';
const trialName = typeof trial.trial_name === 'string' ? trial.trial_name : 'unknown-trial';
const trajectoryId = typeof trial.trajectory_id === 'string' ? trial.trajectory_id.trim() : '';
if (!trajectoryId) {
missing.push({ taskName, jobName, trialName });
}
}
}
if (missing.length > 0) {
console.error(`Missing trajectory_id in ${missing.length} trial(s):`);
const maxLines = 100;
for (const item of missing.slice(0, maxLines)) {
console.error(`- ${item.taskName}: ${item.jobName}/${item.trialName}`);
}
if (missing.length > maxLines) {
console.error(`... and ${missing.length - maxLines} more`);
}
process.exit(1);
}
console.log('All trials have trajectory_id.');
}
main().catch((error) => {
console.error(error instanceof Error ? error.message : String(error));
process.exit(1);
});