Spaces:
Running
Running
Refactor init_leaderboard function to update data outputs to dataframe and improve dropdown UI
Browse files
app.py
CHANGED
@@ -93,15 +93,17 @@ def init_leaderboard(dataframes):
|
|
93 |
def refresh(subset):
|
94 |
global LEADERBOARD_DF
|
95 |
LEADERBOARD_DF = get_leaderboard_df(RESULTS_REPO)
|
96 |
-
|
97 |
-
|
98 |
-
return update_data(subset,
|
99 |
|
100 |
def update_data(subset, search_term, selected_columns):
|
101 |
print("Subset:", subset)
|
102 |
print("Search Term:", search_term)
|
103 |
print("Selected Columns:", selected_columns)
|
104 |
-
filtered_data = dataframes[subset]
|
|
|
|
|
105 |
selected_columns = [c.name for c in fields(AutoEvalColumn) if c.name in selected_columns]
|
106 |
selected_data = filtered_data[selected_columns]
|
107 |
selected_data.sort_values(by="Total", ascending=False, inplace=True)
|
@@ -114,7 +116,7 @@ def init_leaderboard(dataframes):
|
|
114 |
inputs=[
|
115 |
selected_subset,
|
116 |
],
|
117 |
-
outputs=df,
|
118 |
concurrency_limit=20,
|
119 |
)
|
120 |
|
|
|
93 |
def refresh(subset):
|
94 |
global LEADERBOARD_DF
|
95 |
LEADERBOARD_DF = get_leaderboard_df(RESULTS_REPO)
|
96 |
+
default_columns = [c.name for c in fields(AutoEvalColumn) if c.displayed_by_default]
|
97 |
+
|
98 |
+
return update_data(subset, None, default_columns), gr.Textbox(placeholder="🔍 Search Models... [press enter]", label="Filter Models by Name"), gr.CheckboxGroup(default_columns)
|
99 |
|
100 |
def update_data(subset, search_term, selected_columns):
|
101 |
print("Subset:", subset)
|
102 |
print("Search Term:", search_term)
|
103 |
print("Selected Columns:", selected_columns)
|
104 |
+
filtered_data = dataframes[subset]
|
105 |
+
if search_term:
|
106 |
+
filtered_data = filtered_data[dataframes[subset]['Model Name'].str.contains(search_term, case=False)]
|
107 |
selected_columns = [c.name for c in fields(AutoEvalColumn) if c.name in selected_columns]
|
108 |
selected_data = filtered_data[selected_columns]
|
109 |
selected_data.sort_values(by="Total", ascending=False, inplace=True)
|
|
|
116 |
inputs=[
|
117 |
selected_subset,
|
118 |
],
|
119 |
+
outputs=[df, research_textbox, selected_columns],
|
120 |
concurrency_limit=20,
|
121 |
)
|
122 |
|