MCPcopy Create free account
hub / github.com/SkyworkAI/DeepResearchAgent / test_math_benchmark

Function test_math_benchmark

examples/run_benchmark.py:134–358  ·  view source on GitHub ↗

Test the benchmark manager specifically for Math/AIME using a REAL model. Uses response_format for structured output with concurrent processing. Args: benchmark_name: Name of the benchmark to test max_concurrency: Maximum number of concurrent tasks to process re

(benchmark_name: str = "aime25", max_concurrency: int = 5, result_saver: Optional[BenchmarkResultSaver] = None)

Source from the content-addressed store, hash-verified

132 return re.sub(r'[\\/*?:"<>|]', '', name).strip()
133
134async def test_math_benchmark(benchmark_name: str = "aime25", max_concurrency: int = 5, result_saver: Optional[BenchmarkResultSaver] = None):
135 """
136 Test the benchmark manager specifically for Math/AIME using a REAL model.
137 Uses response_format for structured output with concurrent processing.
138
139 Args:
140 benchmark_name: Name of the benchmark to test
141 max_concurrency: Maximum number of concurrent tasks to process
142 result_saver: Optional result saver for recording results
143 """
144 print(f"🧪 Testing benchmark manager with benchmark: {benchmark_name}")
145 print(f"🤖 Using Model: {TARGET_MODEL}")
146 print(f"⚡ Max Concurrency: {max_concurrency}")
147
148 # 定义保存目录
149 save_dir = os.path.join(config.workdir, "benchmark", benchmark_name)
150 if not os.path.exists(save_dir):
151 os.makedirs(save_dir, exist_ok=True)
152 print(f"📁 Created output directory: {save_dir}")
153
154 # 1. 重置并收集所有任务
155 print(f"🔄 Resetting progress for {benchmark_name}...")
156 task = await benchmark_manager.reset(benchmark_name)
157
158 if not task:
159 logger.warning("⚠️ No tasks available to run (Dataset empty or all finished).")
160 return
161
162 # 收集所有任务
163 print(f"📦 Collecting all tasks...")
164 all_tasks = []
165 while task is not None:
166 all_tasks.append(task)
167 task = await benchmark_manager.step(benchmark_name)
168
169 total_tasks = len(all_tasks)
170 print(f"✅ Collected {total_tasks} tasks. Starting concurrent processing...")
171
172 # Update result saver with actual task count
173 if result_saver:
174 result_saver.update_total_tasks(total_tasks)
175
176 # 创建 Semaphore 限制并发数
177 semaphore = asyncio.Semaphore(max_concurrency)
178
179 # 用于跟踪进度
180 completed_count = 0
181 completed_lock = asyncio.Lock()
182
183 async def process_single_task(task: Task, result_saver: Optional[BenchmarkResultSaver] = None) -> Task:
184 """处理单个任务的协程函数"""
185 nonlocal completed_count # 必须在函数开始处声明
186 task_id = task.task_id
187 start_time = time.time()
188
189 async with semaphore: # 使用 Semaphore 限制并发
190 try:
191 print(f"\n" + "="*50)

Callers 1

mainFunction · 0.70

Calls 13

printFunction · 0.85
joinMethod · 0.80
warningMethod · 0.80
update_total_tasksMethod · 0.80
dumpMethod · 0.80
process_single_taskFunction · 0.70
existsMethod · 0.45
resetMethod · 0.45
appendMethod · 0.45
stepMethod · 0.45
errorMethod · 0.45
statsMethod · 0.45

Tested by

no test coverage detected