Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -102,10 +102,53 @@ async def startup_event():
|
|
| 102 |
# ββ helpers ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 103 |
|
| 104 |
def load_eval_results() -> dict:
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
return {}
|
| 110 |
|
| 111 |
|
|
|
|
| 102 |
# ββ helpers ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 103 |
|
| 104 |
def load_eval_results() -> dict:
|
| 105 |
+
results_dir = resolve_path("results")
|
| 106 |
+
candidate_files = [
|
| 107 |
+
os.path.join(results_dir, "eval_all.json"),
|
| 108 |
+
os.path.join(results_dir, "eval_report.json"),
|
| 109 |
+
]
|
| 110 |
+
|
| 111 |
+
for path in candidate_files:
|
| 112 |
+
if os.path.exists(path):
|
| 113 |
+
with open(path, "r", encoding="utf-8") as f:
|
| 114 |
+
data = json.load(f)
|
| 115 |
+
|
| 116 |
+
if path.endswith("eval_all.json"):
|
| 117 |
+
return data
|
| 118 |
+
|
| 119 |
+
# Single-dataset reports use mode->metrics shape. Wrap them so the
|
| 120 |
+
# dashboard can render them like the combined eval output.
|
| 121 |
+
if isinstance(data, dict) and any(
|
| 122 |
+
key in data for key in ("full", "dense", "sparse", "hybrid")
|
| 123 |
+
):
|
| 124 |
+
return {"report": data}
|
| 125 |
+
|
| 126 |
+
if os.path.isdir(results_dir):
|
| 127 |
+
merged = {}
|
| 128 |
+
for filename in sorted(os.listdir(results_dir)):
|
| 129 |
+
if not (filename.startswith("eval_") and filename.endswith(".json")):
|
| 130 |
+
continue
|
| 131 |
+
if filename in {"eval_all.json", "eval_report.json"}:
|
| 132 |
+
continue
|
| 133 |
+
|
| 134 |
+
dataset_name = filename[len("eval_"):-len(".json")]
|
| 135 |
+
path = os.path.join(results_dir, filename)
|
| 136 |
+
|
| 137 |
+
try:
|
| 138 |
+
with open(path, "r", encoding="utf-8") as f:
|
| 139 |
+
data = json.load(f)
|
| 140 |
+
except Exception as e:
|
| 141 |
+
print(f"[Dashboard] Could not load {path}: {e}")
|
| 142 |
+
continue
|
| 143 |
+
|
| 144 |
+
if isinstance(data, dict):
|
| 145 |
+
merged[dataset_name] = data
|
| 146 |
+
|
| 147 |
+
if merged:
|
| 148 |
+
print(f"[Dashboard] Loaded evaluation data from {len(merged)} per-dataset report(s)")
|
| 149 |
+
return merged
|
| 150 |
+
|
| 151 |
+
print(f"[Dashboard] No evaluation results found in {results_dir}")
|
| 152 |
return {}
|
| 153 |
|
| 154 |
|