Eric Xu commited on
Commit
b6efc9e
·
unverified ·
1 Parent(s): bf0d091

Remove session restore — was only for debugging

Browse files
Files changed (1) hide show
  1. web/app.py +1 -42
web/app.py CHANGED
@@ -62,48 +62,7 @@ def _lazy_stratified_sampler():
62
  _stratified_sampler = _ss
63
  return _stratified_sampler
64
 
65
- from contextlib import asynccontextmanager
66
-
67
-
68
- @asynccontextmanager
69
- async def lifespan(app):
70
- """Restore saved sessions on startup."""
71
- results_dir = PROJECT_ROOT / "results"
72
- if results_dir.exists():
73
- for d in results_dir.iterdir():
74
- if not d.is_dir():
75
- continue
76
- raw = d / "raw_results.json"
77
- cohort_file = d / "cohort.json"
78
- meta_file = d / "meta.json"
79
- if raw.exists() and cohort_file.exists():
80
- try:
81
- with open(raw) as f:
82
- eval_results = json.load(f)
83
- with open(cohort_file) as f:
84
- cohort = json.load(f)
85
- entity_text = ""
86
- if meta_file.exists():
87
- with open(meta_file) as f:
88
- meta = json.load(f)
89
- entity_text = meta.get("entity", "")
90
- sid = d.name.replace("web_", "")
91
- sessions[sid] = {
92
- "id": sid,
93
- "entity_text": entity_text,
94
- "cohort": cohort,
95
- "eval_results": eval_results,
96
- "gradient": None,
97
- "created": "",
98
- }
99
- valid = [r for r in eval_results if isinstance(r, dict) and "score" in r]
100
- print(f" Restored session {sid}: {len(valid)} results, {len(cohort)} cohort")
101
- except Exception as e:
102
- print(f" Failed to restore {d.name}: {e}")
103
- yield
104
-
105
-
106
- app = FastAPI(title="SGO — Semantic Gradient Optimization", lifespan=lifespan)
107
  app.mount("/static", StaticFiles(directory=Path(__file__).parent / "static"), name="static")
108
 
109
  # In-memory store for active sessions
 
62
  _stratified_sampler = _ss
63
  return _stratified_sampler
64
 
65
+ app = FastAPI(title="SGO — Semantic Gradient Optimization")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  app.mount("/static", StaticFiles(directory=Path(__file__).parent / "static"), name="static")
67
 
68
  # In-memory store for active sessions