Spaces:
Running
Running
jasonshaoshun
commited on
Commit
·
8a4a40c
1
Parent(s):
5e00d4f
debug
Browse files
app.py
CHANGED
|
@@ -131,28 +131,40 @@ from dataclasses import fields
|
|
| 131 |
|
| 132 |
|
| 133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
class SmartSelectColumns(SelectColumns):
|
| 135 |
"""
|
| 136 |
-
Enhanced SelectColumns component
|
| 137 |
"""
|
| 138 |
def __init__(
|
| 139 |
self,
|
| 140 |
benchmark_keywords: Optional[List[str]] = None,
|
| 141 |
model_keywords: Optional[List[str]] = None,
|
| 142 |
initial_selected: Optional[List[str]] = None,
|
| 143 |
-
label: str =
|
| 144 |
-
|
|
|
|
|
|
|
| 145 |
):
|
| 146 |
-
#
|
| 147 |
-
default_selection = initial_selected or []
|
| 148 |
super().__init__(
|
| 149 |
-
default_selection=
|
|
|
|
|
|
|
| 150 |
label=label,
|
| 151 |
-
|
|
|
|
| 152 |
)
|
| 153 |
|
| 154 |
self.benchmark_keywords = benchmark_keywords or []
|
| 155 |
self.model_keywords = model_keywords or []
|
|
|
|
|
|
|
|
|
|
| 156 |
|
| 157 |
def get_filtered_groups(self, columns: List[str]) -> Dict[str, List[str]]:
|
| 158 |
"""Get column groups based on keywords."""
|
|
@@ -176,6 +188,7 @@ class SmartSelectColumns(SelectColumns):
|
|
| 176 |
if matching_cols:
|
| 177 |
filtered_groups[f"Model group for {model}"] = matching_cols
|
| 178 |
|
|
|
|
| 179 |
return filtered_groups
|
| 180 |
|
| 181 |
|
|
@@ -187,6 +200,7 @@ class SmartSelectColumns(SelectColumns):
|
|
| 187 |
|
| 188 |
|
| 189 |
|
|
|
|
| 190 |
def restart_space():
|
| 191 |
API.restart_space(repo_id=REPO_ID)
|
| 192 |
|
|
@@ -457,30 +471,36 @@ def init_leaderboard_mib_subgraph(dataframe, track):
|
|
| 457 |
benchmark_keywords = ["ioi", "mcqa", "arithmetic", "arc"]
|
| 458 |
model_keywords = ["qwen2_5", "gpt2", "gemma2", "llama3"]
|
| 459 |
|
| 460 |
-
# Create SmartSelectColumns instance
|
| 461 |
smart_columns = SmartSelectColumns(
|
| 462 |
benchmark_keywords=benchmark_keywords,
|
| 463 |
model_keywords=model_keywords,
|
| 464 |
initial_selected=["Method", "Average"],
|
| 465 |
-
|
| 466 |
-
|
|
|
|
|
|
|
| 467 |
)
|
| 468 |
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 484 |
|
| 485 |
|
| 486 |
|
|
|
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
+
from gradio_leaderboard import SelectColumns, Leaderboard
|
| 135 |
+
import pandas as pd
|
| 136 |
+
from typing import List, Dict, Optional
|
| 137 |
+
from dataclasses import fields
|
| 138 |
+
|
| 139 |
class SmartSelectColumns(SelectColumns):
|
| 140 |
"""
|
| 141 |
+
Enhanced SelectColumns component matching exact original parameters.
|
| 142 |
"""
|
| 143 |
def __init__(
|
| 144 |
self,
|
| 145 |
benchmark_keywords: Optional[List[str]] = None,
|
| 146 |
model_keywords: Optional[List[str]] = None,
|
| 147 |
initial_selected: Optional[List[str]] = None,
|
| 148 |
+
label: Optional[str] = None,
|
| 149 |
+
show_label: bool = True,
|
| 150 |
+
info: Optional[str] = None,
|
| 151 |
+
allow: bool = True
|
| 152 |
):
|
| 153 |
+
# Match exact parameters from working SelectColumns
|
|
|
|
| 154 |
super().__init__(
|
| 155 |
+
default_selection=initial_selected or [],
|
| 156 |
+
cant_deselect=[],
|
| 157 |
+
allow=allow,
|
| 158 |
label=label,
|
| 159 |
+
show_label=show_label,
|
| 160 |
+
info=info
|
| 161 |
)
|
| 162 |
|
| 163 |
self.benchmark_keywords = benchmark_keywords or []
|
| 164 |
self.model_keywords = model_keywords or []
|
| 165 |
+
|
| 166 |
+
# Store groups for later use
|
| 167 |
+
self._groups = {}
|
| 168 |
|
| 169 |
def get_filtered_groups(self, columns: List[str]) -> Dict[str, List[str]]:
|
| 170 |
"""Get column groups based on keywords."""
|
|
|
|
| 188 |
if matching_cols:
|
| 189 |
filtered_groups[f"Model group for {model}"] = matching_cols
|
| 190 |
|
| 191 |
+
self._groups = filtered_groups
|
| 192 |
return filtered_groups
|
| 193 |
|
| 194 |
|
|
|
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
+
|
| 204 |
def restart_space():
|
| 205 |
API.restart_space(repo_id=REPO_ID)
|
| 206 |
|
|
|
|
| 471 |
benchmark_keywords = ["ioi", "mcqa", "arithmetic", "arc"]
|
| 472 |
model_keywords = ["qwen2_5", "gpt2", "gemma2", "llama3"]
|
| 473 |
|
| 474 |
+
# Create SmartSelectColumns instance with exact same parameters as working version
|
| 475 |
smart_columns = SmartSelectColumns(
|
| 476 |
benchmark_keywords=benchmark_keywords,
|
| 477 |
model_keywords=model_keywords,
|
| 478 |
initial_selected=["Method", "Average"],
|
| 479 |
+
allow=True,
|
| 480 |
+
label=None,
|
| 481 |
+
show_label=True,
|
| 482 |
+
info=None
|
| 483 |
)
|
| 484 |
|
| 485 |
+
try:
|
| 486 |
+
print("\nCreating leaderboard...")
|
| 487 |
+
# Get groups before creating leaderboard
|
| 488 |
+
smart_columns.get_filtered_groups(dataframe.columns)
|
| 489 |
+
|
| 490 |
+
leaderboard = Leaderboard(
|
| 491 |
+
value=dataframe,
|
| 492 |
+
datatype=[c.type for c in fields(AutoEvalColumn_mib_subgraph)],
|
| 493 |
+
select_columns=smart_columns,
|
| 494 |
+
search_columns=["Method"],
|
| 495 |
+
hide_columns=[],
|
| 496 |
+
interactive=False
|
| 497 |
+
)
|
| 498 |
+
print("Leaderboard created successfully")
|
| 499 |
+
return leaderboard
|
| 500 |
+
|
| 501 |
+
except Exception as e:
|
| 502 |
+
print("Error creating leaderboard:", str(e))
|
| 503 |
+
raise
|
| 504 |
|
| 505 |
|
| 506 |
|