Spaces:
Sleeping
Sleeping
Johannes Janosovits commited on
Commit Β·
18160d5
1
Parent(s): cef2bfc
foo
Browse files
app.py
CHANGED
|
@@ -58,9 +58,10 @@ tr.run-row.active td { background: var(--bg3); }
|
|
| 58 |
_cache: dict = {"runs": None, "err": None}
|
| 59 |
|
| 60 |
|
| 61 |
-
def
|
| 62 |
-
|
| 63 |
-
|
|
|
|
| 64 |
for g_name, g_data in groups.items():
|
| 65 |
if not isinstance(g_data, dict):
|
| 66 |
continue
|
|
@@ -69,32 +70,31 @@ def _summarize(groups: dict, tasks: list) -> str:
|
|
| 69 |
continue
|
| 70 |
mname = k.split(",")[0]
|
| 71 |
if not mname.endswith("_stderr"):
|
| 72 |
-
|
|
|
|
| 73 |
break
|
| 74 |
-
if
|
| 75 |
-
return "; ".join(
|
| 76 |
|
| 77 |
if not tasks:
|
| 78 |
-
return "β"
|
| 79 |
|
| 80 |
-
# Few tasks:
|
| 81 |
if len(tasks) <= 5:
|
| 82 |
-
|
| 83 |
for t in tasks:
|
|
|
|
| 84 |
first_m = next(iter(t["metrics"]), None)
|
| 85 |
-
if first_m
|
| 86 |
-
|
| 87 |
-
else:
|
| 88 |
-
task_parts.append(t["name"])
|
| 89 |
-
return "; ".join(task_parts)
|
| 90 |
|
| 91 |
-
# Many tasks without a group
|
| 92 |
first_m = next(iter(tasks[0]["metrics"]), None)
|
| 93 |
if first_m:
|
| 94 |
vals = [t["metrics"][first_m]["value"] for t in tasks if first_m in t["metrics"]]
|
| 95 |
if vals:
|
| 96 |
-
return f"avg {first_m}: {sum(vals)/len(vals):.3f}
|
| 97 |
-
return "β"
|
| 98 |
|
| 99 |
|
| 100 |
def load_runs(force: bool = False) -> tuple[list, str | None]:
|
|
@@ -156,6 +156,7 @@ def load_runs(force: bool = False) -> tuple[list, str | None]:
|
|
| 156 |
"samples_file": samples_f if samples_f in sample_files else None,
|
| 157 |
})
|
| 158 |
|
|
|
|
| 159 |
runs.append({
|
| 160 |
"model": model,
|
| 161 |
"date": date_str,
|
|
@@ -163,7 +164,8 @@ def load_runs(force: bool = False) -> tuple[list, str | None]:
|
|
| 163 |
"ts": ts,
|
| 164 |
"tasks": tasks,
|
| 165 |
"n_tasks": len(tasks),
|
| 166 |
-
"
|
|
|
|
| 167 |
})
|
| 168 |
|
| 169 |
_cache.update(runs=runs, err=None)
|
|
@@ -238,7 +240,8 @@ def server(input, output, session):
|
|
| 238 |
ui.tags.td(ui.span({"class": "model"}, run["model"])),
|
| 239 |
ui.tags.td(run["date"]),
|
| 240 |
ui.tags.td(str(run["n_tasks"])),
|
| 241 |
-
ui.tags.td(run["
|
|
|
|
| 242 |
ui.tags.td(
|
| 243 |
ui.tags.a(
|
| 244 |
{"class": "a", "href": f"{HF_BLOB_URL}/{run['filename']}",
|
|
@@ -255,7 +258,8 @@ def server(input, output, session):
|
|
| 255 |
ui.tags.th("Model"),
|
| 256 |
ui.tags.th("Date"),
|
| 257 |
ui.tags.th("Tasks"),
|
| 258 |
-
ui.tags.th("
|
|
|
|
| 259 |
ui.tags.th("File"),
|
| 260 |
)
|
| 261 |
),
|
|
|
|
| 58 |
_cache: dict = {"runs": None, "err": None}
|
| 59 |
|
| 60 |
|
| 61 |
+
def _names_and_metrics(groups: dict, tasks: list) -> tuple[str, str]:
|
| 62 |
+
"""Returns (name_str, metrics_str) for the two summary columns."""
|
| 63 |
+
# Prefer group-level aggregates
|
| 64 |
+
g_names, g_metrics = [], []
|
| 65 |
for g_name, g_data in groups.items():
|
| 66 |
if not isinstance(g_data, dict):
|
| 67 |
continue
|
|
|
|
| 70 |
continue
|
| 71 |
mname = k.split(",")[0]
|
| 72 |
if not mname.endswith("_stderr"):
|
| 73 |
+
g_names.append(g_name)
|
| 74 |
+
g_metrics.append(f"{v:.3f}")
|
| 75 |
break
|
| 76 |
+
if g_names:
|
| 77 |
+
return "; ".join(g_names), "; ".join(g_metrics)
|
| 78 |
|
| 79 |
if not tasks:
|
| 80 |
+
return "β", "β"
|
| 81 |
|
| 82 |
+
# Few tasks: name column lists task names, metrics column lists values
|
| 83 |
if len(tasks) <= 5:
|
| 84 |
+
names, metrics = [], []
|
| 85 |
for t in tasks:
|
| 86 |
+
names.append(t["name"])
|
| 87 |
first_m = next(iter(t["metrics"]), None)
|
| 88 |
+
metrics.append(f"{t['metrics'][first_m]['value']:.3f}" if first_m else "β")
|
| 89 |
+
return "; ".join(names), "; ".join(metrics)
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
+
# Many tasks without a group
|
| 92 |
first_m = next(iter(tasks[0]["metrics"]), None)
|
| 93 |
if first_m:
|
| 94 |
vals = [t["metrics"][first_m]["value"] for t in tasks if first_m in t["metrics"]]
|
| 95 |
if vals:
|
| 96 |
+
return f"({len(tasks)} tasks)", f"avg {first_m}: {sum(vals)/len(vals):.3f}"
|
| 97 |
+
return f"({len(tasks)} tasks)", "β"
|
| 98 |
|
| 99 |
|
| 100 |
def load_runs(force: bool = False) -> tuple[list, str | None]:
|
|
|
|
| 156 |
"samples_file": samples_f if samples_f in sample_files else None,
|
| 157 |
})
|
| 158 |
|
| 159 |
+
task_names, metrics = _names_and_metrics(data.get("groups", {}), tasks)
|
| 160 |
runs.append({
|
| 161 |
"model": model,
|
| 162 |
"date": date_str,
|
|
|
|
| 164 |
"ts": ts,
|
| 165 |
"tasks": tasks,
|
| 166 |
"n_tasks": len(tasks),
|
| 167 |
+
"task_names": task_names,
|
| 168 |
+
"metrics": metrics,
|
| 169 |
})
|
| 170 |
|
| 171 |
_cache.update(runs=runs, err=None)
|
|
|
|
| 240 |
ui.tags.td(ui.span({"class": "model"}, run["model"])),
|
| 241 |
ui.tags.td(run["date"]),
|
| 242 |
ui.tags.td(str(run["n_tasks"])),
|
| 243 |
+
ui.tags.td(run["task_names"]),
|
| 244 |
+
ui.tags.td(run["metrics"]),
|
| 245 |
ui.tags.td(
|
| 246 |
ui.tags.a(
|
| 247 |
{"class": "a", "href": f"{HF_BLOB_URL}/{run['filename']}",
|
|
|
|
| 258 |
ui.tags.th("Model"),
|
| 259 |
ui.tags.th("Date"),
|
| 260 |
ui.tags.th("Tasks"),
|
| 261 |
+
ui.tags.th("Name"),
|
| 262 |
+
ui.tags.th("Metrics"),
|
| 263 |
ui.tags.th("File"),
|
| 264 |
)
|
| 265 |
),
|