Resolve TypeError when processing evaluation queue data
Browse files- app.py +1 -1
- src/populate.py +16 -2
app.py
CHANGED
@@ -144,7 +144,7 @@ def update_leaderboard():
|
|
144 |
"""Update the leaderboard with latest evaluation results."""
|
145 |
global LEADERBOARD_DF
|
146 |
LEADERBOARD_DF = get_leaderboard_df(EVAL_RESULTS_PATH, EVAL_REQUESTS_PATH, COLS, BENCHMARK_COLS)
|
147 |
-
|
148 |
|
149 |
def init_leaderboard(df):
|
150 |
"""Initialize the leaderboard with the given DataFrame."""
|
|
|
144 |
"""Update the leaderboard with latest evaluation results."""
|
145 |
global LEADERBOARD_DF
|
146 |
LEADERBOARD_DF = get_leaderboard_df(EVAL_RESULTS_PATH, EVAL_REQUESTS_PATH, COLS, BENCHMARK_COLS)
|
147 |
+
return LEADERBOARD_DF
|
148 |
|
149 |
def init_leaderboard(df):
|
150 |
"""Initialize the leaderboard with the given DataFrame."""
|
src/populate.py
CHANGED
@@ -12,15 +12,29 @@ def get_leaderboard_df(results_path: str, requests_path: str, cols: list, benchm
|
|
12 |
print(f"Getting raw eval results from {results_path} and {requests_path}")
|
13 |
raw_data = get_raw_eval_results(results_path, requests_path)
|
14 |
print(f"Got {len(raw_data)} raw eval results")
|
15 |
-
|
16 |
if not raw_data:
|
17 |
print("No raw data found!")
|
18 |
return pd.DataFrame(columns=cols)
|
19 |
|
20 |
-
all_data_json = [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
print(f"Converted {len(all_data_json)} results to dict")
|
22 |
print(f"Data before DataFrame creation: {all_data_json}")
|
23 |
|
|
|
|
|
|
|
|
|
24 |
df = pd.DataFrame.from_records(all_data_json)
|
25 |
print(f"Created DataFrame with columns: {df.columns.tolist()}")
|
26 |
print(f"DataFrame before filtering:\n{df}")
|
|
|
12 |
print(f"Getting raw eval results from {results_path} and {requests_path}")
|
13 |
raw_data = get_raw_eval_results(results_path, requests_path)
|
14 |
print(f"Got {len(raw_data)} raw eval results")
|
15 |
+
|
16 |
if not raw_data:
|
17 |
print("No raw data found!")
|
18 |
return pd.DataFrame(columns=cols)
|
19 |
|
20 |
+
all_data_json = []
|
21 |
+
for v in raw_data:
|
22 |
+
try:
|
23 |
+
data_dict = v.to_dict() if hasattr(v, 'to_dict') else v
|
24 |
+
if data_dict and isinstance(data_dict, dict):
|
25 |
+
all_data_json.append(data_dict)
|
26 |
+
else:
|
27 |
+
print(f"Warning: Invalid data format for result: {v}")
|
28 |
+
except Exception as e:
|
29 |
+
print(f"Error processing result: {e}")
|
30 |
+
|
31 |
print(f"Converted {len(all_data_json)} results to dict")
|
32 |
print(f"Data before DataFrame creation: {all_data_json}")
|
33 |
|
34 |
+
if not all_data_json:
|
35 |
+
print("No valid data found after conversion!")
|
36 |
+
return pd.DataFrame(columns=cols)
|
37 |
+
|
38 |
df = pd.DataFrame.from_records(all_data_json)
|
39 |
print(f"Created DataFrame with columns: {df.columns.tolist()}")
|
40 |
print(f"DataFrame before filtering:\n{df}")
|