cazyundee commited on
Commit
3fdbf36
·
verified ·
1 Parent(s): a5de9d9

Run loader diagnosis as background job

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -420,6 +420,10 @@ def _run_benchmark_job(job_id, kind, model_filter=None, force=False):
420
  with _BENCH_LOCK:
421
  result = _run_cpu_smoke(model_filter)
422
  payload = {"status": "complete", "result": result}
 
 
 
 
423
  else:
424
  if force:
425
  global _BENCH_RESULTS
@@ -519,12 +523,12 @@ def _patched_create_app(blocks, **kwargs):
519
  except Exception as e: return JSONResponse({"error": str(e)}, status_code=502)
520
 
521
  @fa_app.get("/respite/benchmark/diagnose")
522
- def _diagnose(model: str="TinyLlama 1.1B (control)"):
523
- try:
524
- with _BENCH_LOCK:
525
- return JSONResponse(_run_cpu_diagnose(model.strip()))
526
- except Exception as e:
527
- return JSONResponse({"error": str(e)}, status_code=500)
528
 
529
  @fa_app.get("/respite/benchmark/smoke")
530
  def _smoke(model: str="Gemma 4 E4B", job_id: str=""):
 
420
  with _BENCH_LOCK:
421
  result = _run_cpu_smoke(model_filter)
422
  payload = {"status": "complete", "result": result}
423
+ elif kind == "diagnose":
424
+ with _BENCH_LOCK:
425
+ result = _run_cpu_diagnose(model_filter)
426
+ payload = {"status": "complete", "result": result}
427
  else:
428
  if force:
429
  global _BENCH_RESULTS
 
523
  except Exception as e: return JSONResponse({"error": str(e)}, status_code=502)
524
 
525
  @fa_app.get("/respite/benchmark/diagnose")
526
+ def _diagnose(model: str="TinyLlama 1.1B (control)", job_id: str=""):
527
+ if job_id:
528
+ with _BENCH_JOBS_LOCK:
529
+ return JSONResponse(_BENCH_JOBS.get(job_id, {"status": "not_found"}))
530
+ job = _start_benchmark_job("diagnose", model.strip())
531
+ return JSONResponse({"status": "accepted", "job_id": job, "poll": "/respite/benchmark/diagnose?job_id=" + job}, status_code=202)
532
 
533
  @fa_app.get("/respite/benchmark/smoke")
534
  def _smoke(model: str="Gemma 4 E4B", job_id: str=""):