dashboard preview thumbnail par job
dispatcher scp frame_*.jpg (premiere apres trim head) vers
/var/lib/cosma-qc/thumbnails/job_N.jpg a la fin de do_extract.
Endpoint GET /jobs/{id}/thumbnail serve via FileResponse. Template:
<img class=thumb src=jobs/N/thumbnail> si has_thumbnail. 48x27 px,
object-fit cover.
Backfill manuel des jobs deja done (9, 12, 13, 16, 19) via scp direct.
This commit is contained in:
Binary file not shown.
@@ -379,6 +379,25 @@ def do_extract(job: sqlite3.Row, worker: dict) -> str:
|
||||
print(f" ↳ job #{job['id']}: only {remaining} underwater frames (<{min_frames}) — marking skipped")
|
||||
set_status(job["id"], status="skipped", error=f"too short: {remaining} underwater frames")
|
||||
raise RuntimeError("skipped_short")
|
||||
# Copy the first kept frame back to the dashboard host as a thumbnail so the UI can show
|
||||
# what the job actually sees. Mid-point would be better but first is cheap and on disk now.
|
||||
thumb_dir = DB_PATH.parent / "thumbnails"
|
||||
thumb_dir.mkdir(exist_ok=True)
|
||||
thumb_local = thumb_dir / f"job_{job['id']}.jpg"
|
||||
subprocess.run(
|
||||
["scp", "-o", "BatchMode=yes",
|
||||
f"{worker['ssh_alias']}:{frames_dir}/frame_*.jpg", str(thumb_local)],
|
||||
capture_output=True, timeout=30,
|
||||
) # globbing only picks 1 on the remote side via shell expansion
|
||||
# If glob scp is empty, try first explicit by listing
|
||||
if not thumb_local.exists() or thumb_local.stat().st_size == 0:
|
||||
rc, out, _ = ssh(worker["ssh_alias"], f"ls {shlex.quote(frames_dir)}/frame_*.jpg 2>/dev/null | head -1")
|
||||
first = out.strip()
|
||||
if first:
|
||||
subprocess.run(
|
||||
["scp", "-o", "BatchMode=yes", f"{worker['ssh_alias']}:{first}", str(thumb_local)],
|
||||
capture_output=True, timeout=30,
|
||||
)
|
||||
# Trim once per job so LVM thin pool on the host actually reclaims the freed blocks.
|
||||
ssh(worker["ssh_alias"], "sudo fstrim / 2>/dev/null || fstrim / 2>/dev/null", timeout=60)
|
||||
return frames_dir
|
||||
|
||||
Reference in New Issue
Block a user