forked from poppopjmp/VMDragonSlayer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_installation.py
More file actions
196 lines (159 loc) · 5.96 KB
/
verify_installation.py
File metadata and controls
196 lines (159 loc) · 5.96 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
#!/usr/bin/env python3
"""
VMDragonSlayer Installation Verification Script
===============================================
This script verifies that VMDragonSlayer is properly installed and configured.
It runs through all the critical components to ensure they work correctly.
"""
import sys
import os
from pathlib import Path
def test_basic_imports():
"""Test basic VMDragonSlayer imports."""
print("Testing basic imports...")
try:
from dragonslayer.core.orchestrator import Orchestrator, AnalysisType
print("✓ Core orchestrator imports successful")
return True
except ImportError as e:
print(f"✗ Import failed: {e}")
return False
def test_dependencies():
"""Test critical dependencies."""
print("\nTesting critical dependencies...")
# Test z3-solver
try:
import z3
solver = z3.Solver()
print("✓ z3-solver available and functional")
except Exception as e:
print(f"✗ z3-solver issue: {e}")
return False
# Test other core dependencies
dependencies = [
('numpy', 'numpy'),
('pandas', 'pandas'),
('pydantic', 'pydantic'),
('yaml', 'pyyaml'),
('psutil', 'psutil'),
('cryptography', 'cryptography'),
('requests', 'requests'),
]
for module, package in dependencies:
try:
__import__(module)
print(f"✓ {package} available")
except ImportError:
print(f"⚠ {package} not available (may be optional)")
return True
def test_orchestrator_creation():
"""Test orchestrator creation and basic functionality."""
print("\nTesting orchestrator creation...")
try:
from dragonslayer.core.orchestrator import Orchestrator, AnalysisType
orchestrator = Orchestrator()
print("✓ Orchestrator created successfully")
# Test analysis types
analysis_types = [t.value for t in AnalysisType]
print(f"✓ Available analysis types: {', '.join(analysis_types)}")
return True
except Exception as e:
print(f"✗ Orchestrator creation failed: {e}")
return False
def test_gpu_detection():
"""Test GPU detection and graceful fallback."""
print("\nTesting GPU detection...")
try:
# Test PyTorch GPU detection
import torch
print(f"✓ PyTorch available: {torch.__version__}")
if torch.cuda.is_available():
print(f"✓ CUDA available: {torch.cuda.device_count()} devices")
print(f"✓ Current device: {torch.cuda.get_device_name()}")
else:
print("ℹ CUDA not available - CPU mode will be used")
except ImportError:
print("ℹ PyTorch not installed - ML features unavailable")
try:
# Test GPU module graceful handling
from dragonslayer.gpu import GPUEngine
print("✓ GPU module imports successfully (graceful fallback)")
except Exception as e:
print(f"⚠ GPU module issue: {e}")
return True
def test_configuration():
"""Test configuration system."""
print("\nTesting configuration system...")
try:
from dragonslayer.core.config import ConfigManager
config_manager = ConfigManager()
print("✓ ConfigManager available")
# Test config property (correct method)
config = config_manager.config
print("✓ Configuration loaded via .config property")
# Test section access
if hasattr(config, 'analysis'):
print("✓ Analysis configuration section available")
if hasattr(config, 'ml'):
print("✓ ML configuration section available")
return True
except Exception as e:
print(f"ℹ Configuration system: {e}")
return True # Not critical for basic functionality
def test_example_import():
"""Test that examples can be imported."""
print("\nTesting example scripts...")
example_dir = Path("examples")
if not example_dir.exists():
print("⚠ Examples directory not found")
return True
examples = list(example_dir.glob("*.py"))
print(f"✓ Found {len(examples)} example scripts")
for example in examples[:3]: # Test first 3 examples
try:
# Test syntax by compiling
with open(example, 'r') as f:
compile(f.read(), str(example), 'exec')
print(f"✓ {example.name} syntax OK")
except Exception as e:
print(f"⚠ {example.name} issue: {e}")
return True
def main():
"""Run all verification tests."""
print("VMDragonSlayer Installation Verification")
print("=" * 50)
tests = [
test_basic_imports,
test_dependencies,
test_orchestrator_creation,
test_gpu_detection,
test_configuration,
test_example_import,
]
passed = 0
total = len(tests)
for test in tests:
try:
if test():
passed += 1
except Exception as e:
print(f"✗ Test {test.__name__} failed with exception: {e}")
print("\n" + "=" * 50)
print(f"VERIFICATION RESULTS: {passed}/{total} tests passed")
if passed == total:
print("✓ VMDragonSlayer is properly installed and configured!")
print("\nYou can now:")
print(" • Run the examples in examples/ directory")
print(" • Use the Direct API for analysis")
print(" • Read INSTALLATION.md for advanced setup")
return True
else:
print("⚠ Some issues detected. Check the output above.")
print("\nFor help:")
print(" • Check INSTALLATION.md for troubleshooting")
print(" • Ensure all dependencies are installed")
print(" • Try: pip install -r requirements.txt")
return False
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)