File size: 3,788 Bytes
db70c95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
Test script to check if all dependencies can be imported for Hugging Face deployment
"""

import sys

def test_imports():
    """Test all required imports"""
    print("πŸ§ͺ Testing deployment readiness...")
    
    failed_imports = []
    
    # Test core dependencies
    try:
        import gradio
        print("βœ… gradio")
    except ImportError as e:
        failed_imports.append(f"gradio: {e}")
        print("❌ gradio")
    
    try:
        import groq
        print("βœ… groq")
    except ImportError as e:
        failed_imports.append(f"groq: {e}")
        print("❌ groq")
    
    try:
        import whisper
        print("βœ… openai-whisper")
    except ImportError as e:
        failed_imports.append(f"openai-whisper: {e}")
        print("❌ openai-whisper")
    
    try:
        import pydub
        print("βœ… pydub")
    except ImportError as e:
        failed_imports.append(f"pydub: {e}")
        print("❌ pydub")
    
    try:
        import soundfile
        print("βœ… soundfile")
    except ImportError as e:
        failed_imports.append(f"soundfile: {e}")
        print("❌ soundfile")
    
    try:
        import fitz  # PyMuPDF
        print("βœ… PyMuPDF")
    except ImportError as e:
        failed_imports.append(f"PyMuPDF: {e}")
        print("❌ PyMuPDF")
    
    try:
        import docx
        print("βœ… python-docx")
    except ImportError as e:
        failed_imports.append(f"python-docx: {e}")
        print("❌ python-docx")
    
    try:
        import reportlab
        print("βœ… reportlab")
    except ImportError as e:
        failed_imports.append(f"reportlab: {e}")
        print("❌ reportlab")
    
    try:
        import speech_recognition
        print("βœ… speechrecognition")
    except ImportError as e:
        failed_imports.append(f"speechrecognition: {e}")
        print("❌ speechrecognition")
    
    try:
        import matplotlib
        print("βœ… matplotlib")
    except ImportError as e:
        failed_imports.append(f"matplotlib: {e}")
        print("❌ matplotlib")
    
    try:
        import numpy
        print("βœ… numpy")
    except ImportError as e:
        failed_imports.append(f"numpy: {e}")
        print("❌ numpy")
    
    # Test module imports
    print("\nπŸ“¦ Testing custom modules...")
    
    try:
        import config
        print("βœ… config")
    except ImportError as e:
        failed_imports.append(f"config: {e}")
        print("❌ config")
    
    try:
        from modules.llm_handler import generate_coaching_question
        print("βœ… modules.llm_handler")
    except ImportError as e:
        failed_imports.append(f"modules.llm_handler: {e}")
        print("❌ modules.llm_handler")
    
    try:
        from modules.doc_processor import extract_text_from_document
        print("βœ… modules.doc_processor")
    except ImportError as e:
        failed_imports.append(f"modules.doc_processor: {e}")
        print("❌ modules.doc_processor")
    
    try:
        from modules.report_generator import generate_pdf_report
        print("βœ… modules.report_generator")
    except ImportError as e:
        failed_imports.append(f"modules.report_generator: {e}")
        print("❌ modules.report_generator")
    
    # Summary
    print("\n" + "="*50)
    if failed_imports:
        print(f"❌ {len(failed_imports)} import failures found:")
        for failure in failed_imports:
            print(f"   - {failure}")
        print("\n🚨 App may not work properly on Hugging Face!")
        return False
    else:
        print("βœ… All imports successful!")
        print("πŸš€ Ready for Hugging Face deployment!")
        return True

if __name__ == "__main__":
    success = test_imports()
    sys.exit(0 if success else 1)