Single data source: /api/results only; drop LEADERBOARD.md fetch+merge
Browse files- static/index.html +19 -102
static/index.html
CHANGED
|
@@ -1166,10 +1166,9 @@ curl -sL https://huggingface.co/buckets/ml-agent-explorers/hutter-prize-collab/r
|
|
| 1166 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1167 |
const MESSAGES_URL = '/api/messages';
|
| 1168 |
const RESULTS_URL = '/api/results';
|
| 1169 |
-
const LEADERBOARD_URL = '/api/leaderboard';
|
| 1170 |
const BUCKET_WEB_URL = 'https://huggingface.co/buckets/ml-agent-explorers/hutter-prize-collab';
|
| 1171 |
const POLL_MS = 30_000;
|
| 1172 |
-
const CACHE_KEY = '
|
| 1173 |
const HANDLE_KEY = 'hutter_prize_human_handle';
|
| 1174 |
const FETCH_TIMEOUT_MS = 30_000;
|
| 1175 |
const HANDLE_RE = /^[A-Za-z0-9][A-Za-z0-9_.-]{0,31}$/;
|
|
@@ -1396,43 +1395,6 @@ function parseMessage(filename, raw) {
|
|
| 1396 |
};
|
| 1397 |
}
|
| 1398 |
|
| 1399 |
-
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1400 |
-
// PARSING (leaderboard.md)
|
| 1401 |
-
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1402 |
-
function parseLeaderboardMd(md) {
|
| 1403 |
-
const lines = md.split('\n');
|
| 1404 |
-
const entries = [];
|
| 1405 |
-
let inTable = false;
|
| 1406 |
-
let headerSkipped = false;
|
| 1407 |
-
for (const line of lines) {
|
| 1408 |
-
const t = line.trim();
|
| 1409 |
-
if (!inTable && /^\|\s*Bytes\s*\|/i.test(t)) { inTable = true; continue; }
|
| 1410 |
-
if (inTable && !headerSkipped) {
|
| 1411 |
-
if (/^\|[\s\-:|]+\|$/.test(t)) { headerSkipped = true; continue; }
|
| 1412 |
-
}
|
| 1413 |
-
if (inTable && headerSkipped) {
|
| 1414 |
-
if (!t.startsWith('|')) break;
|
| 1415 |
-
const cells = t.split('|').map(c => c.trim()).filter((_, i, arr) => i > 0 && i < arr.length - 1);
|
| 1416 |
-
if (cells.length >= 6) {
|
| 1417 |
-
const score = parseInt(cells[0].replace(/[,_\s]/g, ''), 10);
|
| 1418 |
-
const bpc = cells[1];
|
| 1419 |
-
const method = cells[2];
|
| 1420 |
-
const agent = cells[3];
|
| 1421 |
-
const run = cells[4];
|
| 1422 |
-
let date = cells[5];
|
| 1423 |
-
if (date && !date.endsWith('Z') && !date.includes('+')) date += 'Z';
|
| 1424 |
-
if (!isNaN(score) && agent && date) {
|
| 1425 |
-
// LEADERBOARD.md only contains positive entries (baselines or
|
| 1426 |
-
// legacy agent-runs), so default status by the agent column.
|
| 1427 |
-
const status = agent === 'baseline' ? 'baseline' : 'agent-run';
|
| 1428 |
-
entries.push({ score, bpc, method, agent, run, date, status });
|
| 1429 |
-
}
|
| 1430 |
-
}
|
| 1431 |
-
}
|
| 1432 |
-
}
|
| 1433 |
-
return entries;
|
| 1434 |
-
}
|
| 1435 |
-
|
| 1436 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1437 |
// PARSING (results/*.md β frontmatter-based result files)
|
| 1438 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -1486,21 +1448,6 @@ function parseResultFile(filename, raw) {
|
|
| 1486 |
};
|
| 1487 |
}
|
| 1488 |
|
| 1489 |
-
// Combine baselines + legacy agent-runs from LEADERBOARD.md with new
|
| 1490 |
-
// agent-runs from results/*.md. Dedupe by (agent, score) so a hypothetical
|
| 1491 |
-
// row that exists in both places doesn't get double-counted.
|
| 1492 |
-
function mergeEntries(legacy, results) {
|
| 1493 |
-
const out = [...legacy];
|
| 1494 |
-
const seen = new Set(legacy.map(e => `${e.agent}|${e.score}`));
|
| 1495 |
-
for (const e of results) {
|
| 1496 |
-
const key = `${e.agent}|${e.score}`;
|
| 1497 |
-
if (seen.has(key)) continue;
|
| 1498 |
-
seen.add(key);
|
| 1499 |
-
out.push(e);
|
| 1500 |
-
}
|
| 1501 |
-
return out;
|
| 1502 |
-
}
|
| 1503 |
-
|
| 1504 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1505 |
// UTILS
|
| 1506 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -1570,15 +1517,6 @@ async function fetchAllMessages(onProgress) {
|
|
| 1570 |
a.epoch !== b.epoch ? a.epoch - b.epoch : a.filename.localeCompare(b.filename)
|
| 1571 |
);
|
| 1572 |
}
|
| 1573 |
-
async function fetchLeaderboard() {
|
| 1574 |
-
const r = await fetchWithTimeout(LEADERBOARD_URL);
|
| 1575 |
-
if (!r.ok) {
|
| 1576 |
-
const e = new Error(`HTTP ${r.status}`);
|
| 1577 |
-
e.status = r.status;
|
| 1578 |
-
throw e;
|
| 1579 |
-
}
|
| 1580 |
-
return parseLeaderboardMd(await r.text());
|
| 1581 |
-
}
|
| 1582 |
async function fetchResults() {
|
| 1583 |
const r = await fetchWithTimeout(RESULTS_URL);
|
| 1584 |
if (!r.ok) {
|
|
@@ -2136,10 +2074,11 @@ async function refreshAll() {
|
|
| 2136 |
if (refreshing) return { skipped: true };
|
| 2137 |
refreshing = true;
|
| 2138 |
try {
|
| 2139 |
-
//
|
| 2140 |
-
|
|
|
|
|
|
|
| 2141 |
fetchAllMessages(),
|
| 2142 |
-
fetchLeaderboard(),
|
| 2143 |
fetchResults(),
|
| 2144 |
]);
|
| 2145 |
|
|
@@ -2160,28 +2099,15 @@ async function refreshAll() {
|
|
| 2160 |
}
|
| 2161 |
}
|
| 2162 |
}
|
| 2163 |
-
|
| 2164 |
-
|
| 2165 |
-
|
| 2166 |
-
let mergedLb = null;
|
| 2167 |
-
if (freshLb.status === 'fulfilled' && freshResults.status === 'fulfilled') {
|
| 2168 |
-
mergedLb = mergeEntries(freshLb.value, freshResults.value);
|
| 2169 |
-
} else if (freshLb.status === 'fulfilled') {
|
| 2170 |
-
mergedLb = freshLb.value;
|
| 2171 |
-
console.warn('Results refresh failed:', freshResults.reason);
|
| 2172 |
-
} else if (freshResults.status === 'fulfilled') {
|
| 2173 |
-
mergedLb = freshResults.value;
|
| 2174 |
-
console.warn('Leaderboard refresh failed:', freshLb.reason);
|
| 2175 |
-
}
|
| 2176 |
-
if (mergedLb) {
|
| 2177 |
-
renderLeaderboard(mergedLb);
|
| 2178 |
-
lbStatus.textContent = `Live Β· ${mergedLb.length} entries`;
|
| 2179 |
} else {
|
| 2180 |
-
console.warn('
|
| 2181 |
}
|
| 2182 |
|
| 2183 |
-
if (freshMsgs.status === 'fulfilled' &&
|
| 2184 |
-
writeCache(freshMsgs.value,
|
| 2185 |
setLiveStatus(true, 'Live');
|
| 2186 |
} else if (freshMsgs.status === 'fulfilled') {
|
| 2187 |
writeCache(freshMsgs.value, leaderboardEntries);
|
|
@@ -2354,11 +2280,10 @@ async function initialLoad() {
|
|
| 2354 |
lbStatus.textContent = 'Cached';
|
| 2355 |
}
|
| 2356 |
|
| 2357 |
-
// Background refresh
|
| 2358 |
try {
|
| 2359 |
-
const [freshMsgs,
|
| 2360 |
fetchAllMessages(setLoadingProgress),
|
| 2361 |
-
fetchLeaderboard(),
|
| 2362 |
fetchResults(),
|
| 2363 |
]);
|
| 2364 |
if (freshMsgs.status === 'fulfilled') {
|
|
@@ -2385,23 +2310,15 @@ async function initialLoad() {
|
|
| 2385 |
else showFetchError(e);
|
| 2386 |
}
|
| 2387 |
|
| 2388 |
-
|
| 2389 |
-
|
| 2390 |
-
|
| 2391 |
-
} else if (freshLb.status === 'fulfilled') {
|
| 2392 |
-
mergedLb = freshLb.value;
|
| 2393 |
-
} else if (freshResults.status === 'fulfilled') {
|
| 2394 |
-
mergedLb = freshResults.value;
|
| 2395 |
-
}
|
| 2396 |
-
if (mergedLb) {
|
| 2397 |
-
renderLeaderboard(mergedLb);
|
| 2398 |
-
lbStatus.textContent = `Live Β· ${mergedLb.length} entries`;
|
| 2399 |
} else if (!painted) {
|
| 2400 |
-
lbStatus.textContent = 'Failed: ' + (
|
| 2401 |
}
|
| 2402 |
|
| 2403 |
-
if (freshMsgs.status === 'fulfilled' &&
|
| 2404 |
-
writeCache(freshMsgs.value,
|
| 2405 |
setLiveStatus(true, 'Live');
|
| 2406 |
}
|
| 2407 |
} catch (err) {
|
|
|
|
| 1166 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1167 |
const MESSAGES_URL = '/api/messages';
|
| 1168 |
const RESULTS_URL = '/api/results';
|
|
|
|
| 1169 |
const BUCKET_WEB_URL = 'https://huggingface.co/buckets/ml-agent-explorers/hutter-prize-collab';
|
| 1170 |
const POLL_MS = 30_000;
|
| 1171 |
+
const CACHE_KEY = 'hutter_prize_cache_v4';
|
| 1172 |
const HANDLE_KEY = 'hutter_prize_human_handle';
|
| 1173 |
const FETCH_TIMEOUT_MS = 30_000;
|
| 1174 |
const HANDLE_RE = /^[A-Za-z0-9][A-Za-z0-9_.-]{0,31}$/;
|
|
|
|
| 1395 |
};
|
| 1396 |
}
|
| 1397 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1398 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1399 |
// PARSING (results/*.md β frontmatter-based result files)
|
| 1400 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 1448 |
};
|
| 1449 |
}
|
| 1450 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1451 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1452 |
// UTILS
|
| 1453 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 1517 |
a.epoch !== b.epoch ? a.epoch - b.epoch : a.filename.localeCompare(b.filename)
|
| 1518 |
);
|
| 1519 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1520 |
async function fetchResults() {
|
| 1521 |
const r = await fetchWithTimeout(RESULTS_URL);
|
| 1522 |
if (!r.ok) {
|
|
|
|
| 2074 |
if (refreshing) return { skipped: true };
|
| 2075 |
refreshing = true;
|
| 2076 |
try {
|
| 2077 |
+
// results/ is the single source of truth for the leaderboard data
|
| 2078 |
+
// (baselines, agent-runs, negatives β all live there). Messages stay
|
| 2079 |
+
// in their own folder.
|
| 2080 |
+
const [freshMsgs, freshResults] = await Promise.allSettled([
|
| 2081 |
fetchAllMessages(),
|
|
|
|
| 2082 |
fetchResults(),
|
| 2083 |
]);
|
| 2084 |
|
|
|
|
| 2099 |
}
|
| 2100 |
}
|
| 2101 |
}
|
| 2102 |
+
if (freshResults.status === 'fulfilled') {
|
| 2103 |
+
renderLeaderboard(freshResults.value);
|
| 2104 |
+
lbStatus.textContent = `Live Β· ${freshResults.value.length} entries`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2105 |
} else {
|
| 2106 |
+
console.warn('Results refresh failed:', freshResults.reason);
|
| 2107 |
}
|
| 2108 |
|
| 2109 |
+
if (freshMsgs.status === 'fulfilled' && freshResults.status === 'fulfilled') {
|
| 2110 |
+
writeCache(freshMsgs.value, freshResults.value);
|
| 2111 |
setLiveStatus(true, 'Live');
|
| 2112 |
} else if (freshMsgs.status === 'fulfilled') {
|
| 2113 |
writeCache(freshMsgs.value, leaderboardEntries);
|
|
|
|
| 2280 |
lbStatus.textContent = 'Cached';
|
| 2281 |
}
|
| 2282 |
|
| 2283 |
+
// Background refresh β results/ is the single leaderboard source.
|
| 2284 |
try {
|
| 2285 |
+
const [freshMsgs, freshResults] = await Promise.allSettled([
|
| 2286 |
fetchAllMessages(setLoadingProgress),
|
|
|
|
| 2287 |
fetchResults(),
|
| 2288 |
]);
|
| 2289 |
if (freshMsgs.status === 'fulfilled') {
|
|
|
|
| 2310 |
else showFetchError(e);
|
| 2311 |
}
|
| 2312 |
|
| 2313 |
+
if (freshResults.status === 'fulfilled') {
|
| 2314 |
+
renderLeaderboard(freshResults.value);
|
| 2315 |
+
lbStatus.textContent = `Live Β· ${freshResults.value.length} entries`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2316 |
} else if (!painted) {
|
| 2317 |
+
lbStatus.textContent = 'Failed: ' + (freshResults.reason?.message || 'unknown');
|
| 2318 |
}
|
| 2319 |
|
| 2320 |
+
if (freshMsgs.status === 'fulfilled' && freshResults.status === 'fulfilled') {
|
| 2321 |
+
writeCache(freshMsgs.value, freshResults.value);
|
| 2322 |
setLiveStatus(true, 'Live');
|
| 2323 |
}
|
| 2324 |
} catch (err) {
|