-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_library.py
More file actions
executable file
·105 lines (84 loc) · 2.96 KB
/
test_library.py
File metadata and controls
executable file
·105 lines (84 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env python3
"""
Simple test script to verify RefineBench library functionality.
"""
import os
import sys
# Add the current directory to Python path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
def test_imports():
"""Test that all modules can be imported"""
try:
from refinebench_eval import RefineBenchConfig, RefineBenchDataset
print("✓ Core imports successful")
from refinebench_eval.config import ModelConfig, ExperimentalConfig
print("✓ Config imports successful")
from refinebench_eval.dataset import RefineBenchDataset
print("✓ Dataset imports successful")
from refinebench_eval.utils import MessageBuilder
print("✓ Utils imports successful")
return True
except ImportError as e:
print(f"✗ Import error: {e}")
return False
def test_config():
"""Test configuration creation"""
try:
from refinebench_eval import RefineBenchConfig
config = RefineBenchConfig(
agent=RefineBenchConfig.ModelConfig(
model_name="test_model",
model_path="test/path"
),
evaluator=RefineBenchConfig.ModelConfig(
model_name="test_evaluator",
model_path="test/evaluator"
)
)
print("✓ Configuration creation successful")
return True
except Exception as e:
print(f"✗ Configuration error: {e}")
return False
def test_dataset():
"""Test dataset loading"""
try:
from refinebench_eval import RefineBenchDataset
dataset = RefineBenchDataset()
print("✓ Dataset initialization successful")
# Test getting data index list (this will try to load from HF)
try:
indices = dataset.get_data_index_list()
print(f"✓ Dataset loading successful, found {len(indices)} instances")
except Exception as e:
print(f"⚠ Dataset loading failed (expected if no internet): {e}")
return True
except Exception as e:
print(f"✗ Dataset error: {e}")
return False
def main():
print("Testing RefineBench Library...")
print("=" * 40)
tests = [
("Import Test", test_imports),
("Configuration Test", test_config),
("Dataset Test", test_dataset),
]
passed = 0
total = len(tests)
for test_name, test_func in tests:
print(f"\n{test_name}:")
if test_func():
passed += 1
else:
print(f"❌ {test_name} failed")
print("\n" + "=" * 40)
print(f"Tests passed: {passed}/{total}")
if passed == total:
print("🎉 All tests passed! Library is ready to use.")
return 0
else:
print("⚠️ Some tests failed. Check the errors above.")
return 1
if __name__ == "__main__":
sys.exit(main())