gaia-enhanced-agent / test_deployment_readiness.py
GAIA Agent Deployment
Deploy Complete Enhanced GAIA Agent with Phase 1-6 Improvements
9a6a4dc
#!/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)