forked from togethercomputer/MoA
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_installation.py
More file actions
194 lines (165 loc) · 5.01 KB
/
test_installation.py
File metadata and controls
194 lines (165 loc) · 5.01 KB
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
#!/usr/bin/env python
"""Test script to verify all dependencies are installed and working on Windows."""
import sys
def test_imports():
"""Test all critical imports."""
print("Testing imports...")
try:
import flask
try:
version = flask.__version__
print(f"[OK] Flask {version}")
except AttributeError:
print("[OK] Flask")
except ImportError as e:
print(f"[FAIL] Flask: {e}")
return False
try:
import werkzeug
try:
version = werkzeug.__version__
print(f"[OK] Werkzeug {version}")
except AttributeError:
print("[OK] Werkzeug")
except ImportError as e:
print(f"[FAIL] Werkzeug: {e}")
return False
try:
import fitz # PyMuPDF
print("[OK] PyMuPDF (fitz)")
except ImportError as e:
print(f"[FAIL] PyMuPDF: {e}")
return False
try:
import docx
print("[OK] python-docx")
except ImportError as e:
print(f"[FAIL] python-docx: {e}")
return False
try:
import openai
print(f"[OK] openai {openai.__version__}")
except ImportError as e:
print(f"[FAIL] openai: {e}")
return False
try:
import fire
print("[OK] fire")
except ImportError as e:
print(f"[FAIL] fire: {e}")
return False
try:
import loguru
print("[OK] loguru")
except ImportError as e:
print(f"[FAIL] loguru: {e}")
return False
try:
import datasets
print(f"[OK] datasets {datasets.__version__}")
except ImportError as e:
print(f"[FAIL] datasets: {e}")
return False
try:
import typer
print("[OK] typer")
except ImportError as e:
print(f"[FAIL] typer: {e}")
return False
try:
import rich
try:
version = rich.__version__
print(f"[OK] rich {version}")
except AttributeError:
print("[OK] rich")
except ImportError as e:
print(f"[FAIL] rich: {e}")
return False
try:
import dotenv
print("[OK] python-dotenv")
except ImportError as e:
print(f"[FAIL] python-dotenv: {e}")
return False
try:
import requests
print(f"[OK] requests {requests.__version__}")
except ImportError as e:
print(f"[FAIL] requests: {e}")
return False
try:
from flask_sqlalchemy import SQLAlchemy
print("[OK] Flask-SQLAlchemy")
except ImportError as e:
print(f"[FAIL] Flask-SQLAlchemy: {e}")
return False
try:
# Apply compatibility fix before importing
import werkzeug
if not hasattr(werkzeug, 'secure_filename'):
from werkzeug.utils import secure_filename as _secure_filename
werkzeug.secure_filename = _secure_filename
if not hasattr(werkzeug, 'FileStorage'):
from werkzeug.datastructures import FileStorage
werkzeug.FileStorage = FileStorage
from flask_uploads import UploadSet
print("[OK] Flask-Uploads")
except ImportError as e:
print(f"[FAIL] Flask-Uploads: {e}")
return False
try:
from flask_migrate import Migrate
print("[OK] Flask-Migrate")
except ImportError as e:
print(f"[FAIL] Flask-Migrate: {e}")
return False
return True
def test_app():
"""Test Flask app import."""
print("\nTesting Flask app...")
try:
from app import app
print("[OK] Flask app imports successfully")
print(f"[OK] App name: {app.name}")
return True
except Exception as e:
print(f"[FAIL] Flask app import failed: {e}")
import traceback
traceback.print_exc()
return False
def test_directories():
"""Test required directories exist."""
import os
print("\nTesting directories...")
dirs = ['instance', 'uploads']
all_exist = True
for dir_name in dirs:
if os.path.exists(dir_name):
print(f"[OK] {dir_name}/ exists")
else:
print(f"[FAIL] {dir_name}/ missing")
all_exist = False
return all_exist
if __name__ == "__main__":
print("=" * 50)
print("MoA Groq Chatbot - Installation Test")
print("=" * 50)
print(f"Python version: {sys.version}")
print(f"Platform: {sys.platform}")
print("=" * 50)
success = True
success &= test_imports()
success &= test_directories()
success &= test_app()
print("\n" + "=" * 50)
if success:
print("[OK] All tests passed! Installation is complete.")
print("You can now run the application using:")
print(" - python app.py")
print(" - run.bat (Windows)")
print(" - .\\run.ps1 (PowerShell)")
else:
print("[FAIL] Some tests failed. Please check the errors above.")
print("=" * 50)
sys.exit(0 if success else 1)