update populate
Browse files- src/populate.py +16 -4
src/populate.py
CHANGED
|
@@ -6,7 +6,7 @@ import json
|
|
| 6 |
import random
|
| 7 |
|
| 8 |
from src.display.utils import COLUMNS, EVAL_COLS, Tasks
|
| 9 |
-
from src.envs import EVAL_RESULTS_PATH, FIXED_QUESTIONS_FILE #
|
| 10 |
|
| 11 |
def get_leaderboard_df(eval_results_path, eval_requests_path, cols, benchmark_cols):
|
| 12 |
# Initialize an empty DataFrame
|
|
@@ -14,12 +14,16 @@ def get_leaderboard_df(eval_results_path, eval_requests_path, cols, benchmark_co
|
|
| 14 |
|
| 15 |
# Load evaluation results from JSON files
|
| 16 |
if os.path.exists(eval_results_path):
|
| 17 |
-
result_files = [
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
data_list = []
|
| 19 |
for file in result_files:
|
| 20 |
with open(file, 'r') as f:
|
| 21 |
data = json.load(f)
|
| 22 |
-
# Flatten the JSON structure
|
| 23 |
flattened_data = {}
|
| 24 |
flattened_data.update(data.get('config', {}))
|
| 25 |
flattened_data.update(data.get('results', {}))
|
|
@@ -27,6 +31,10 @@ def get_leaderboard_df(eval_results_path, eval_requests_path, cols, benchmark_co
|
|
| 27 |
if data_list:
|
| 28 |
df = pd.DataFrame(data_list)
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
# Ensure DataFrame has all columns
|
| 31 |
for col in cols:
|
| 32 |
if col not in df.columns:
|
|
@@ -46,7 +54,11 @@ def get_evaluation_queue_df(eval_requests_path, eval_cols):
|
|
| 46 |
|
| 47 |
# Load evaluation requests from JSON files
|
| 48 |
if os.path.exists(eval_requests_path):
|
| 49 |
-
request_files = [
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
data_list = []
|
| 51 |
for file in request_files:
|
| 52 |
with open(file, 'r') as f:
|
|
|
|
| 6 |
import random
|
| 7 |
|
| 8 |
from src.display.utils import COLUMNS, EVAL_COLS, Tasks
|
| 9 |
+
from src.envs import EVAL_RESULTS_PATH, FIXED_QUESTIONS_FILE # Ensure FIXED_QUESTIONS_FILE is defined in envs.py
|
| 10 |
|
| 11 |
def get_leaderboard_df(eval_results_path, eval_requests_path, cols, benchmark_cols):
|
| 12 |
# Initialize an empty DataFrame
|
|
|
|
| 14 |
|
| 15 |
# Load evaluation results from JSON files
|
| 16 |
if os.path.exists(eval_results_path):
|
| 17 |
+
result_files = [
|
| 18 |
+
os.path.join(eval_results_path, f)
|
| 19 |
+
for f in os.listdir(eval_results_path)
|
| 20 |
+
if f.endswith('.json')
|
| 21 |
+
]
|
| 22 |
data_list = []
|
| 23 |
for file in result_files:
|
| 24 |
with open(file, 'r') as f:
|
| 25 |
data = json.load(f)
|
| 26 |
+
# Flatten the JSON structure
|
| 27 |
flattened_data = {}
|
| 28 |
flattened_data.update(data.get('config', {}))
|
| 29 |
flattened_data.update(data.get('results', {}))
|
|
|
|
| 31 |
if data_list:
|
| 32 |
df = pd.DataFrame(data_list)
|
| 33 |
|
| 34 |
+
# Rename 'model_name' to 'model' if 'model' is missing
|
| 35 |
+
if 'model' not in df.columns and 'model_name' in df.columns:
|
| 36 |
+
df.rename(columns={'model_name': 'model'}, inplace=True)
|
| 37 |
+
|
| 38 |
# Ensure DataFrame has all columns
|
| 39 |
for col in cols:
|
| 40 |
if col not in df.columns:
|
|
|
|
| 54 |
|
| 55 |
# Load evaluation requests from JSON files
|
| 56 |
if os.path.exists(eval_requests_path):
|
| 57 |
+
request_files = [
|
| 58 |
+
os.path.join(eval_requests_path, f)
|
| 59 |
+
for f in os.listdir(eval_requests_path)
|
| 60 |
+
if f.endswith('.json')
|
| 61 |
+
]
|
| 62 |
data_list = []
|
| 63 |
for file in request_files:
|
| 64 |
with open(file, 'r') as f:
|