Ahmedik95316 commited on
Commit
2e222e5
Β·
1 Parent(s): b4620ce

Update docker_validation.py

Browse files
Files changed (1) hide show
  1. docker_validation.py +89 -12
docker_validation.py CHANGED
@@ -1,12 +1,89 @@
1
- # Create path_config.py
2
- cat > path_config.py << 'EOF'
3
- # [PASTE THE ENTIRE CONTENT FROM THE "Dynamic Path Configuration System" ARTIFACT HERE]
4
- EOF
5
-
6
- # Create docker_validation.py
7
- cat > docker_validation.py << 'EOF'
8
- # [PASTE THE ENTIRE CONTENT FROM THE "Docker Build Validation Script" ARTIFACT HERE]
9
- EOF
10
-
11
- # Make validation script executable
12
- chmod +x docker_validation.py
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Docker build validation script
4
+ Validates that the system is properly set up during container build
5
+ """
6
+
7
+ import sys
8
+ import os
9
+
10
+ # Add app directory to Python path
11
+ sys.path.append('/app')
12
+
13
+ def main():
14
+ """Main validation function"""
15
+ print("πŸ” Starting Docker build validation...")
16
+
17
+ try:
18
+ # Test path manager import
19
+ from path_config import path_manager
20
+ print(f"βœ… Path manager imported successfully")
21
+
22
+ # Display environment information
23
+ print(f"🌍 Container environment: {path_manager.environment}")
24
+ print(f"πŸ“ Base directory: {path_manager.base_paths['base']}")
25
+ print(f"πŸ“Š Data directory: {path_manager.base_paths['data']}")
26
+ print(f"πŸ€– Model directory: {path_manager.base_paths['model']}")
27
+ print(f"πŸ“ Logs directory: {path_manager.base_paths['logs']}")
28
+
29
+ # Check critical files
30
+ print("\nπŸ” Checking critical files...")
31
+ critical_files = [
32
+ (path_manager.get_combined_dataset_path(), "Combined Dataset"),
33
+ (path_manager.get_model_file_path(), "Model File"),
34
+ (path_manager.get_vectorizer_path(), "Vectorizer File"),
35
+ (path_manager.get_metadata_path(), "Metadata File")
36
+ ]
37
+
38
+ files_found = 0
39
+ for file_path, description in critical_files:
40
+ if file_path.exists():
41
+ print(f"βœ… {description}: {file_path}")
42
+ files_found += 1
43
+ else:
44
+ print(f"❌ {description}: {file_path}")
45
+
46
+ # Test critical imports
47
+ print("\n🐍 Testing Python imports...")
48
+ imports_to_test = [
49
+ ('pandas', 'Data processing'),
50
+ ('sklearn', 'Machine learning'),
51
+ ('streamlit', 'Web interface'),
52
+ ('fastapi', 'API framework'),
53
+ ('numpy', 'Numerical computing'),
54
+ ('requests', 'HTTP client')
55
+ ]
56
+
57
+ import_success = 0
58
+ for module_name, description in imports_to_test:
59
+ try:
60
+ __import__(module_name)
61
+ print(f"βœ… {description} ({module_name})")
62
+ import_success += 1
63
+ except ImportError as e:
64
+ print(f"❌ {description} ({module_name}): {e}")
65
+
66
+ # Summary
67
+ print(f"\nπŸ“Š Validation Summary:")
68
+ print(f" Files found: {files_found}/{len(critical_files)}")
69
+ print(f" Imports successful: {import_success}/{len(imports_to_test)}")
70
+
71
+ # Determine overall status
72
+ if files_found >= 3 and import_success == len(imports_to_test):
73
+ print("πŸŽ‰ Docker build validation PASSED")
74
+ return 0
75
+ elif files_found >= 2 and import_success >= len(imports_to_test) - 1:
76
+ print("⚠️ Docker build validation PASSED with warnings")
77
+ return 0
78
+ else:
79
+ print("❌ Docker build validation FAILED")
80
+ return 1
81
+
82
+ except Exception as e:
83
+ print(f"❌ Docker build validation ERROR: {e}")
84
+ import traceback
85
+ print(f"Traceback: {traceback.format_exc()}")
86
+ return 1
87
+
88
+ if __name__ == "__main__":
89
+ sys.exit(main())