|
| 1 | +#!/usr/bin/env python3 |
| 2 | +""" |
| 3 | +Complete project verification script |
| 4 | +Checks all components and ensures the project is fully functional |
| 5 | +""" |
| 6 | + |
| 7 | +import os |
| 8 | +import sys |
| 9 | +from pathlib import Path |
| 10 | +import importlib.util |
| 11 | +import subprocess |
| 12 | + |
| 13 | +class Colors: |
| 14 | + GREEN = '\033[0;32m' |
| 15 | + RED = '\033[0;31m' |
| 16 | + YELLOW = '\033[1;33m' |
| 17 | + BLUE = '\033[0;34m' |
| 18 | + NC = '\033[0m' |
| 19 | + |
| 20 | +def print_header(text): |
| 21 | + print(f"\n{Colors.BLUE}{'='*60}{Colors.NC}") |
| 22 | + print(f"{Colors.BLUE}{text}{Colors.NC}") |
| 23 | + print(f"{Colors.BLUE}{'='*60}{Colors.NC}") |
| 24 | + |
| 25 | +def print_success(text): |
| 26 | + print(f"{Colors.GREEN}✓ {text}{Colors.NC}") |
| 27 | + |
| 28 | +def print_error(text): |
| 29 | + print(f"{Colors.RED}✗ {text}{Colors.NC}") |
| 30 | + |
| 31 | +def print_warning(text): |
| 32 | + print(f"{Colors.YELLOW}⚠ {text}{Colors.NC}") |
| 33 | + |
| 34 | +def check_file_exists(filepath): |
| 35 | + """Check if file exists""" |
| 36 | + if Path(filepath).exists(): |
| 37 | + print_success(f"{filepath}") |
| 38 | + return True |
| 39 | + else: |
| 40 | + print_error(f"{filepath} - MISSING") |
| 41 | + return False |
| 42 | + |
| 43 | +def check_python_import(module_path): |
| 44 | + """Check if Python module can be imported""" |
| 45 | + try: |
| 46 | + module = importlib.import_module(module_path) |
| 47 | + print_success(f"Import: {module_path}") |
| 48 | + return True |
| 49 | + except Exception as e: |
| 50 | + print_error(f"Import: {module_path} - {str(e)[:50]}") |
| 51 | + return False |
| 52 | + |
| 53 | +def main(): |
| 54 | + print_header("Distributed Training Framework - Complete Verification") |
| 55 | + |
| 56 | + all_checks = [] |
| 57 | + |
| 58 | + # Check 1: Core Source Files |
| 59 | + print_header("1. Checking Core Source Files") |
| 60 | + core_files = [ |
| 61 | + "src/__init__.py", |
| 62 | + "src/core/__init__.py", |
| 63 | + "src/core/distributed_training.py", |
| 64 | + "src/core/enhanced_trainer.py", |
| 65 | + "src/core/communication_optimizer.py", |
| 66 | + "src/monitoring/__init__.py", |
| 67 | + "src/monitoring/monitoring_dashboard.py", |
| 68 | + "src/monitoring/health_monitoring.py", |
| 69 | + "src/monitoring/logging_config.py", |
| 70 | + "src/config/__init__.py", |
| 71 | + "src/config/config_manager.py", |
| 72 | + "src/utils/__init__.py", |
| 73 | + "src/utils/helpers.py", |
| 74 | + "src/utils/dataset.py", |
| 75 | + ] |
| 76 | + core_check = all(check_file_exists(f) for f in core_files) |
| 77 | + all_checks.append(("Core Source Files", core_check)) |
| 78 | + |
| 79 | + # Check 2: Scripts |
| 80 | + print_header("2. Checking Scripts") |
| 81 | + scripts = [ |
| 82 | + "scripts/__init__.py", |
| 83 | + "scripts/production_train.py", |
| 84 | + "scripts/launch_training.sh", |
| 85 | + "scripts/setup_environment.sh", |
| 86 | + "scripts/create_project_structure.sh", |
| 87 | + "scripts/generate_dummy_data.py", |
| 88 | + "scripts/quick_test.sh", |
| 89 | + ] |
| 90 | + scripts_check = all(check_file_exists(f) for f in scripts) |
| 91 | + all_checks.append(("Scripts", scripts_check)) |
| 92 | + |
| 93 | + # Check 3: Tests |
| 94 | + print_header("3. Checking Test Files") |
| 95 | + tests = [ |
| 96 | + "tests/__init__.py", |
| 97 | + "tests/test_distributed.py", |
| 98 | + "tests/test_integration.py", |
| 99 | + "tests/test_performance.py", |
| 100 | + ] |
| 101 | + tests_check = all(check_file_exists(f) for f in tests) |
| 102 | + all_checks.append(("Test Files", tests_check)) |
| 103 | + |
| 104 | + # Check 4: Configs |
| 105 | + print_header("4. Checking Configuration Files") |
| 106 | + configs = [ |
| 107 | + "configs/dev.yaml", |
| 108 | + "configs/staging.yaml", |
| 109 | + "configs/production.yaml", |
| 110 | + "configs/README.md", |
| 111 | + ] |
| 112 | + configs_check = all(check_file_exists(f) for f in configs) |
| 113 | + all_checks.append(("Config Files", configs_check)) |
| 114 | + |
| 115 | + # Check 5: Deployment |
| 116 | + print_header("5. Checking Deployment Files") |
| 117 | + deployment = [ |
| 118 | + "deployment/docker/Dockerfile", |
| 119 | + "deployment/docker/Dockerfile.dev", |
| 120 | + "deployment/docker/docker-compose.yml", |
| 121 | + "deployment/kubernetes/k8s-deployment.yaml", |
| 122 | + "deployment/kubernetes/k8s-service.yaml", |
| 123 | + "deployment/kubernetes/k8s-configmap.yaml", |
| 124 | + "deployment/kubernetes/helm/Chart.yaml", |
| 125 | + "deployment/kubernetes/helm/values.yaml", |
| 126 | + ] |
| 127 | + deployment_check = all(check_file_exists(f) for f in deployment) |
| 128 | + all_checks.append(("Deployment Files", deployment_check)) |
| 129 | + |
| 130 | + # Check 6: CI/CD |
| 131 | + print_header("6. Checking CI/CD Files") |
| 132 | + cicd = [ |
| 133 | + ".github/workflows/ci-cd.yml", |
| 134 | + ".github/workflows/tests.yml", |
| 135 | + ".github/workflows/security.yml", |
| 136 | + ] |
| 137 | + cicd_check = all(check_file_exists(f) for f in cicd) |
| 138 | + all_checks.append(("CI/CD Files", cicd_check)) |
| 139 | + |
| 140 | + # Check 7: Documentation |
| 141 | + print_header("7. Checking Documentation") |
| 142 | + docs = [ |
| 143 | + "README.md", |
| 144 | + "DOCS/SETUP_GUIDE.md", |
| 145 | + "DOCS/QUICK_REFERENCE.md", |
| 146 | + "DOCS/IMPLEMENTATION_CHECKLIST.md", |
| 147 | + "DOCS/PROJECT_DESCRIPTION.md", |
| 148 | + "DOCS/GETTING_STARTED.md", |
| 149 | + ] |
| 150 | + docs_check = all(check_file_exists(f) for f in docs) |
| 151 | + all_checks.append(("Documentation", docs_check)) |
| 152 | + |
| 153 | + # Check 8: Data Structure |
| 154 | + print_header("8. Checking Data Structure") |
| 155 | + data_files = [ |
| 156 | + "data/README.md", |
| 157 | + "data/train/metadata.json", |
| 158 | + "data/val/metadata.json", |
| 159 | + ] |
| 160 | + data_check = all(check_file_exists(f) for f in data_files) |
| 161 | + all_checks.append(("Data Structure", data_check)) |
| 162 | + |
| 163 | + # Check 9: Benchmark Files |
| 164 | + print_header("9. Checking Benchmark Files") |
| 165 | + benchmark_files = [ |
| 166 | + "benchmarks/__init__.py", |
| 167 | + "benchmarks/run_benchmark.py", |
| 168 | + "benchmarks/results/scalability_results.json", |
| 169 | + "benchmarks/results/benchmark_report.md", |
| 170 | + ] |
| 171 | + benchmark_check = all(check_file_exists(f) for f in benchmark_files) |
| 172 | + all_checks.append(("Benchmark Files", benchmark_check)) |
| 173 | + |
| 174 | + # Check 10: Python Imports |
| 175 | + print_header("10. Checking Python Imports") |
| 176 | + imports_to_check = [ |
| 177 | + "src", |
| 178 | + "src.core.distributed_training", |
| 179 | + "src.core.enhanced_trainer", |
| 180 | + "src.core.communication_optimizer", |
| 181 | + "src.monitoring.monitoring_dashboard", |
| 182 | + "src.monitoring.health_monitoring", |
| 183 | + "src.monitoring.logging_config", |
| 184 | + "src.config.config_manager", |
| 185 | + "src.utils.helpers", |
| 186 | + "src.utils.dataset", |
| 187 | + ] |
| 188 | + |
| 189 | + # Add src to path |
| 190 | + sys.path.insert(0, str(Path.cwd())) |
| 191 | + |
| 192 | + import_results = [] |
| 193 | + for module in imports_to_check: |
| 194 | + result = check_python_import(module) |
| 195 | + import_results.append(result) |
| 196 | + |
| 197 | + imports_check = all(import_results) |
| 198 | + all_checks.append(("Python Imports", imports_check)) |
| 199 | + |
| 200 | + # Check 11: Required Dependencies |
| 201 | + print_header("11. Checking Required Dependencies") |
| 202 | + try: |
| 203 | + import torch |
| 204 | + print_success(f"PyTorch {torch.__version__}") |
| 205 | + deps_check = True |
| 206 | + except ImportError: |
| 207 | + print_error("PyTorch not installed") |
| 208 | + deps_check = False |
| 209 | + |
| 210 | + all_checks.append(("Dependencies", deps_check)) |
| 211 | + |
| 212 | + # Summary |
| 213 | + print_header("VERIFICATION SUMMARY") |
| 214 | + |
| 215 | + total_checks = len(all_checks) |
| 216 | + passed_checks = sum(1 for _, result in all_checks if result) |
| 217 | + |
| 218 | + for check_name, result in all_checks: |
| 219 | + status = "PASS" if result else "FAIL" |
| 220 | + color = Colors.GREEN if result else Colors.RED |
| 221 | + print(f"{color}{status:6}{Colors.NC} - {check_name}") |
| 222 | + |
| 223 | + print(f"\n{Colors.BLUE}{'='*60}{Colors.NC}") |
| 224 | + percentage = (passed_checks / total_checks) * 100 |
| 225 | + |
| 226 | + if percentage == 100: |
| 227 | + print(f"{Colors.GREEN}✓ ALL CHECKS PASSED: {passed_checks}/{total_checks} ({percentage:.0f}%){Colors.NC}") |
| 228 | + print(f"{Colors.GREEN}✓ PROJECT IS FULLY FUNCTIONAL!{Colors.NC}") |
| 229 | + return_code = 0 |
| 230 | + elif percentage >= 80: |
| 231 | + print(f"{Colors.YELLOW}⚠ MOSTLY FUNCTIONAL: {passed_checks}/{total_checks} ({percentage:.0f}%){Colors.NC}") |
| 232 | + print(f"{Colors.YELLOW}Some components may need attention{Colors.NC}") |
| 233 | + return_code = 1 |
| 234 | + else: |
| 235 | + print(f"{Colors.RED}✗ NEEDS WORK: {passed_checks}/{total_checks} ({percentage:.0f}%){Colors.NC}") |
| 236 | + print(f"{Colors.RED}Multiple components are missing{Colors.NC}") |
| 237 | + return_code = 2 |
| 238 | + |
| 239 | + # Next Steps |
| 240 | + if percentage < 100: |
| 241 | + print(f"\n{Colors.YELLOW}Next Steps:{Colors.NC}") |
| 242 | + print("1. Run: python scripts/create_project_structure.sh") |
| 243 | + print("2. Run: pip install -e .") |
| 244 | + print("3. Run: python scripts/generate_dummy_data.py") |
| 245 | + else: |
| 246 | + print(f"\n{Colors.GREEN}Ready to use!{Colors.NC}") |
| 247 | + print("Quick test: ./scripts/quick_test.sh") |
| 248 | + print("Start training: python scripts/production_train.py") |
| 249 | + |
| 250 | + print(f"{Colors.BLUE}{'='*60}{Colors.NC}\n") |
| 251 | + |
| 252 | + return return_code |
| 253 | + |
| 254 | +if __name__ == "__main__": |
| 255 | + exit_code = main() |
| 256 | + sys.exit(exit_code) |
0 commit comments