SAGE OSS Evaluator commited on
Commit
b1a0fd2
·
1 Parent(s): 7844386
src/leaderboard/read_evals.py DELETED
@@ -1,196 +0,0 @@
1
- import glob
2
- import json
3
- import math
4
- import os
5
- from dataclasses import dataclass
6
-
7
- import dateutil
8
- import numpy as np
9
-
10
- from src.display.formatting import make_clickable_model
11
- from src.display.utils import AutoEvalColumn, ModelType, Tasks, Precision, WeightType
12
- from src.submission.check_validity import is_model_on_hub
13
-
14
-
15
- @dataclass
16
- class EvalResult:
17
- """Represents one full evaluation. Built from a combination of the result and request file for a given run.
18
- """
19
- eval_name: str # org_model_precision (uid)
20
- full_model: str # org/model (path on hub)
21
- org: str
22
- model: str
23
- revision: str # commit hash, "" if main
24
- results: dict
25
- precision: Precision = Precision.Unknown
26
- model_type: ModelType = ModelType.Unknown # Pretrained, fine tuned, ...
27
- weight_type: WeightType = WeightType.Original # Original or Adapter
28
- architecture: str = "Unknown"
29
- license: str = "?"
30
- likes: int = 0
31
- num_params: int = 0
32
- date: str = "" # submission date of request file
33
- still_on_hub: bool = False
34
-
35
- @classmethod
36
- def init_from_json_file(self, json_filepath):
37
- """Inits the result from the specific model result file"""
38
- with open(json_filepath) as fp:
39
- data = json.load(fp)
40
-
41
- config = data.get("config")
42
-
43
- # Precision
44
- precision = Precision.from_str(config.get("model_dtype"))
45
-
46
- # Get model and org
47
- org_and_model = config.get("model_name", config.get("model_args", None))
48
- org_and_model = org_and_model.split("/", 1)
49
-
50
- if len(org_and_model) == 1:
51
- org = None
52
- model = org_and_model[0]
53
- result_key = f"{model}_{precision.value.name}"
54
- else:
55
- org = org_and_model[0]
56
- model = org_and_model[1]
57
- result_key = f"{org}_{model}_{precision.value.name}"
58
- full_model = "/".join(org_and_model)
59
-
60
- still_on_hub, _, model_config = is_model_on_hub(
61
- full_model, config.get("model_sha", "main"), trust_remote_code=True, test_tokenizer=False
62
- )
63
- architecture = "?"
64
- if model_config is not None:
65
- architectures = getattr(model_config, "architectures", None)
66
- if architectures:
67
- architecture = ";".join(architectures)
68
-
69
- # Extract results available in this file (some results are split in several files)
70
- results = {}
71
- for task in Tasks:
72
- task = task.value
73
-
74
- # We average all scores of a given metric (not all metrics are present in all files)
75
- accs = np.array([v.get(task.metric, None) for k, v in data["results"].items() if task.benchmark == k])
76
- if accs.size == 0 or any([acc is None for acc in accs]):
77
- continue
78
-
79
- mean_acc = np.mean(accs) * 100.0
80
- results[task.benchmark] = mean_acc
81
-
82
- return self(
83
- eval_name=result_key,
84
- full_model=full_model,
85
- org=org,
86
- model=model,
87
- results=results,
88
- precision=precision,
89
- revision= config.get("model_sha", ""),
90
- still_on_hub=still_on_hub,
91
- architecture=architecture
92
- )
93
-
94
- def update_with_request_file(self, requests_path):
95
- """Finds the relevant request file for the current model and updates info with it"""
96
- request_file = get_request_file_for_model(requests_path, self.full_model, self.precision.value.name)
97
-
98
- try:
99
- with open(request_file, "r") as f:
100
- request = json.load(f)
101
- self.model_type = ModelType.from_str(request.get("model_type", ""))
102
- self.weight_type = WeightType[request.get("weight_type", "Original")]
103
- self.license = request.get("license", "?")
104
- self.likes = request.get("likes", 0)
105
- self.num_params = request.get("params", 0)
106
- self.date = request.get("submitted_time", "")
107
- except Exception:
108
- print(f"Could not find request file for {self.org}/{self.model} with precision {self.precision.value.name}")
109
-
110
- def to_dict(self):
111
- """Converts the Eval Result to a dict compatible with our dataframe display"""
112
- average = sum([v for v in self.results.values() if v is not None]) / len(Tasks)
113
- data_dict = {
114
- "eval_name": self.eval_name, # not a column, just a save name,
115
- AutoEvalColumn.precision.name: self.precision.value.name,
116
- AutoEvalColumn.model_type.name: self.model_type.value.name,
117
- AutoEvalColumn.model_type_symbol.name: self.model_type.value.symbol,
118
- AutoEvalColumn.weight_type.name: self.weight_type.value.name,
119
- AutoEvalColumn.architecture.name: self.architecture,
120
- AutoEvalColumn.model.name: make_clickable_model(self.full_model),
121
- AutoEvalColumn.revision.name: self.revision,
122
- AutoEvalColumn.average.name: average,
123
- AutoEvalColumn.license.name: self.license,
124
- AutoEvalColumn.likes.name: self.likes,
125
- AutoEvalColumn.params.name: self.num_params,
126
- AutoEvalColumn.still_on_hub.name: self.still_on_hub,
127
- }
128
-
129
- for task in Tasks:
130
- data_dict[task.value.col_name] = self.results[task.value.benchmark]
131
-
132
- return data_dict
133
-
134
-
135
- def get_request_file_for_model(requests_path, model_name, precision):
136
- """Selects the correct request file for a given model. Only keeps runs tagged as FINISHED"""
137
- request_files = os.path.join(
138
- requests_path,
139
- f"{model_name}_eval_request_*.json",
140
- )
141
- request_files = glob.glob(request_files)
142
-
143
- # Select correct request file (precision)
144
- request_file = ""
145
- request_files = sorted(request_files, reverse=True)
146
- for tmp_request_file in request_files:
147
- with open(tmp_request_file, "r") as f:
148
- req_content = json.load(f)
149
- if (
150
- req_content["status"] in ["FINISHED"]
151
- and req_content["precision"] == precision.split(".")[-1]
152
- ):
153
- request_file = tmp_request_file
154
- return request_file
155
-
156
-
157
- def get_raw_eval_results(results_path: str, requests_path: str) -> list[EvalResult]:
158
- """From the path of the results folder root, extract all needed info for results"""
159
- model_result_filepaths = []
160
-
161
- for root, _, files in os.walk(results_path):
162
- # We should only have json files in model results
163
- if len(files) == 0 or any([not f.endswith(".json") for f in files]):
164
- continue
165
-
166
- # Sort the files by date
167
- try:
168
- files.sort(key=lambda x: x.removesuffix(".json").removeprefix("results_")[:-7])
169
- except dateutil.parser._parser.ParserError:
170
- files = [files[-1]]
171
-
172
- for file in files:
173
- model_result_filepaths.append(os.path.join(root, file))
174
-
175
- eval_results = {}
176
- for model_result_filepath in model_result_filepaths:
177
- # Creation of result
178
- eval_result = EvalResult.init_from_json_file(model_result_filepath)
179
- eval_result.update_with_request_file(requests_path)
180
-
181
- # Store results of same eval together
182
- eval_name = eval_result.eval_name
183
- if eval_name in eval_results.keys():
184
- eval_results[eval_name].results.update({k: v for k, v in eval_result.results.items() if v is not None})
185
- else:
186
- eval_results[eval_name] = eval_result
187
-
188
- results = []
189
- for v in eval_results.values():
190
- try:
191
- v.to_dict() # we test if the dict version is complete
192
- results.append(v)
193
- except KeyError: # not all eval values present
194
- continue
195
-
196
- return results
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/leaderboard/sage_eval.py DELETED
@@ -1,238 +0,0 @@
1
- import json
2
- import os
3
- from dataclasses import dataclass
4
- from typing import Dict, List, Any
5
-
6
- import numpy as np
7
-
8
- from src.display.formatting import make_clickable_model
9
- from src.display.utils import AutoEvalColumn, ModelType, Tasks, Precision, WeightType
10
-
11
-
12
- @dataclass
13
- class SAGEResult:
14
- """Represents one SAGE evaluation result"""
15
- submission_id: str
16
- organization: str
17
- email: str
18
- results: Dict[str, float] # Domain -> accuracy
19
- num_predictions: int
20
- submitted_time: str
21
- status: str = "EVALUATED"
22
-
23
- def to_dict(self):
24
- """Converts the SAGE Result to a dict compatible with our dataframe display"""
25
- # Use overall score if available, otherwise calculate average
26
- if "sage_overall" in self.results:
27
- average = self.results["sage_overall"]
28
- else:
29
- domain_scores = [v for v in self.results.values() if v is not None and isinstance(v, (int, float))]
30
- average = sum(domain_scores) / len(domain_scores) if domain_scores else 0.0
31
-
32
- # Extract model name from submission_id for initial results
33
- if self.submission_id.startswith("initial_"):
34
- model_name = self.submission_id.split("_", 2)[-1].replace("_", " ")
35
- display_name = f"**{model_name}**"
36
- model_symbol = "🤖"
37
- else:
38
- display_name = f"[{self.organization}]({self.email})"
39
- model_symbol = "🏢"
40
-
41
- data_dict = {
42
- "eval_name": self.submission_id,
43
- AutoEvalColumn.model.name: display_name,
44
- AutoEvalColumn.model_type_symbol.name: model_symbol,
45
- AutoEvalColumn.model_type.name: "SAGE Benchmark",
46
- AutoEvalColumn.precision.name: self.organization, # Show organization/context info
47
- AutoEvalColumn.weight_type.name: "Evaluated",
48
- AutoEvalColumn.architecture.name: "Multi-domain",
49
- AutoEvalColumn.average.name: round(average, 2),
50
- AutoEvalColumn.license.name: "N/A",
51
- AutoEvalColumn.likes.name: 0,
52
- AutoEvalColumn.params.name: 0,
53
- AutoEvalColumn.still_on_hub.name: True,
54
- AutoEvalColumn.revision.name: self.submitted_time,
55
- }
56
-
57
- # Add domain-specific scores
58
- for task in Tasks:
59
- domain_key = task.value.benchmark
60
- data_dict[task.value.col_name] = self.results.get(domain_key, 0.0)
61
-
62
- return data_dict
63
-
64
-
65
- def evaluate_sage_submission(submission_data: Dict[str, Any]) -> Dict[str, float]:
66
- """
67
- Evaluate a SAGE submission and calculate domain-specific accuracies.
68
- This is a placeholder function - in practice, you would compare against ground truth.
69
- """
70
-
71
- # Placeholder evaluation - in real implementation, you would:
72
- # 1. Load ground truth answers for each question
73
- # 2. Compare submitted content with ground truth
74
- # 3. Calculate accuracy for each scientific domain
75
-
76
- predictions = submission_data["predictions"]
77
-
78
- # Simulate domain classification and accuracy calculation
79
- # In practice, you would have question_id -> domain mapping and ground truth
80
- domain_counts = {
81
- "sage_math": 0,
82
- "sage_physics": 0,
83
- "sage_chemistry": 0,
84
- "sage_biology": 0,
85
- "sage_earth_science": 0,
86
- "sage_astronomy": 0
87
- }
88
-
89
- domain_correct = {
90
- "sage_math": 0,
91
- "sage_physics": 0,
92
- "sage_chemistry": 0,
93
- "sage_biology": 0,
94
- "sage_earth_science": 0,
95
- "sage_astronomy": 0
96
- }
97
-
98
- # Simulate evaluation - replace with actual evaluation logic
99
- total_questions = len(predictions)
100
- domain_size = total_questions // 6 # Assume equal distribution for demo
101
-
102
- for i, prediction in enumerate(predictions):
103
- # Assign questions to domains based on question_id (simplified)
104
- question_id = prediction["original_question_id"]
105
-
106
- # Simple domain assignment (in practice, use actual question metadata)
107
- if question_id % 6 == 0:
108
- domain = "sage_math"
109
- elif question_id % 6 == 1:
110
- domain = "sage_physics"
111
- elif question_id % 6 == 2:
112
- domain = "sage_chemistry"
113
- elif question_id % 6 == 3:
114
- domain = "sage_biology"
115
- elif question_id % 6 == 4:
116
- domain = "sage_earth_science"
117
- else:
118
- domain = "sage_astronomy"
119
-
120
- domain_counts[domain] += 1
121
-
122
- # Simulate accuracy (replace with actual evaluation against ground truth)
123
- # For demo purposes, assign random accuracy between 60-90%
124
- np.random.seed(question_id) # Consistent "accuracy" for demo
125
- is_correct = np.random.random() > 0.3 # 70% accuracy simulation
126
-
127
- if is_correct:
128
- domain_correct[domain] += 1
129
-
130
- # Calculate accuracies
131
- domain_accuracies = {}
132
- for domain in domain_counts:
133
- if domain_counts[domain] > 0:
134
- accuracy = (domain_correct[domain] / domain_counts[domain]) * 100
135
- domain_accuracies[domain] = round(accuracy, 2)
136
- else:
137
- domain_accuracies[domain] = 0.0
138
-
139
- # Add overall accuracy
140
- total_correct = sum(domain_correct.values())
141
- total_questions = sum(domain_counts.values())
142
- overall_accuracy = (total_correct / total_questions) * 100 if total_questions > 0 else 0.0
143
- domain_accuracies["sage_overall"] = round(overall_accuracy, 2)
144
-
145
- return domain_accuracies
146
-
147
-
148
- def load_initial_sage_results() -> List[SAGEResult]:
149
- """Load initial SAGE results from the provided performance table"""
150
- # Try multiple possible paths for the initial results file
151
- possible_paths = [
152
- "./initial_sage_results.json",
153
- "initial_sage_results.json",
154
- os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "initial_sage_results.json")
155
- ]
156
-
157
- initial_results_path = None
158
- for path in possible_paths:
159
- if os.path.exists(path):
160
- initial_results_path = path
161
- break
162
-
163
- sage_results = []
164
-
165
- if initial_results_path:
166
- try:
167
- with open(initial_results_path, 'r') as f:
168
- initial_data = json.load(f)
169
-
170
- for i, entry in enumerate(initial_data):
171
- sage_result = SAGEResult(
172
- submission_id=f"initial_{i:02d}_{entry['model_name'].replace(' ', '_').replace('-', '_')}",
173
- organization=f"{entry['organization']} ({entry['tokens']})",
174
- email=f"contact@{entry['organization'].lower().replace(' ', '')}.com",
175
- results=entry["results"],
176
- num_predictions=1000, # Estimated from benchmark
177
- submitted_time=entry["submitted_time"],
178
- status="EVALUATED"
179
- )
180
- sage_results.append(sage_result)
181
-
182
- except Exception as e:
183
- print(f"Error loading initial SAGE results from {initial_results_path}: {e}")
184
- else:
185
- print(f"Initial SAGE results file not found. Tried paths: {possible_paths}")
186
- print(f"Current working directory: {os.getcwd()}")
187
- print(f"Files in current directory: {os.listdir('.')}")
188
-
189
- return sage_results
190
-
191
-
192
- def process_sage_results_for_leaderboard(submissions_dir: str = "./sage_submissions") -> List[SAGEResult]:
193
- """Process all SAGE submissions and convert them to leaderboard format"""
194
-
195
- sage_results = []
196
-
197
- # Load initial benchmark results
198
- sage_results.extend(load_initial_sage_results())
199
-
200
- # Load user submissions if directory exists
201
- if os.path.exists(submissions_dir):
202
- for org_dir in os.listdir(submissions_dir):
203
- org_path = os.path.join(submissions_dir, org_dir)
204
- if not os.path.isdir(org_path):
205
- continue
206
-
207
- for file in os.listdir(org_path):
208
- if file.startswith("submission_") and file.endswith(".json"):
209
- try:
210
- # Load submission data
211
- submission_path = os.path.join(org_path, file)
212
- with open(submission_path, 'r') as f:
213
- submission_data = json.load(f)
214
-
215
- # Evaluate the submission
216
- domain_accuracies = evaluate_sage_submission(submission_data)
217
-
218
- # Create result object
219
- timestamp = file.replace("submission_", "").replace(".json", "")
220
- submission_id = f"{org_dir}_{timestamp}"
221
-
222
- sage_result = SAGEResult(
223
- submission_id=submission_id,
224
- organization=submission_data["submission_org"],
225
- email=submission_data["submission_email"],
226
- results=domain_accuracies,
227
- num_predictions=len(submission_data["predictions"]),
228
- submitted_time=timestamp,
229
- status="EVALUATED"
230
- )
231
-
232
- sage_results.append(sage_result)
233
-
234
- except Exception as e:
235
- print(f"Error processing SAGE submission {file}: {e}")
236
- continue
237
-
238
- return sage_results
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/populate.py CHANGED
@@ -5,8 +5,7 @@ import pandas as pd
5
  from typing import List
6
 
7
  from src.display.formatting import has_no_nan_values, make_clickable_model
8
- from src.display.utils import AutoEvalColumn, EvalQueueColumn
9
- # from src.leaderboard.read_evals import get_raw_eval_results # Removed to avoid transformers dependency
10
 
11
  # Import SAGE-specific modules - avoid transformers dependency
12
  process_sage_results_for_leaderboard = None
@@ -73,13 +72,12 @@ try:
73
 
74
  return data_dict
75
 
76
- def load_initial_sage_results_local() -> List[SAGEResult]:
77
- """Load initial SAGE results from OSS or local files"""
78
  sage_results = []
79
 
80
- # 尝试从OSS加载
81
  try:
82
- # 导入OSS排行榜管理器(现在在本地oss目录中)
83
  from src.oss.oss_leaderboard_manager import OSSLeaderboardManager
84
 
85
  # 从OSS加载排行榜数据
@@ -100,78 +98,26 @@ try:
100
  status="EVALUATED"
101
  )
102
  sage_results.append(sage_result)
103
-
104
- return sage_results
105
  else:
106
- print("⚠️ OSS中未找到排行榜数据,尝试本地文件")
107
 
108
  except Exception as e:
109
- print(f"⚠️ 从OSS加载排行榜失败: {e}")
110
- print("🔄 回退到本地文件模式")
111
-
112
- # 回退到本地文件模式
113
- possible_paths = [
114
- "./initial_sage_results.json",
115
- "initial_sage_results.json",
116
- os.path.join(os.path.dirname(os.path.dirname(__file__)), "initial_sage_results.json")
117
- ]
118
-
119
- initial_results_path = None
120
- for path in possible_paths:
121
- if os.path.exists(path):
122
- initial_results_path = path
123
- break
124
-
125
- if initial_results_path:
126
- try:
127
- with open(initial_results_path, 'r') as f:
128
- initial_data = json.load(f)
129
-
130
- print(f"✅ 从本地文件加载了 {len(initial_data)} 条排行榜记录: {initial_results_path}")
131
-
132
- for i, entry in enumerate(initial_data):
133
- sage_result = SAGEResult(
134
- submission_id=f"local_{i:02d}_{entry['model_name'].replace(' ', '_').replace('-', '_')}",
135
- organization=f"{entry['organization']} ({entry.get('tokens', 'N/A')})",
136
- email=entry.get('contact_email', f"contact@{entry['organization'].lower().replace(' ', '')}.com"),
137
- results=entry["results"],
138
- num_predictions=1000,
139
- submitted_time=entry["submitted_time"],
140
- status="EVALUATED"
141
- )
142
- sage_results.append(sage_result)
143
-
144
- except Exception as e:
145
- print(f"❌ 从本地文件加载排行榜失败 {initial_results_path}: {e}")
146
- else:
147
- print(f"❌ 未找到排行榜文件。尝试过的路径: {possible_paths}")
148
 
149
  return sage_results
150
 
151
- def process_sage_results_for_leaderboard_local(submissions_dir: str = "./sage_submissions") -> List[SAGEResult]:
152
- """Process all SAGE submissions without external dependencies"""
153
- sage_results = []
154
-
155
- # Load initial benchmark results
156
- sage_results.extend(load_initial_sage_results_local())
157
-
158
- return sage_results
159
 
160
  # Set the function
161
- process_sage_results_for_leaderboard = process_sage_results_for_leaderboard_local
162
 
163
  except ImportError as e:
164
  print(f"Could not set up SAGE results processing: {e}")
165
  process_sage_results_for_leaderboard = None
166
 
167
 
168
- def get_leaderboard_df(results_path: str, requests_path: str, cols: list, benchmark_cols: list) -> pd.DataFrame:
169
- """Creates a dataframe from all the individual experiment results - disabled for SAGE"""
170
- # For SAGE, we use get_sage_leaderboard_df instead
171
- print("⚠️ get_leaderboard_df called - use get_sage_leaderboard_df for SAGE instead")
172
- return pd.DataFrame()
173
-
174
-
175
  def get_sage_leaderboard_df(cols: list, benchmark_cols: list) -> pd.DataFrame:
176
  """Creates a dataframe from SAGE evaluation results"""
177
  if process_sage_results_for_leaderboard is None:
@@ -190,45 +136,4 @@ def get_sage_leaderboard_df(cols: list, benchmark_cols: list) -> pd.DataFrame:
190
 
191
  # filter out if any of the benchmarks have not been produced
192
  df = df[has_no_nan_values(df, benchmark_cols)]
193
- return df
194
-
195
-
196
- def get_evaluation_queue_df(save_path: str, cols: list) -> List[pd.DataFrame]:
197
- """Creates the different dataframes for the evaluation queues requestes"""
198
- if not os.path.exists(save_path):
199
- # Return empty dataframes if the path doesn't exist
200
- empty_df = pd.DataFrame(columns=cols)
201
- return empty_df, empty_df, empty_df
202
-
203
- entries = [entry for entry in os.listdir(save_path) if not entry.startswith(".")]
204
- all_evals = []
205
-
206
- for entry in entries:
207
- if ".json" in entry:
208
- file_path = os.path.join(save_path, entry)
209
- with open(file_path) as fp:
210
- data = json.load(fp)
211
-
212
- data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
213
- data[EvalQueueColumn.revision.name] = data.get("revision", "main")
214
-
215
- all_evals.append(data)
216
- elif ".md" not in entry:
217
- # this is a folder
218
- sub_entries = [e for e in os.listdir(f"{save_path}/{entry}") if os.path.isfile(e) and not e.startswith(".")]
219
- for sub_entry in sub_entries:
220
- file_path = os.path.join(save_path, entry, sub_entry)
221
- with open(file_path) as fp:
222
- data = json.load(fp)
223
-
224
- data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
225
- data[EvalQueueColumn.revision.name] = data.get("revision", "main")
226
- all_evals.append(data)
227
-
228
- pending_list = [e for e in all_evals if e["status"] in ["PENDING", "RERUN"]]
229
- running_list = [e for e in all_evals if e["status"] == "RUNNING"]
230
- finished_list = [e for e in all_evals if e["status"].startswith("FINISHED") or e["status"] == "PENDING_NEW_EVAL"]
231
- df_pending = pd.DataFrame.from_records(pending_list, columns=cols)
232
- df_running = pd.DataFrame.from_records(running_list, columns=cols)
233
- df_finished = pd.DataFrame.from_records(finished_list, columns=cols)
234
- return df_finished[cols], df_running[cols], df_pending[cols]
 
5
  from typing import List
6
 
7
  from src.display.formatting import has_no_nan_values, make_clickable_model
8
+ from src.display.utils import AutoEvalColumn
 
9
 
10
  # Import SAGE-specific modules - avoid transformers dependency
11
  process_sage_results_for_leaderboard = None
 
72
 
73
  return data_dict
74
 
75
+ def load_initial_sage_results_from_oss() -> List[SAGEResult]:
76
+ """Load initial SAGE results from OSS"""
77
  sage_results = []
78
 
 
79
  try:
80
+ # 导入OSS排行榜管理器
81
  from src.oss.oss_leaderboard_manager import OSSLeaderboardManager
82
 
83
  # 从OSS加载排行榜数据
 
98
  status="EVALUATED"
99
  )
100
  sage_results.append(sage_result)
 
 
101
  else:
102
+ print("⚠️ OSS中未找到排行榜数据")
103
 
104
  except Exception as e:
105
+ print(f" 从OSS加载排行榜失败: {e}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
  return sage_results
108
 
109
+ def process_sage_results_for_leaderboard_oss() -> List[SAGEResult]:
110
+ """Process all SAGE results from OSS"""
111
+ return load_initial_sage_results_from_oss()
 
 
 
 
 
112
 
113
  # Set the function
114
+ process_sage_results_for_leaderboard = process_sage_results_for_leaderboard_oss
115
 
116
  except ImportError as e:
117
  print(f"Could not set up SAGE results processing: {e}")
118
  process_sage_results_for_leaderboard = None
119
 
120
 
 
 
 
 
 
 
 
121
  def get_sage_leaderboard_df(cols: list, benchmark_cols: list) -> pd.DataFrame:
122
  """Creates a dataframe from SAGE evaluation results"""
123
  if process_sage_results_for_leaderboard is None:
 
136
 
137
  # filter out if any of the benchmarks have not been produced
138
  df = df[has_no_nan_values(df, benchmark_cols)]
139
+ return df