Michael Rabinovich Cursor commited on
Commit ·
9b64c98
1
Parent(s): 772cc56
eval_job: publish report + gallery in one commit
Browse filesBatch the whole-submission report + per-fixture gallery thumbnails into a
single create_commit instead of one upload_file per file, matching the
sharded merge path. Faster publish and no 429 "concurrency queue"
failures on the dataset commit endpoint.
Co-authored-by: Cursor <cursoragent@cursor.com>
- eval_job.py +50 -66
eval_job.py
CHANGED
|
@@ -60,7 +60,7 @@ import zipfile
|
|
| 60 |
from pathlib import Path
|
| 61 |
from typing import Any
|
| 62 |
|
| 63 |
-
from huggingface_hub import HfApi, hf_hub_download
|
| 64 |
|
| 65 |
|
| 66 |
RUN_DIR = Path("/tmp/run")
|
|
@@ -161,10 +161,9 @@ def main() -> int:
|
|
| 161 |
html_path = REPORT_HTML_DIR / f"{submission_id}.html"
|
| 162 |
_run_report(RUN_DIR, html_path)
|
| 163 |
report_json = _build_report_json(RUN_DIR)
|
| 164 |
-
|
| 165 |
-
submission_id, html_path, report_json, submissions_repo, token,
|
| 166 |
)
|
| 167 |
-
_upload_gallery_renders(submission_id, RUN_DIR, submissions_repo, token)
|
| 168 |
print(f"[eval_job] done: {submission_id}", flush=True)
|
| 169 |
return 0
|
| 170 |
|
|
@@ -367,84 +366,69 @@ def _build_report_json(run_dir: Path) -> dict[str, Any]:
|
|
| 367 |
return {"run_summary": summary, "per_fixture_results": per_fixture}
|
| 368 |
|
| 369 |
|
| 370 |
-
def
|
| 371 |
submission_id: str,
|
| 372 |
html_path: Path,
|
| 373 |
report_json: dict[str, Any],
|
| 374 |
-
submissions_repo: str,
|
| 375 |
-
token: str,
|
| 376 |
-
) -> None:
|
| 377 |
-
"""Upload ``reports/<id>.html`` + ``reports/<id>.json`` to the Hub."""
|
| 378 |
-
api = HfApi(token=token)
|
| 379 |
-
api.upload_file(
|
| 380 |
-
path_or_fileobj=str(html_path),
|
| 381 |
-
path_in_repo=f"{REPORTS_DIR_IN_REPO}/{submission_id}.html",
|
| 382 |
-
repo_id=submissions_repo,
|
| 383 |
-
repo_type="dataset",
|
| 384 |
-
commit_message=f"add HTML report for {submission_id}",
|
| 385 |
-
)
|
| 386 |
-
api.upload_file(
|
| 387 |
-
path_or_fileobj=json.dumps(
|
| 388 |
-
report_json, ensure_ascii=False, indent=2,
|
| 389 |
-
).encode("utf-8"),
|
| 390 |
-
path_in_repo=f"{REPORTS_DIR_IN_REPO}/{submission_id}.json",
|
| 391 |
-
repo_id=submissions_repo,
|
| 392 |
-
repo_type="dataset",
|
| 393 |
-
commit_message=f"add JSON report for {submission_id}",
|
| 394 |
-
)
|
| 395 |
-
print(
|
| 396 |
-
f"[eval_job] uploaded reports/{submission_id}.{{html,json}}",
|
| 397 |
-
flush=True,
|
| 398 |
-
)
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
def _upload_gallery_renders(
|
| 402 |
-
submission_id: str,
|
| 403 |
run_dir: Path,
|
| 404 |
submissions_repo: str,
|
| 405 |
token: str,
|
| 406 |
) -> None:
|
| 407 |
-
"""
|
| 408 |
-
|
| 409 |
-
Stages
|
| 410 |
-
``renders/<id>/<fixture>.png``
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
|
|
|
|
|
|
|
|
|
| 416 |
per-fixture status from the row and draws the dashed "invalid
|
| 417 |
generation" cell, so a thumbnail's absence is not an error.
|
| 418 |
"""
|
| 419 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 420 |
for fixture_dir in sorted(d for d in run_dir.iterdir() if d.is_dir()):
|
| 421 |
iso_png = fixture_dir / "renders" / f"{GALLERY_THUMB_VIEW}.png"
|
| 422 |
if iso_png.is_file():
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
|
|
|
|
|
|
| 431 |
|
| 432 |
api = HfApi(token=token)
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
)
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
f"add gallery render {fixture_name} for {submission_id}"
|
| 443 |
-
),
|
| 444 |
-
)
|
| 445 |
print(
|
| 446 |
-
f"[eval_job]
|
| 447 |
-
f"{
|
| 448 |
flush=True,
|
| 449 |
)
|
| 450 |
|
|
|
|
| 60 |
from pathlib import Path
|
| 61 |
from typing import Any
|
| 62 |
|
| 63 |
+
from huggingface_hub import CommitOperationAdd, HfApi, hf_hub_download
|
| 64 |
|
| 65 |
|
| 66 |
RUN_DIR = Path("/tmp/run")
|
|
|
|
| 161 |
html_path = REPORT_HTML_DIR / f"{submission_id}.html"
|
| 162 |
_run_report(RUN_DIR, html_path)
|
| 163 |
report_json = _build_report_json(RUN_DIR)
|
| 164 |
+
_publish_reports_and_gallery(
|
| 165 |
+
submission_id, html_path, report_json, RUN_DIR, submissions_repo, token,
|
| 166 |
)
|
|
|
|
| 167 |
print(f"[eval_job] done: {submission_id}", flush=True)
|
| 168 |
return 0
|
| 169 |
|
|
|
|
| 366 |
return {"run_summary": summary, "per_fixture_results": per_fixture}
|
| 367 |
|
| 368 |
|
| 369 |
+
def _publish_reports_and_gallery(
|
| 370 |
submission_id: str,
|
| 371 |
html_path: Path,
|
| 372 |
report_json: dict[str, Any],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 373 |
run_dir: Path,
|
| 374 |
submissions_repo: str,
|
| 375 |
token: str,
|
| 376 |
) -> None:
|
| 377 |
+
"""Publish report HTML/JSON + every gallery thumbnail in one commit.
|
| 378 |
+
|
| 379 |
+
Stages ``reports/<id>.{html,json}`` plus one
|
| 380 |
+
``renders/<id>/<fixture>.png`` per fixture that produced an ``iso``
|
| 381 |
+
thumbnail, then pushes them all in a single ``create_commit``. A
|
| 382 |
+
commit-per-file both serialises the publish and hammers the
|
| 383 |
+
dataset's commit endpoint (the 429 "concurrency queue" failures that
|
| 384 |
+
stranded earlier runs); one commit is atomic, fast, and rate-limit
|
| 385 |
+
friendly. The standalone PNGs back the gallery's ``renderFor()``; the
|
| 386 |
+
full multi-view renders stay base64-embedded in ``reports/<id>.html``
|
| 387 |
+
for the self-contained report. A fixture with no ``iso.png`` (missing
|
| 388 |
+
output, or a render that never ran) is skipped; the gallery reads the
|
| 389 |
per-fixture status from the row and draws the dashed "invalid
|
| 390 |
generation" cell, so a thumbnail's absence is not an error.
|
| 391 |
"""
|
| 392 |
+
operations: list[CommitOperationAdd] = [
|
| 393 |
+
CommitOperationAdd(
|
| 394 |
+
path_in_repo=f"{REPORTS_DIR_IN_REPO}/{submission_id}.html",
|
| 395 |
+
path_or_fileobj=str(html_path),
|
| 396 |
+
),
|
| 397 |
+
CommitOperationAdd(
|
| 398 |
+
path_in_repo=f"{REPORTS_DIR_IN_REPO}/{submission_id}.json",
|
| 399 |
+
path_or_fileobj=json.dumps(
|
| 400 |
+
report_json, ensure_ascii=False, indent=2,
|
| 401 |
+
).encode("utf-8"),
|
| 402 |
+
),
|
| 403 |
+
]
|
| 404 |
+
render_count = 0
|
| 405 |
for fixture_dir in sorted(d for d in run_dir.iterdir() if d.is_dir()):
|
| 406 |
iso_png = fixture_dir / "renders" / f"{GALLERY_THUMB_VIEW}.png"
|
| 407 |
if iso_png.is_file():
|
| 408 |
+
operations.append(
|
| 409 |
+
CommitOperationAdd(
|
| 410 |
+
path_in_repo=(
|
| 411 |
+
f"{RENDERS_DIR_IN_REPO}/{submission_id}/"
|
| 412 |
+
f"{fixture_dir.name}.png"
|
| 413 |
+
),
|
| 414 |
+
path_or_fileobj=str(iso_png),
|
| 415 |
+
)
|
| 416 |
+
)
|
| 417 |
+
render_count += 1
|
| 418 |
|
| 419 |
api = HfApi(token=token)
|
| 420 |
+
api.create_commit(
|
| 421 |
+
repo_id=submissions_repo,
|
| 422 |
+
repo_type="dataset",
|
| 423 |
+
operations=operations,
|
| 424 |
+
commit_message=(
|
| 425 |
+
f"publish report + {render_count} gallery render(s) "
|
| 426 |
+
f"for {submission_id}"
|
| 427 |
+
),
|
| 428 |
+
)
|
|
|
|
|
|
|
|
|
|
| 429 |
print(
|
| 430 |
+
f"[eval_job] published reports/{submission_id}.{{html,json}} + "
|
| 431 |
+
f"{render_count} gallery render(s) in one commit",
|
| 432 |
flush=True,
|
| 433 |
)
|
| 434 |
|