Spaces:
Runtime error
Runtime error
Update src/populate.py
Browse files- src/populate.py +14 -13
src/populate.py
CHANGED
@@ -1,45 +1,43 @@
|
|
|
|
|
|
1 |
import json
|
2 |
import os
|
3 |
-
|
4 |
import pandas as pd
|
5 |
-
|
6 |
from src.display.formatting import has_no_nan_values, make_clickable_model
|
7 |
from src.display.utils import AutoEvalColumn, EvalQueueColumn
|
8 |
from src.leaderboard.read_evals import get_raw_eval_results
|
9 |
|
10 |
-
|
11 |
def get_leaderboard_df(results_path: str, requests_path: str, cols: list, benchmark_cols: list) -> pd.DataFrame:
|
12 |
-
print("
|
13 |
raw_data = get_raw_eval_results(results_path, requests_path)
|
14 |
-
print("
|
15 |
|
16 |
all_data_json = [v.to_dict() for v in raw_data]
|
|
|
17 |
|
18 |
df = pd.DataFrame.from_records(all_data_json)
|
|
|
|
|
19 |
df = df.sort_values(by=[AutoEvalColumn.average.name], ascending=False)
|
20 |
df = df[cols].round(decimals=2)
|
|
|
21 |
|
22 |
-
print("after df things") # blz
|
23 |
-
|
24 |
-
|
25 |
# filter out if any of the benchmarks have not been produced
|
26 |
df = df[has_no_nan_values(df, benchmark_cols)]
|
|
|
27 |
return raw_data, df
|
28 |
|
29 |
-
|
30 |
def get_evaluation_queue_df(save_path: str, cols: list) -> list[pd.DataFrame]:
|
|
|
31 |
entries = [entry for entry in os.listdir(save_path) if not entry.startswith(".")]
|
32 |
all_evals = []
|
33 |
|
34 |
-
print("inside get_evaluation_queue_df") # blz
|
35 |
-
|
36 |
for entry in entries:
|
37 |
if ".json" in entry:
|
38 |
-
print(f"a json file {entry}") # blz
|
39 |
-
|
40 |
file_path = os.path.join(save_path, entry)
|
41 |
with open(file_path) as fp:
|
42 |
data = json.load(fp)
|
|
|
43 |
|
44 |
data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
|
45 |
data[EvalQueueColumn.revision.name] = data.get("revision", "main")
|
@@ -52,6 +50,7 @@ def get_evaluation_queue_df(save_path: str, cols: list) -> list[pd.DataFrame]:
|
|
52 |
file_path = os.path.join(save_path, entry, sub_entry)
|
53 |
with open(file_path) as fp:
|
54 |
data = json.load(fp)
|
|
|
55 |
|
56 |
data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
|
57 |
data[EvalQueueColumn.revision.name] = data.get("revision", "main")
|
@@ -63,4 +62,6 @@ def get_evaluation_queue_df(save_path: str, cols: list) -> list[pd.DataFrame]:
|
|
63 |
df_pending = pd.DataFrame.from_records(pending_list, columns=cols)
|
64 |
df_running = pd.DataFrame.from_records(running_list, columns=cols)
|
65 |
df_finished = pd.DataFrame.from_records(finished_list, columns=cols)
|
|
|
|
|
66 |
return df_finished[cols], df_running[cols], df_pending[cols]
|
|
|
1 |
+
# populate.py
|
2 |
+
|
3 |
import json
|
4 |
import os
|
|
|
5 |
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 |
from src.leaderboard.read_evals import get_raw_eval_results
|
9 |
|
|
|
10 |
def get_leaderboard_df(results_path: str, requests_path: str, cols: list, benchmark_cols: list) -> pd.DataFrame:
|
11 |
+
print("get_leaderboard_df: Starting to process leaderboard data.")
|
12 |
raw_data = get_raw_eval_results(results_path, requests_path)
|
13 |
+
print("get_leaderboard_df: Raw eval results obtained.")
|
14 |
|
15 |
all_data_json = [v.to_dict() for v in raw_data]
|
16 |
+
print(f"get_leaderboard_df: Converted raw data to JSON. Number of entries: {len(all_data_json)}")
|
17 |
|
18 |
df = pd.DataFrame.from_records(all_data_json)
|
19 |
+
print("get_leaderboard_df: DataFrame created from records.")
|
20 |
+
|
21 |
df = df.sort_values(by=[AutoEvalColumn.average.name], ascending=False)
|
22 |
df = df[cols].round(decimals=2)
|
23 |
+
print("get_leaderboard_df: DataFrame sorted and columns rounded.")
|
24 |
|
|
|
|
|
|
|
25 |
# filter out if any of the benchmarks have not been produced
|
26 |
df = df[has_no_nan_values(df, benchmark_cols)]
|
27 |
+
print("get_leaderboard_df: DataFrame filtered for NaN values in benchmarks.")
|
28 |
return raw_data, df
|
29 |
|
|
|
30 |
def get_evaluation_queue_df(save_path: str, cols: list) -> list[pd.DataFrame]:
|
31 |
+
print(f"get_evaluation_queue_df: Reading evaluation queue from {save_path}")
|
32 |
entries = [entry for entry in os.listdir(save_path) if not entry.startswith(".")]
|
33 |
all_evals = []
|
34 |
|
|
|
|
|
35 |
for entry in entries:
|
36 |
if ".json" in entry:
|
|
|
|
|
37 |
file_path = os.path.join(save_path, entry)
|
38 |
with open(file_path) as fp:
|
39 |
data = json.load(fp)
|
40 |
+
print(f"get_evaluation_queue_df: Processing file {entry}")
|
41 |
|
42 |
data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
|
43 |
data[EvalQueueColumn.revision.name] = data.get("revision", "main")
|
|
|
50 |
file_path = os.path.join(save_path, entry, sub_entry)
|
51 |
with open(file_path) as fp:
|
52 |
data = json.load(fp)
|
53 |
+
print(f"get_evaluation_queue_df: Processing file {sub_entry} in folder {entry}")
|
54 |
|
55 |
data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
|
56 |
data[EvalQueueColumn.revision.name] = data.get("revision", "main")
|
|
|
62 |
df_pending = pd.DataFrame.from_records(pending_list, columns=cols)
|
63 |
df_running = pd.DataFrame.from_records(running_list, columns=cols)
|
64 |
df_finished = pd.DataFrame.from_records(finished_list, columns=cols)
|
65 |
+
print("get_evaluation_queue_df: Evaluation dataframes created.")
|
66 |
+
|
67 |
return df_finished[cols], df_running[cols], df_pending[cols]
|