File size: 5,665 Bytes
ab4e093
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
Quick fix script to check and resolve import issues
"""

import sys
import importlib
from pathlib import Path

def check_imports():
    """Check if all required modules can be imported"""
    
    print("πŸ” Checking imports...")
    
    # Core Python modules
    core_modules = [
        'os', 'sys', 'asyncio', 'logging', 'uuid', 'json', 'shutil',
        'pathlib', 'datetime', 'typing'
    ]
    
    # FastAPI modules
    fastapi_modules = [
        'fastapi', 'uvicorn', 'pydantic'
    ]
    
    # ML modules
    ml_modules = [
        'torch', 'transformers', 'datasets', 'safetensors'
    ]
    
    # Utility modules
    utility_modules = [
        'numpy', 'pillow', 'requests', 'psutil', 'cryptography'
    ]
    
    # Optional modules
    optional_modules = [
        'cv2', 'pydicom', 'SimpleITK', 'intel_extension_for_pytorch'
    ]
    
    all_good = True
    
    # Check core modules
    print("\nπŸ“¦ Core Python modules:")
    for module in core_modules:
        try:
            importlib.import_module(module)
            print(f"  βœ… {module}")
        except ImportError as e:
            print(f"  ❌ {module}: {e}")
            all_good = False
    
    # Check FastAPI modules
    print("\n🌐 FastAPI modules:")
    for module in fastapi_modules:
        try:
            importlib.import_module(module)
            print(f"  βœ… {module}")
        except ImportError as e:
            print(f"  ❌ {module}: {e}")
            all_good = False
    
    # Check ML modules
    print("\nπŸ€– Machine Learning modules:")
    for module in ml_modules:
        try:
            importlib.import_module(module)
            print(f"  βœ… {module}")
        except ImportError as e:
            print(f"  ❌ {module}: {e}")
            all_good = False
    
    # Check utility modules
    print("\nπŸ”§ Utility modules:")
    for module in utility_modules:
        try:
            if module == 'pillow':
                importlib.import_module('PIL')
            elif module == 'opencv-python':
                importlib.import_module('cv2')
            else:
                importlib.import_module(module)
            print(f"  βœ… {module}")
        except ImportError as e:
            print(f"  ❌ {module}: {e}")
            all_good = False
    
    # Check optional modules
    print("\nπŸ” Optional modules:")
    for module in optional_modules:
        try:
            importlib.import_module(module)
            print(f"  βœ… {module}")
        except ImportError as e:
            print(f"  ⚠️  {module}: {e} (optional)")
    
    return all_good

def check_custom_modules():
    """Check if custom modules can be imported"""
    
    print("\nπŸ—οΈ  Custom modules:")
    
    custom_modules = [
        'src.model_loader',
        'src.distillation', 
        'src.utils',
        'src.core.memory_manager',
        'src.core.chunk_loader',
        'src.core.cpu_optimizer',
        'src.core.token_manager',
        'src.medical.medical_datasets',
        'src.medical.dicom_handler',
        'src.medical.medical_preprocessing',
        'database.database',
        'database.models'
    ]
    
    all_good = True
    
    for module in custom_modules:
        try:
            importlib.import_module(module)
            print(f"  βœ… {module}")
        except ImportError as e:
            print(f"  ❌ {module}: {e}")
            all_good = False
        except Exception as e:
            print(f"  ⚠️  {module}: {e} (import error)")
            all_good = False
    
    return all_good

def check_files():
    """Check if required files exist"""
    
    print("\nπŸ“ Required files:")
    
    required_files = [
        'app.py',
        'requirements.txt',
        'src/__init__.py',
        'src/model_loader.py',
        'src/distillation.py',
        'src/utils.py',
        'src/core/__init__.py',
        'src/medical/__init__.py',
        'database/__init__.py',
        'templates/index.html',
        'templates/token-management.html',
        'templates/medical-datasets.html',
        'static/css/style.css',
        'static/js/main.js'
    ]
    
    all_good = True
    
    for file_path in required_files:
        path = Path(file_path)
        if path.exists():
            print(f"  βœ… {file_path}")
        else:
            print(f"  ❌ {file_path}")
            all_good = False
    
    return all_good

def main():
    """Main function"""
    
    print("πŸš€ AI Knowledge Distillation Platform - Import Checker")
    print("=" * 60)
    
    # Check imports
    imports_ok = check_imports()
    
    # Check custom modules
    custom_ok = check_custom_modules()
    
    # Check files
    files_ok = check_files()
    
    print("\n" + "=" * 60)
    
    if imports_ok and custom_ok and files_ok:
        print("βœ… All checks passed! The application should start successfully.")
        return 0
    else:
        print("❌ Some checks failed. Please fix the issues above.")
        
        if not imports_ok:
            print("\nπŸ’‘ To fix import issues:")
            print("   pip install -r requirements.txt")
        
        if not custom_ok:
            print("\nπŸ’‘ To fix custom module issues:")
            print("   Check that all Python files are properly created")
            print("   Ensure __init__.py files exist in all directories")
        
        if not files_ok:
            print("\nπŸ’‘ To fix missing files:")
            print("   Ensure all required files are created")
            print("   Check templates and static directories")
        
        return 1

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