Spaces:
Running
Running
File size: 7,176 Bytes
9a6a4dc |
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 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
#!/usr/bin/env python3
"""
Phase 6 Deployment Readiness Test
Comprehensive validation that all improvements are ready for HuggingFace deployment.
"""
import sys
import os
from pathlib import Path
import importlib.util
# Add current directory to path
sys.path.insert(0, str(Path(__file__).parent))
def test_core_components():
"""Test that all core components are available."""
print("π Testing Core Components...")
# Test agent imports
try:
from agents.fixed_enhanced_unified_agno_agent import FixedGAIAAgent
print("β
Fixed GAIA Agent import successful")
except ImportError as e:
print(f"β Fixed GAIA Agent import failed: {e}")
return False
# Test calculator prompt enhancer
try:
from utils.calculator_prompt_enhancer import CalculatorPromptEnhancer
print("β
Calculator Prompt Enhancer import successful")
except ImportError as e:
print(f"β Calculator Prompt Enhancer import failed: {e}")
return False
# Test response processor
try:
from utils.response_processor import EnhancedResponseProcessor
print("β
Enhanced Response Processor import successful")
except ImportError as e:
print(f"β Enhanced Response Processor import failed: {e}")
return False
# Test file handler
try:
from utils.file_handler import EnhancedFileHandler
print("β
Enhanced File Handler import successful")
except ImportError as e:
print(f"β Enhanced File Handler import failed: {e}")
return False
return True
def test_app_functionality():
"""Test that the main app.py is functional."""
print("\nπ Testing App Functionality...")
try:
# Test app import
spec = importlib.util.spec_from_file_location("app", "app.py")
app_module = importlib.util.module_from_spec(spec)
# Check if app has required functions
spec.loader.exec_module(app_module)
if hasattr(app_module, 'setup_environment'):
print("β
App has setup_environment function")
elif hasattr(app_module, 'DeploymentReadyGAIAAgent'):
print("β
App has DeploymentReadyGAIAAgent class")
else:
print("β App missing required components")
return False
return True
except Exception as e:
print(f"β App functionality test failed: {e}")
return False
def test_calculator_improvements():
"""Test that calculator improvements are working."""
print("\nπ Testing Calculator Improvements...")
try:
from utils.calculator_prompt_enhancer import CalculatorPromptEnhancer
enhancer = CalculatorPromptEnhancer()
# Test exponentiation detection
test_cases = [
"What is 2 to the power of 8?",
"Calculate 2^8",
"What is 2**8?"
]
for test_case in test_cases:
enhanced = enhancer.enhance_prompt_for_exponentiation(test_case)
if "Python" in enhanced or "python" in enhanced:
print(f"β
Exponentiation enhancement working: {test_case}")
else:
print(f"β οΈ Enhancement may not be working: {test_case}")
return True
except Exception as e:
print(f"β Calculator improvements test failed: {e}")
return False
def test_file_structure():
"""Test that all required files are present."""
print("\nπ Testing File Structure...")
required_files = [
"app.py",
"requirements.txt",
"push_to_hf.py",
"agents/fixed_enhanced_unified_agno_agent.py",
"utils/calculator_prompt_enhancer.py",
"utils/response_processor.py",
"utils/file_handler.py",
"utils/environment_setup.py"
]
missing_files = []
for file_path in required_files:
if Path(file_path).exists():
print(f"β
{file_path}")
else:
print(f"β Missing: {file_path}")
missing_files.append(file_path)
return len(missing_files) == 0
def test_phase_improvements():
"""Test that all phase improvements are integrated."""
print("\nπ Testing Phase Improvements Integration...")
# Check Phase 1-5 test results
test_files = [
"tests/test_calculator_accuracy_100.py",
"tests/test_calculator_exponentiation_fix.py",
"tests/test_agent_prompt_enhancer_integration.py",
"tests/test_response_processor.py",
"tests/test_file_handler.py"
]
available_tests = []
for test_file in test_files:
if Path(test_file).exists():
print(f"β
{test_file}")
available_tests.append(test_file)
else:
print(f"β οΈ Test not found: {test_file}")
print(f"π Available test suites: {len(available_tests)}/{len(test_files)}")
return len(available_tests) >= 3 # At least 3 test suites should be available
def test_deployment_script():
"""Test that deployment script is ready."""
print("\nπ Testing Deployment Script...")
try:
from push_to_hf import push_to_huggingface
print("β
HuggingFace deployment script import successful")
# Check if script has proper error handling
if "HF_TOKEN" in open("push_to_hf.py").read():
print("β
Deployment script checks for HF_TOKEN")
else:
print("β Deployment script missing HF_TOKEN check")
return False
return True
except Exception as e:
print(f"β Deployment script test failed: {e}")
return False
def main():
"""Run comprehensive deployment readiness test."""
print("π Phase 6 Deployment Readiness Test")
print("=" * 50)
tests = [
("Core Components", test_core_components),
("App Functionality", test_app_functionality),
("Calculator Improvements", test_calculator_improvements),
("File Structure", test_file_structure),
("Phase Improvements", test_phase_improvements),
("Deployment Script", test_deployment_script)
]
passed_tests = 0
total_tests = len(tests)
for test_name, test_func in tests:
try:
if test_func():
passed_tests += 1
print(f"β
{test_name}: PASSED")
else:
print(f"β {test_name}: FAILED")
except Exception as e:
print(f"β {test_name}: ERROR - {e}")
print("\n" + "=" * 50)
print(f"π Test Results: {passed_tests}/{total_tests} tests passed")
if passed_tests == total_tests:
print("π DEPLOYMENT READY! All tests passed.")
print("π Ready to push to HuggingFace Space with:")
print(" cd deployment-ready && python push_to_hf.py")
return True
else:
print("β οΈ Some tests failed. Please review before deployment.")
return False
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1) |