Spaces:
Sleeping
Sleeping
Zhu Jiajun (jz28583) Claude Opus 4.7 (1M context) commited on
Commit ·
53c64b6
1
Parent(s): bd3e9ac
Restore /admin/insert for maintainer leaderboard corrections
Browse filesRemoved earlier for integrity, but the maintainer needs a path to fix
known-bad rows whose CSVs are no longer available (e.g. the autopipe-v2
figraph 0.824 entry that should be 0.788). Same bypass-key gate.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- server/api.py +39 -0
server/api.py
CHANGED
|
@@ -483,6 +483,45 @@ def admin_delete():
|
|
| 483 |
})
|
| 484 |
|
| 485 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 486 |
@app.post("/admin/repoll/<run_id>")
|
| 487 |
def admin_repoll(run_id: str):
|
| 488 |
"""Re-trigger the Kaggle poll loop for a stuck/failed pending row, without
|
|
|
|
| 483 |
})
|
| 484 |
|
| 485 |
|
| 486 |
+
@app.post("/admin/insert")
|
| 487 |
+
def admin_insert():
|
| 488 |
+
"""Insert a leaderboard row directly. Bypass-key gated; intended for
|
| 489 |
+
maintainer corrections (e.g. backfilling a known score whose CSV is no
|
| 490 |
+
longer available). For routine scoring, use POST /submit.
|
| 491 |
+
|
| 492 |
+
Body: JSON {"task": "...", "agent": "...", "primary": float,
|
| 493 |
+
"secondary": {...}, "n_rows": int|null, "sha256": str|null}
|
| 494 |
+
"""
|
| 495 |
+
import datetime as _dt
|
| 496 |
+
import json as _json
|
| 497 |
+
import uuid as _uuid
|
| 498 |
+
|
| 499 |
+
sent_key = request.headers.get("X-Bypass-Key", "").strip()
|
| 500 |
+
if not (BYPASS_KEY and sent_key
|
| 501 |
+
and __import__("hmac").compare_digest(sent_key, BYPASS_KEY)):
|
| 502 |
+
return jsonify({"error": "bypass key required"}), 403
|
| 503 |
+
payload = request.get_json(silent=True) or {}
|
| 504 |
+
task = payload.get("task")
|
| 505 |
+
agent = payload.get("agent")
|
| 506 |
+
primary = payload.get("primary")
|
| 507 |
+
if not (task and agent and isinstance(primary, (int, float))):
|
| 508 |
+
return jsonify({"error": "task, agent, primary required"}), 400
|
| 509 |
+
secondary = payload.get("secondary") or {}
|
| 510 |
+
n_rows = int(payload.get("n_rows") or -1)
|
| 511 |
+
sha = payload.get("sha256") or "manual_insert"
|
| 512 |
+
run_id = _uuid.uuid4().hex[:12]
|
| 513 |
+
now = _dt.datetime.now(_dt.timezone.utc).isoformat()
|
| 514 |
+
conn = _db()
|
| 515 |
+
conn.execute(
|
| 516 |
+
"INSERT INTO submissions VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
| 517 |
+
(run_id, task, agent, float(primary), _json.dumps(secondary),
|
| 518 |
+
sha, n_rows, "admin", now),
|
| 519 |
+
)
|
| 520 |
+
conn.commit()
|
| 521 |
+
return jsonify({"run_id": run_id, "task": task, "agent": agent,
|
| 522 |
+
"primary": primary, "secondary": secondary})
|
| 523 |
+
|
| 524 |
+
|
| 525 |
@app.post("/admin/repoll/<run_id>")
|
| 526 |
def admin_repoll(run_id: str):
|
| 527 |
"""Re-trigger the Kaggle poll loop for a stuck/failed pending row, without
|