-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate_implementation.py
More file actions
249 lines (211 loc) · 7.06 KB
/
validate_implementation.py
File metadata and controls
249 lines (211 loc) · 7.06 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
#!/usr/bin/env python3
"""
Manual validation script for MedRAG enhancements.
Tests functionality without requiring full dependencies.
"""
import os
import sys
from pathlib import Path
print("="*80)
print("MedRAG Enhancements - Manual Validation")
print("="*80)
# Test 1: File existence
print("\n1. Checking file existence...")
files_to_check = [
'src/load_zip_dataset.py',
'src/models_with_yolo.py',
'src/demo_rag_vfl_with_zip.py',
'docs/USING_YOUR_XRAY_ZIP.md',
'tests/test_zip_and_yolo.py',
'requirements.txt',
'README.md',
]
all_exist = True
for file_path in files_to_check:
exists = os.path.exists(file_path)
status = "✓" if exists else "✗"
print(f" {status} {file_path}")
if not exists:
all_exist = False
if not all_exist:
print("\n✗ Some files are missing!")
sys.exit(1)
else:
print("\n✓ All required files exist")
# Test 2: Python syntax
print("\n2. Checking Python syntax...")
import py_compile
python_files = [
'src/load_zip_dataset.py',
'src/models_with_yolo.py',
'src/demo_rag_vfl_with_zip.py',
'tests/test_zip_and_yolo.py',
]
all_valid = True
for file_path in python_files:
try:
py_compile.compile(file_path, doraise=True)
print(f" ✓ {file_path}")
except py_compile.PyCompileError as e:
print(f" ✗ {file_path}: {e}")
all_valid = False
if not all_valid:
print("\n✗ Some files have syntax errors!")
sys.exit(1)
else:
print("\n✓ All Python files have valid syntax")
# Test 3: Backward compatibility
print("\n3. Checking backward compatibility (original files unchanged)...")
original_files = [
'src/demo_rag_vfl.py',
'src/models.py',
'prepare_dataset.py',
]
all_valid = True
for file_path in original_files:
try:
py_compile.compile(file_path, doraise=True)
print(f" ✓ {file_path}")
except py_compile.PyCompileError as e:
print(f" ✗ {file_path}: {e}")
all_valid = False
if not all_valid:
print("\n✗ Backward compatibility broken!")
sys.exit(1)
else:
print("\n✓ Backward compatibility maintained")
# Test 4: Check documentation
print("\n4. Checking documentation...")
doc_file = 'docs/USING_YOUR_XRAY_ZIP.md'
with open(doc_file, 'r') as f:
content = f.read()
def check_hospital_mentions(text):
"""Check if hospital naming is mentioned in various formats."""
text_lower = text.lower()
hospital_variants = [
'hospital a', 'hospital b', 'hospital c', 'hospital d',
'hospitala', 'hospitalb', 'hospitalc', 'hospitald'
]
return any(variant in text_lower for variant in hospital_variants)
checks = [
('Hospital A, B, C, D mentioned', check_hospital_mentions(content)),
('YOLO mentioned', 'YOLO' in content or 'yolo' in content),
('ZIP mentioned', 'ZIP' in content or 'zip' in content),
('load_zip_dataset.py mentioned', 'load_zip_dataset.py' in content),
('demo_rag_vfl_with_zip.py mentioned', 'demo_rag_vfl_with_zip.py' in content),
]
all_checks = True
for check_name, result in checks:
status = "✓" if result else "✗"
print(f" {status} {check_name}")
if not result:
all_checks = False
if not all_checks:
print("\n✗ Documentation incomplete!")
sys.exit(1)
else:
print("\n✓ Documentation complete")
# Test 5: Check README updates
print("\n5. Checking README updates...")
with open('README.md', 'r') as f:
readme = f.read()
readme_checks = [
('ZIP dataset support mentioned', 'ZIP' in readme or 'zip' in readme),
('YOLO mentioned', 'YOLO' in readme or 'yolo' in readme),
('Hospital naming mentioned', 'Hospital' in readme),
('New documentation link', 'USING_YOUR_XRAY_ZIP.md' in readme),
]
all_checks = True
for check_name, result in readme_checks:
status = "✓" if result else "✗"
print(f" {status} {check_name}")
if not result:
all_checks = False
if not all_checks:
print("\n✗ README not fully updated!")
sys.exit(1)
else:
print("\n✓ README properly updated")
# Test 6: Check requirements.txt
print("\n6. Checking requirements.txt...")
with open('requirements.txt', 'r') as f:
requirements = f.read()
req_checks = [
('ultralytics added', 'ultralytics' in requirements),
('opencv-python added', 'opencv-python' in requirements),
]
all_checks = True
for check_name, result in req_checks:
status = "✓" if result else "✗"
print(f" {status} {check_name}")
if not result:
all_checks = False
if not all_checks:
print("\n✗ Requirements not fully updated!")
sys.exit(1)
else:
print("\n✓ Requirements properly updated")
# Test 7: Content verification
print("\n7. Verifying key content...")
# Check load_zip_dataset.py
with open('src/load_zip_dataset.py', 'r') as f:
loader_content = f.read()
loader_checks = [
('Hospital naming (A, B, C, D)', 'hospitalA' in loader_content or "hospital{hospital_id}" in loader_content),
('ZIP extraction', 'zipfile' in loader_content),
('Image classification', 'classify_image' in loader_content),
('Progress tracking', 'tqdm' in loader_content or 'print_summary' in loader_content),
]
all_checks = True
for check_name, result in loader_checks:
status = "✓" if result else "✗"
print(f" {status} ZIP Loader: {check_name}")
if not result:
all_checks = False
# Check models_with_yolo.py
with open('src/models_with_yolo.py', 'r') as f:
models_content = f.read()
models_checks = [
('YOLOv5 support', 'yolov5' in models_content or 'YOLOv5' in models_content),
('YOLOv8 support', 'yolov8' in models_content or 'YOLOv8' in models_content),
('Hybrid ResNet+YOLO', 'ClientModelResNetYOLO' in models_content),
('64-dim embeddings', 'embedding_dim=64' in models_content),
('create_client_model function', 'def create_client_model' in models_content),
]
for check_name, result in models_checks:
status = "✓" if result else "✗"
print(f" {status} YOLO Models: {check_name}")
if not result:
all_checks = False
# Check demo_rag_vfl_with_zip.py
with open('src/demo_rag_vfl_with_zip.py', 'r') as f:
demo_content = f.read()
demo_checks = [
('Hospital naming', 'hospitalA' in demo_content or 'hospital{hospital_id}' in demo_content),
('YOLO model support', 'yolo5' in demo_content or 'yolo8' in demo_content),
('Backward compatible paths', 'client{i}' in demo_content),
('Model comparison', 'compare_models' in demo_content),
]
for check_name, result in demo_checks:
status = "✓" if result else "✗"
print(f" {status} Demo Script: {check_name}")
if not result:
all_checks = False
if not all_checks:
print("\n✗ Content verification failed!")
sys.exit(1)
else:
print("\n✓ Content verification passed")
# Final summary
print("\n" + "="*80)
print("VALIDATION SUMMARY")
print("="*80)
print("✓ All files exist")
print("✓ All Python files have valid syntax")
print("✓ Backward compatibility maintained")
print("✓ Documentation complete")
print("✓ Requirements updated")
print("✓ Content verified")
print("\n✅ All manual validation checks passed!")
print("="*80)
sys.exit(0)