File size: 3,868 Bytes
7dfe46c |
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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
#!/usr/bin/env python3
"""
Test script to verify the Korean Q&A evaluation system setup.
"""
import sys
from pathlib import Path
# Add src to path
sys.path.append(str(Path(__file__).parent / "src"))
def test_imports():
"""Test that all modules can be imported."""
print("Testing imports...")
try:
from src.logger import setup_logging
print("β Logger module imported successfully")
from src.config import Config
print("β Config module imported successfully")
from src.dataset_loader import DatasetLoader
print("β Dataset loader module imported successfully")
from src.evaluator import KoreanQAEvaluator
print("β Evaluator module imported successfully")
from src.utils import load_environment_variables, validate_api_keys
print("β Utils module imported successfully")
return True
except ImportError as e:
print(f"β Import error: {e}")
return False
def test_logging():
"""Test logging setup."""
print("\nTesting logging setup...")
try:
from src.logger import setup_logging
logger_setup = setup_logging(log_level="INFO")
logger = logger_setup.get_logger("test")
logger.info("Test log message")
logger.warning("Test warning message")
print("β Logging setup successful")
return True
except Exception as e:
print(f"β Logging setup failed: {e}")
return False
def test_config():
"""Test configuration loading."""
print("\nTesting configuration...")
try:
from src.config import Config
# This will fail if API keys are not set, but that's expected
try:
config = Config("src/config.yaml")
print("β Configuration loaded successfully")
print(f" Model: {config.gemini_model}")
return True
except ValueError as e:
if "Missing required API keys" in str(e):
print("β Configuration loaded but API keys missing (expected)")
print(" Please set GOOGLE_API_KEY in your src/.env file")
return True
else:
raise
except Exception as e:
print(f"β Configuration test failed: {e}")
return False
def test_dataset():
"""Test dataset loading."""
print("\nTesting dataset loading...")
try:
from src.dataset_loader import DatasetLoader
dataset_path = "assets/bench_korean.csv"
if not Path(dataset_path).exists():
print(f"β Dataset file not found: {dataset_path}")
return True
loader = DatasetLoader()
# Just test the class instantiation
print("β Dataset loader initialized successfully")
return True
except Exception as e:
print(f"β Dataset loading test failed: {e}")
return False
def main():
"""Run all tests."""
print("Korean Q&A Evaluation System - Setup Test")
print("=" * 50)
tests = [
test_imports,
test_logging,
test_config,
test_dataset
]
passed = 0
total = len(tests)
for test in tests:
if test():
passed += 1
print("\n" + "=" * 50)
print(f"Test Results: {passed}/{total} tests passed")
if passed == total:
print("β All tests passed! System is ready to use.")
print("\nNext steps:")
print("1. Ensure GOOGLE_API_KEY is set in your src/.env file")
print("2. Run: python run_evaluation.py")
else:
print("β Some tests failed. Please check the errors above.")
sys.exit(1)
if __name__ == "__main__":
main() |