Update src/populate.py
Browse files- src/populate.py +7 -17
src/populate.py
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
import pandas as pd
|
| 3 |
import json
|
| 4 |
|
| 5 |
-
from src.display.utils import COLUMNS, EVAL_COLS
|
| 6 |
-
from src.envs import EVAL_RESULTS_PATH
|
| 7 |
|
| 8 |
def get_leaderboard_df(eval_results_path, eval_requests_path, cols, benchmark_cols):
|
| 9 |
# Initialize an empty DataFrame
|
|
@@ -11,15 +12,12 @@ def get_leaderboard_df(eval_results_path, eval_requests_path, cols, benchmark_co
|
|
| 11 |
|
| 12 |
# Load evaluation results from JSON files
|
| 13 |
if os.path.exists(eval_results_path):
|
| 14 |
-
result_files = [
|
| 15 |
-
os.path.join(eval_results_path, f)
|
| 16 |
-
for f in os.listdir(eval_results_path)
|
| 17 |
-
if f.endswith('.json')
|
| 18 |
-
]
|
| 19 |
data_list = []
|
| 20 |
for file in result_files:
|
| 21 |
with open(file, 'r') as f:
|
| 22 |
data = json.load(f)
|
|
|
|
| 23 |
flattened_data = {}
|
| 24 |
flattened_data.update(data.get('config', {}))
|
| 25 |
flattened_data.update(data.get('results', {}))
|
|
@@ -32,10 +30,6 @@ def get_leaderboard_df(eval_results_path, eval_requests_path, cols, benchmark_co
|
|
| 32 |
if col not in df.columns:
|
| 33 |
df[col] = None
|
| 34 |
|
| 35 |
-
# Convert 'average' column to float and handle errors
|
| 36 |
-
if 'average' in df.columns:
|
| 37 |
-
df['average'] = pd.to_numeric(df['average'], errors='coerce')
|
| 38 |
-
|
| 39 |
# Sort by 'average' column if it exists
|
| 40 |
if 'average' in df.columns:
|
| 41 |
df = df.sort_values(by=['average'], ascending=False)
|
|
@@ -50,11 +44,7 @@ def get_evaluation_queue_df(eval_requests_path, eval_cols):
|
|
| 50 |
|
| 51 |
# Load evaluation requests from JSON files
|
| 52 |
if os.path.exists(eval_requests_path):
|
| 53 |
-
request_files = [
|
| 54 |
-
os.path.join(eval_requests_path, f)
|
| 55 |
-
for f in os.listdir(eval_requests_path)
|
| 56 |
-
if f.endswith('.json')
|
| 57 |
-
]
|
| 58 |
data_list = []
|
| 59 |
for file in request_files:
|
| 60 |
with open(file, 'r') as f:
|
|
@@ -67,4 +57,4 @@ def get_evaluation_queue_df(eval_requests_path, eval_cols):
|
|
| 67 |
running_df = df[df['status'] == 'running']
|
| 68 |
pending_df = df[df['status'] == 'pending']
|
| 69 |
|
| 70 |
-
return finished_df, running_df, pending_df
|
|
|
|
| 1 |
+
# src/populate.py
|
| 2 |
+
|
| 3 |
import os
|
| 4 |
import pandas as pd
|
| 5 |
import json
|
| 6 |
|
| 7 |
+
from src.display.utils import COLUMNS, EVAL_COLS
|
|
|
|
| 8 |
|
| 9 |
def get_leaderboard_df(eval_results_path, eval_requests_path, cols, benchmark_cols):
|
| 10 |
# Initialize an empty DataFrame
|
|
|
|
| 12 |
|
| 13 |
# Load evaluation results from JSON files
|
| 14 |
if os.path.exists(eval_results_path):
|
| 15 |
+
result_files = [os.path.join(eval_results_path, f) for f in os.listdir(eval_results_path) if f.endswith('.json')]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
data_list = []
|
| 17 |
for file in result_files:
|
| 18 |
with open(file, 'r') as f:
|
| 19 |
data = json.load(f)
|
| 20 |
+
# Flatten the JSON structure if needed
|
| 21 |
flattened_data = {}
|
| 22 |
flattened_data.update(data.get('config', {}))
|
| 23 |
flattened_data.update(data.get('results', {}))
|
|
|
|
| 30 |
if col not in df.columns:
|
| 31 |
df[col] = None
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
# Sort by 'average' column if it exists
|
| 34 |
if 'average' in df.columns:
|
| 35 |
df = df.sort_values(by=['average'], ascending=False)
|
|
|
|
| 44 |
|
| 45 |
# Load evaluation requests from JSON files
|
| 46 |
if os.path.exists(eval_requests_path):
|
| 47 |
+
request_files = [os.path.join(eval_requests_path, f) for f in os.listdir(eval_requests_path) if f.endswith('.json')]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
data_list = []
|
| 49 |
for file in request_files:
|
| 50 |
with open(file, 'r') as f:
|
|
|
|
| 57 |
running_df = df[df['status'] == 'running']
|
| 58 |
pending_df = df[df['status'] == 'pending']
|
| 59 |
|
| 60 |
+
return finished_df, running_df, pending_df
|