wesleysimplicio commited on
Commit
b44043d
·
verified ·
1 Parent(s): 018704e

benchmarks: add run_aider_benchmark.py

Browse files
Files changed (1) hide show
  1. benchmarks/run_aider_benchmark.py +55 -0
benchmarks/run_aider_benchmark.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Official 2026 Aider Code Editing Benchmark Runner for Simplicio 27B
2
+ import os
3
+ import re
4
+ import ast
5
+ import sys
6
+ import json
7
+ import tempfile
8
+ import subprocess
9
+ from typing import List, Dict, Tuple
10
+
11
+ def load_instances() -> List[Dict]:
12
+ data_path = os.path.join(os.path.dirname(__file__), "aider_instances.json")
13
+ with open(data_path, "r", encoding="utf-8") as f:
14
+ return json.load(f)
15
+
16
+ def parse_surgical_diff(patch_content: str) -> List[Tuple[str, str]]:
17
+ pattern = r"<<<< SEARCH\s*\n(.*?)\n====\s*\n(.*?)\n>>>> REPLACE"
18
+ return re.findall(pattern, patch_content, re.DOTALL)
19
+
20
+ def evaluate_patch(initial: str, search_c: str, replace_c: str, test_code: str, fname: str) -> Dict:
21
+ res = {"search_matched": False, "ast_valid": False, "test_passed": False}
22
+ c_init = initial.replace("\r\n", "\n").strip()
23
+ c_search = search_c.replace("\r\n", "\n").strip()
24
+ if c_search in c_init:
25
+ res["search_matched"] = True
26
+ patched = c_init.replace(c_search, replace_c.strip())
27
+ try:
28
+ ast.parse(patched)
29
+ res["ast_valid"] = True
30
+ except SyntaxError:
31
+ return res
32
+ with tempfile.TemporaryDirectory() as tmpdir:
33
+ with open(os.path.join(tmpdir, fname), "w", encoding="utf-8") as sf:
34
+ sf.write(patched)
35
+ t_path = os.path.join(tmpdir, "test_" + fname)
36
+ with open(t_path, "w", encoding="utf-8") as tf:
37
+ tf.write(test_code)
38
+ p = subprocess.run([sys.executable, "-m", "pytest", t_path, "-q"], cwd=tmpdir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
39
+ if p.returncode == 0:
40
+ res["test_passed"] = True
41
+ return res
42
+
43
+ def main():
44
+ cases = load_instances()
45
+ print("=" * 80)
46
+ print("🚀 OFFICIAL 2026 AIDER CODE EDITING BENCHMARK (SIMPLICIO 27B HARNESS)")
47
+ print("Evaluating Exercism testbed with atomic diff editing and pytest execution.")
48
+ print("=" * 80)
49
+ print(f"Loaded {len(cases)} official benchmark instances:")
50
+ for c in cases:
51
+ print(f" - [{c['instance_id']}] Target: {c['file']}")
52
+ print("\nReady for model inference and evaluation.")
53
+
54
+ if __name__ == "__main__":
55
+ main()