-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_checkpoint.py
More file actions
168 lines (138 loc) · 5.58 KB
/
test_checkpoint.py
File metadata and controls
168 lines (138 loc) · 5.58 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
#!/usr/bin/env python3
"""
Checkpoint Test - Comprehensive test suite for IREE Docker Integration.
This test verifies that basic Docker compilation is ready to work.
"""
import subprocess
import sys
from pathlib import Path
def run_test_suite(test_file: str, description: str) -> bool:
"""Run a test suite and return success status."""
print(f"\n{'='*60}")
print(f"Running {description}")
print(f"{'='*60}")
try:
result = subprocess.run([
"uv", "run", "python", test_file
], cwd=".")
return result.returncode == 0
except Exception as e:
print(f"Failed to run {test_file}: {e}")
return False
def test_project_structure():
"""Test that all required project files exist."""
print("\n=== Testing Project Structure ===")
required_files = [
"pyproject.toml",
"docker/cuda/Dockerfile",
"docker/cuda/scripts/compile.sh",
"docker/cuda/scripts/validate.sh",
"docker/cuda/scripts/benchmark.sh",
"iree_docker_integration/__init__.py",
"iree_docker_integration/cli.py",
"iree_docker_integration/config_validator.py",
"iree_docker_integration/docker_manager.py",
"iree_docker_integration/file_handler.py",
"input/test_model.mlir",
"docker-compose.yml"
]
missing_files = []
for file_path in required_files:
if not Path(file_path).exists():
missing_files.append(file_path)
if missing_files:
print("✗ Missing required files:")
for file_path in missing_files:
print(f" - {file_path}")
return False
print(f"✓ All {len(required_files)} required files exist")
return True
def test_python_environment():
"""Test that the Python environment is properly set up."""
print("\n=== Testing Python Environment ===")
try:
# Test uv is available
result = subprocess.run(["uv", "--version"], capture_output=True, text=True)
if result.returncode != 0:
print("✗ uv is not available")
return False
print(f"✓ uv is available: {result.stdout.strip()}")
# Test dependencies are installed
result = subprocess.run(["uv", "run", "python", "-c",
"import jsonschema, pydantic, click, docker; print('All dependencies available')"],
capture_output=True, text=True)
if result.returncode != 0:
print(f"✗ Dependencies not available: {result.stderr}")
return False
print("✓ All Python dependencies are available")
return True
except Exception as e:
print(f"✗ Python environment test failed: {e}")
return False
def main():
"""Run the complete checkpoint test suite."""
print("="*80)
print("IREE DOCKER INTEGRATION - CHECKPOINT TEST")
print("="*80)
print("This test verifies that basic Docker compilation is ready to work.")
print("All components will be tested except actual Docker execution.")
# Test suites to run
test_suites = [
("test_basic_integration.py", "Basic Integration Tests"),
("test_compilation_readiness.py", "Compilation Readiness Tests")
]
# Individual tests
individual_tests = [
(test_project_structure, "Project Structure"),
(test_python_environment, "Python Environment")
]
passed_suites = 0
total_suites = len(test_suites)
passed_individual = 0
total_individual = len(individual_tests)
# Run individual tests
print(f"\n{'='*60}")
print("Running Individual Tests")
print(f"{'='*60}")
for test_func, description in individual_tests:
try:
if test_func():
passed_individual += 1
print(f"✓ {description} - PASSED")
else:
print(f"✗ {description} - FAILED")
except Exception as e:
print(f"✗ {description} - CRASHED: {e}")
# Run test suites
for test_file, description in test_suites:
if run_test_suite(test_file, description):
passed_suites += 1
print(f"✓ {description} - PASSED")
else:
print(f"✗ {description} - FAILED")
# Final results
print(f"\n{'='*80}")
print("CHECKPOINT TEST RESULTS")
print(f"{'='*80}")
print(f"Individual Tests: {passed_individual}/{total_individual}")
print(f"Test Suites: {passed_suites}/{total_suites}")
print(f"Overall: {passed_individual + passed_suites}/{total_individual + total_suites}")
if passed_individual == total_individual and passed_suites == total_suites:
print("\n🎉 ALL TESTS PASSED! 🎉")
print("\n✅ CHECKPOINT COMPLETE - Basic Docker compilation is ready!")
print("\n📋 Next Steps:")
print(" 1. Start Docker daemon if not running")
print(" 2. Build the Docker image:")
print(" docker build -t iree-compiler:cuda-latest docker/cuda/")
print(" 3. Test actual compilation:")
print(" uv run iree-docker-compile compile --input input/test_model.mlir --target cuda")
print("\n🚀 The IREE Docker Integration system is ready for use!")
return True
else:
print("\n❌ SOME TESTS FAILED")
print("\n⚠️ The system may not be ready for Docker compilation.")
print(" Please review the failed tests above and fix any issues.")
return False
if __name__ == "__main__":
success = main()
exit(0 if success else 1)