File size: 2,623 Bytes
922c3ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""

Simple Deployment Validation

===========================



Quick validation for Hugging Face Spaces deployment.

"""

import os
import sys


def main():
    print("πŸš€ Legal Dashboard OCR - Simple Deployment Validation")
    print("=" * 60)

    # Check essential files
    essential_files = [
        "huggingface_space/app.py",
        "huggingface_space/Spacefile",
        "huggingface_space/README.md",
        "requirements.txt",
        "app/services/ocr_service.py",
        "app/services/ai_service.py",
        "app/services/database_service.py",
        "data/sample_persian.pdf"
    ]

    print("πŸ” Checking essential files...")
    all_files_exist = True

    for file_path in essential_files:
        if os.path.exists(file_path):
            print(f"βœ… {file_path}")
        else:
            print(f"❌ {file_path}")
            all_files_exist = False

    # Check requirements.txt for gradio
    print("\nπŸ” Checking requirements.txt...")
    try:
        with open("requirements.txt", "r", encoding="utf-8") as f:
            content = f.read()
            if "gradio" in content:
                print("βœ… gradio found in requirements.txt")
            else:
                print("❌ gradio missing from requirements.txt")
                all_files_exist = False
    except Exception as e:
        print(f"❌ Error reading requirements.txt: {e}")
        all_files_exist = False

    # Check Spacefile
    print("\nπŸ” Checking Spacefile...")
    try:
        with open("huggingface_space/Spacefile", "r", encoding="utf-8") as f:
            content = f.read()
            if "gradio" in content and "python" in content:
                print("βœ… Spacefile properly configured")
            else:
                print("❌ Spacefile missing required configurations")
                all_files_exist = False
    except Exception as e:
        print(f"❌ Error reading Spacefile: {e}")
        all_files_exist = False

    # Final result
    print("\n" + "=" * 60)
    if all_files_exist:
        print("πŸŽ‰ All checks passed! Ready for deployment.")
        print("\nπŸ“‹ Deployment Steps:")
        print("1. Create Space on https://huggingface.co/spaces")
        print("2. Upload huggingface_space/ directory")
        print("3. Set HF_TOKEN environment variable")
        print("4. Deploy and test")
        return 0
    else:
        print("⚠️ Some checks failed. Please fix issues before deployment.")
        return 1


if __name__ == "__main__":
    sys.exit(main())