Spaces:
Running
Running
Refactor init_leaderboard function to handle multiple subsets and improve column selection and hiding
Browse files
app.py
CHANGED
@@ -64,26 +64,39 @@ except Exception:
|
|
64 |
restart_space()
|
65 |
|
66 |
|
67 |
-
LEADERBOARD_DF = get_leaderboard_df(RESULTS_REPO, EVAL_RESULTS_PATH
|
68 |
|
69 |
|
70 |
-
def init_leaderboard(
|
71 |
-
if
|
72 |
-
raise ValueError("Leaderboard
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
)
|
86 |
-
|
|
|
87 |
|
88 |
demo = gr.Blocks(css=custom_css)
|
89 |
with demo:
|
|
|
64 |
restart_space()
|
65 |
|
66 |
|
67 |
+
LEADERBOARD_DF = get_leaderboard_df(RESULTS_REPO, EVAL_RESULTS_PATH)
|
68 |
|
69 |
|
70 |
+
def init_leaderboard(dataframes):
|
71 |
+
if dataframes is None or not dataframes:
|
72 |
+
raise ValueError("Leaderboard data is empty or None.")
|
73 |
+
|
74 |
+
def create_leaderboard(df):
|
75 |
+
return Leaderboard(
|
76 |
+
value=df,
|
77 |
+
datatype=[c.type for c in fields(AutoEvalColumn)],
|
78 |
+
select_columns=SelectColumns(
|
79 |
+
default_selection=[c.name for c in fields(AutoEvalColumn) if c.displayed_by_default],
|
80 |
+
cant_deselect=[c.name for c in fields(AutoEvalColumn) if c.never_hidden],
|
81 |
+
label="Select Columns to Display:",
|
82 |
+
),
|
83 |
+
search_columns=[AutoEvalColumn.model.name],
|
84 |
+
hide_columns=[c.name for c in fields(AutoEvalColumn) if c.hidden],
|
85 |
+
filter_columns=[],
|
86 |
+
interactive=False,
|
87 |
+
)
|
88 |
+
|
89 |
+
subset_names = list(dataframes.keys())
|
90 |
+
selected_subset = gr.Dropdown(choices=subset_names, label="Select Dataset Subset", value=subset_names[0])
|
91 |
+
|
92 |
+
leaderboard = gr.Dynamic(create_leaderboard, inputs=[selected_subset], outputs="output")
|
93 |
+
selected_subset.change(
|
94 |
+
fn=lambda x: create_leaderboard(dataframes[x]),
|
95 |
+
inputs=[selected_subset],
|
96 |
+
outputs=leaderboard
|
97 |
)
|
98 |
+
|
99 |
+
return leaderboard
|
100 |
|
101 |
demo = gr.Blocks(css=custom_css)
|
102 |
with demo:
|