File size: 4,849 Bytes
5e1a30c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
HuggingFace Spaces Deployment Validation Script
Epic 2 Enhanced RAG System

This script validates that all necessary files and dependencies 
are properly configured for HuggingFace Spaces deployment.
"""

import os
import sys
from pathlib import Path

def check_file_exists(file_path, description):
    """Check if a file exists and report status."""
    if Path(file_path).exists():
        print(f"βœ… {description}: {file_path}")
        return True
    else:
        print(f"❌ {description}: {file_path} - NOT FOUND")
        return False

def check_directory_exists(dir_path, description):
    """Check if a directory exists and report status."""
    if Path(dir_path).is_dir():
        print(f"βœ… {description}: {dir_path}")
        return True
    else:
        print(f"❌ {description}: {dir_path} - NOT FOUND")
        return False

def validate_deployment():
    """Run complete deployment validation."""
    print("πŸš€ Epic 2 Enhanced RAG - HuggingFace Spaces Deployment Validation")
    print("=" * 70)
    
    validation_passed = True
    
    # Check essential application files
    print("\nπŸ“± Application Files:")
    validation_passed &= check_file_exists("app.py", "Main entry point")
    validation_passed &= check_file_exists("streamlit_epic2_demo.py", "Epic 2 demo app")
    validation_passed &= check_file_exists("requirements.txt", "Dependencies")
    validation_passed &= check_file_exists("README.md", "Documentation")
    
    # Check core system architecture
    print("\nπŸ—οΈ System Architecture:")
    validation_passed &= check_directory_exists("src", "Core system")
    validation_passed &= check_directory_exists("src/core", "Platform orchestrator")
    validation_passed &= check_directory_exists("src/components", "Components")
    validation_passed &= check_file_exists("src/core/platform_orchestrator.py", "Platform orchestrator")
    validation_passed &= check_file_exists("src/core/component_factory.py", "Component factory")
    
    # Check configuration files
    print("\nβš™οΈ Configuration:")
    validation_passed &= check_directory_exists("config", "Configuration directory")
    validation_passed &= check_file_exists("config/default.yaml", "Basic configuration")
    validation_passed &= check_file_exists("config/epic2_graph_calibrated.yaml", "Epic 2 configuration")
    
    # Check sample data
    print("\nπŸ“„ Sample Data:")
    validation_passed &= check_directory_exists("data", "Data directory")
    validation_passed &= check_directory_exists("data/test", "Test documents")
    
    # Check validation evidence
    print("\nπŸ“Š Validation Evidence:")
    validation_passed &= check_file_exists("SCORE_COMPRESSION_FIX_COMPLETE_VALIDATION.md", "Performance validation")
    validation_passed &= check_file_exists("DEPLOYMENT_GUIDE.md", "Deployment guide")
    
    # Summary
    print("\n" + "=" * 70)
    if validation_passed:
        print("πŸŽ‰ VALIDATION PASSED: All files ready for HuggingFace Spaces deployment!")
        print("\nπŸ“‹ Next Steps:")
        print("1. Create new Streamlit Space on HuggingFace")
        print("2. Upload all files to your space")
        print("3. Set HF_TOKEN environment variable (optional)")
        print("4. Monitor build logs and deploy")
        print("\nπŸš€ Expected Results:")
        print("- Epic 2 capabilities with 48.7% MRR improvement")
        print("- Automatic environment detection and configuration")
        print("- Professional demo showcasing Swiss engineering standards")
        return True
    else:
        print("❌ VALIDATION FAILED: Missing required files or directories")
        print("\nπŸ”§ Please ensure all Epic 2 system files are properly copied")
        return False

def check_requirements_compatibility():
    """Check if requirements.txt is HF Spaces compatible."""
    try:
        with open("requirements.txt", "r") as f:
            content = f.read()
        
        print("\nπŸ“¦ Requirements Analysis:")
        lines = [line.strip() for line in content.split('\n') if line.strip() and not line.startswith('#')]
        print(f"βœ… Dependencies count: {len(lines)}")
        
        # Check for HF Spaces optimizations
        if "streamlit" in content:
            print("βœ… Streamlit framework included")
        if "transformers" in content:
            print("βœ… Transformers library included")
        if "huggingface-hub" in content:
            print("βœ… HuggingFace Hub integration included")
        
        print("βœ… Requirements file appears HF Spaces compatible")
        
    except FileNotFoundError:
        print("❌ requirements.txt not found")
        return False
    
    return True

if __name__ == "__main__":
    success = validate_deployment()
    success &= check_requirements_compatibility()
    
    sys.exit(0 if success else 1)