Spaces:
Running
Running
Refactor get_leaderboard_df to handle multiple subsets and improve column selection and hiding
Browse files- app.py +1 -1
- src/populate.py +6 -6
app.py
CHANGED
@@ -64,7 +64,7 @@ except Exception:
|
|
64 |
restart_space()
|
65 |
|
66 |
|
67 |
-
LEADERBOARD_DF = get_leaderboard_df(RESULTS_REPO
|
68 |
|
69 |
|
70 |
def init_leaderboard(dataframes):
|
|
|
64 |
restart_space()
|
65 |
|
66 |
|
67 |
+
LEADERBOARD_DF = get_leaderboard_df(RESULTS_REPO)
|
68 |
|
69 |
|
70 |
def init_leaderboard(dataframes):
|
src/populate.py
CHANGED
@@ -6,17 +6,17 @@ import pandas as pd
|
|
6 |
from src.display.formatting import has_no_nan_values, make_clickable_model
|
7 |
from src.display.utils import AutoEvalColumn, EvalQueueColumn
|
8 |
|
9 |
-
from datasets import load_dataset
|
10 |
|
11 |
|
12 |
-
def get_leaderboard_df(results_repo
|
13 |
-
subsets =
|
14 |
subset_dfs = {}
|
15 |
-
|
16 |
-
|
17 |
subset_df = subset_data.to_pandas()
|
18 |
subset_df = subset_df.sort_values(by="Total", ascending=False)
|
19 |
subset_df = subset_df.round(2) # Round all numeric columns to two decimal places
|
20 |
print(subset_df)
|
21 |
-
subset_dfs[
|
22 |
return subset_dfs
|
|
|
6 |
from src.display.formatting import has_no_nan_values, make_clickable_model
|
7 |
from src.display.utils import AutoEvalColumn, EvalQueueColumn
|
8 |
|
9 |
+
from datasets import load_dataset, get_dataset_config_names
|
10 |
|
11 |
|
12 |
+
def get_leaderboard_df(results_repo):
|
13 |
+
subsets = get_dataset_config_names(results_repo)
|
14 |
subset_dfs = {}
|
15 |
+
for subset in subsets:
|
16 |
+
subset_data = load_dataset(results_repo, subset)
|
17 |
subset_df = subset_data.to_pandas()
|
18 |
subset_df = subset_df.sort_values(by="Total", ascending=False)
|
19 |
subset_df = subset_df.round(2) # Round all numeric columns to two decimal places
|
20 |
print(subset_df)
|
21 |
+
subset_dfs[subset] = subset_df
|
22 |
return subset_dfs
|