Michael Rabinovich Cursor commited on
Commit
8eb8954
·
1 Parent(s): 01d67e9

gallery: stop negative-caching render fetches

Browse files

Renders land after boot (a submission completes, or an existing row is
backfilled), so lru_cache was pinning boot-time 404s and keeping
thumbnails dashed until the next restart. Drop the memoization on the
render byte-fetchers; hf_hub_download keeps its own per-revision disk
cache, so re-fetching an unchanged thumbnail stays cheap. Also picks up
the 3 baseline rows' just-backfilled renders on this redeploy.

Co-authored-by: Cursor <cursoragent@cursor.com>

Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -523,14 +523,15 @@ def serve_report(submission_id: str) -> Response:
523
  GALLERY_THUMB_VIEW = "iso"
524
 
525
 
526
- @lru_cache(maxsize=512)
527
  def _fetch_render(submission_id: str, fixture: str) -> bytes | None:
528
  """Pull a submission's gallery thumbnail (``renders/<id>/<fixture>.png``).
529
 
530
- Cached in-process so repeated scrolls past the same thumbnail don't
531
- re-hit the Hub. Returns ``None`` on any failure so the caller serves
532
- a clean 404 (the gallery only requests this for fixtures it already
533
- knows are valid, so a miss here is genuinely unexpected/transient).
 
 
534
  """
535
  try:
536
  local_path = hf_hub_download(
@@ -547,7 +548,6 @@ def _fetch_render(submission_id: str, fixture: str) -> bytes | None:
547
  return None
548
 
549
 
550
- @lru_cache(maxsize=256)
551
  def _fetch_gt_render(fixture: str) -> bytes | None:
552
  """Pull a fixture's ground-truth thumbnail from the private GT dataset.
553
 
@@ -555,7 +555,10 @@ def _fetch_gt_render(fixture: str) -> bytes | None:
555
  ``cadgenbench.common.paths.data_gt_dir``). GT renders are a property
556
  of the data revision, not of any submission, so they're served
557
  straight from the GT repo rather than duplicated per submission.
558
- Needs the Space ``HF_TOKEN``'s read scope on the private repo.
 
 
 
559
  """
560
  try:
561
  local_path = hf_hub_download(
 
523
  GALLERY_THUMB_VIEW = "iso"
524
 
525
 
 
526
  def _fetch_render(submission_id: str, fixture: str) -> bytes | None:
527
  """Pull a submission's gallery thumbnail (``renders/<id>/<fixture>.png``).
528
 
529
+ Deliberately **not** memoized: renders land over time (a submission
530
+ completes, or an existing row is backfilled) after the Space process
531
+ booted, so negative-caching a boot-time miss would keep a thumbnail
532
+ dashed until the next restart. ``hf_hub_download`` does its own disk
533
+ caching per revision, so a re-fetch of an unchanged file stays cheap.
534
+ Returns ``None`` on any failure (the gallery draws the dashed cell).
535
  """
536
  try:
537
  local_path = hf_hub_download(
 
548
  return None
549
 
550
 
 
551
  def _fetch_gt_render(fixture: str) -> bytes | None:
552
  """Pull a fixture's ground-truth thumbnail from the private GT dataset.
553
 
 
555
  ``cadgenbench.common.paths.data_gt_dir``). GT renders are a property
556
  of the data revision, not of any submission, so they're served
557
  straight from the GT repo rather than duplicated per submission.
558
+ Not memoized for the same reason as :func:`_fetch_render` (GT
559
+ renders can be added/updated on a data revision bump);
560
+ ``hf_hub_download`` handles the per-revision disk cache. Needs the
561
+ Space ``HF_TOKEN``'s read scope on the private repo.
562
  """
563
  try:
564
  local_path = hf_hub_download(