Michael Rabinovich commited on
Commit
37e45d8
·
1 Parent(s): c87b253

debug: add /debug/render-bench route for one-shot Chromium timing

Browse files

Read-only FastAPI endpoint mounted on the Space's parent app.
Sequentially times `render_step` against each fixture's input.step
in cadgenbench-data and returns per-fixture seconds + view count.
Used to compare per-render cost on the Space's container vs a
local reference when eval has been timing out at the 120s
render_step ceiling but nothing on the render path changed in our
code. Curl-fetchable under Bearer auth (the Space is private):

curl -H "Authorization: Bearer $HF_TOKEN" \
https://<space>.hf.space/debug/render-bench

Not user-visible (no UI), no side effects, no row writes. Safe to
remove once the diagnosis lands.

Files changed (1) hide show
  1. app.py +47 -0
app.py CHANGED
@@ -421,6 +421,53 @@ app.add_api_route(
421
  serve_report,
422
  methods=["GET"],
423
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
424
  app = gr.mount_gradio_app(app, blocks, path="/")
425
 
426
 
 
421
  serve_report,
422
  methods=["GET"],
423
  )
424
+
425
+
426
+ def debug_render_bench() -> dict:
427
+ """One-shot render-timing probe.
428
+
429
+ Sequentially times ``render_step`` on each cadgenbench-data input
430
+ STEP. Reads-only; no side effects. Used to compare per-render
431
+ cost on the Space's container vs. a local reference, when an
432
+ eval has started timing out at the 120s render_step ceiling but
433
+ nothing on the render path changed in our code.
434
+
435
+ Run via:
436
+ curl -H "Authorization: Bearer $HF_TOKEN" \
437
+ https://<space>.hf.space/debug/render-bench
438
+ """
439
+ import time
440
+ from cadgenbench.common.paths import data_inputs_dir
441
+ from cadgenbench.common.viewer import render_step
442
+
443
+ base = Path(data_inputs_dir())
444
+ results: dict = {}
445
+ for fixture in sorted(p for p in base.iterdir() if p.is_dir()):
446
+ step = fixture / "input.step"
447
+ if not step.exists():
448
+ results[fixture.name] = {"error": "no input.step"}
449
+ continue
450
+ t0 = time.perf_counter()
451
+ try:
452
+ imgs = render_step(str(step), timeout=180)
453
+ dt = time.perf_counter() - t0
454
+ results[fixture.name] = {
455
+ "ok": True, "seconds": round(dt, 2), "views": len(imgs),
456
+ }
457
+ except Exception as e: # noqa: BLE001 - report whatever fails
458
+ dt = time.perf_counter() - t0
459
+ results[fixture.name] = {
460
+ "ok": False, "seconds": round(dt, 2),
461
+ "error": f"{type(e).__name__}: {str(e)[:300]}",
462
+ }
463
+ return results
464
+
465
+
466
+ app.add_api_route(
467
+ "/debug/render-bench",
468
+ debug_render_bench,
469
+ methods=["GET"],
470
+ )
471
  app = gr.mount_gradio_app(app, blocks, path="/")
472
 
473