-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathvalidate.py
More file actions
158 lines (120 loc) · 3.82 KB
/
validate.py
File metadata and controls
158 lines (120 loc) · 3.82 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
#!/usr/bin/env python3
"""
Validation script to verify all modules load correctly.
Run this after installation to check the setup.
"""
import sys
from typing import List
def validate_imports() -> List[str]:
"""Validate all module imports."""
errors = []
print("Validating imports...")
# Core modules
try:
import models # noqa: F401
print("✓ models")
except Exception as e:
errors.append(f"models: {e}")
print(f"✗ models: {e}")
try:
import services # noqa: F401
print("✓ services")
except Exception as e:
errors.append(f"services: {e}")
print(f"✗ services: {e}")
try:
import utils # noqa: F401
print("✓ utils")
except Exception as e:
errors.append(f"utils: {e}")
print(f"✗ utils: {e}")
return errors
def validate_models() -> List[str]:
"""Validate Pydantic models."""
errors = []
print("\nValidating Pydantic models...")
try:
from models import Monitor, BoundingBox, AppConfig, DetectionResult, ButtonType
# Test Monitor
mon = Monitor(x=0, y=0, width=1920, height=1080)
assert mon.aspect_ratio > 1.7
print("✓ Monitor model")
# Test BoundingBox
bbox = BoundingBox(x1=0, y1=0, x2=100, y2=100)
padded = bbox.pad(0.1)
assert padded.width < bbox.width
print("✓ BoundingBox model")
# Test AppConfig
config = AppConfig(vortex=True, verbose=False)
assert config.min_matches == 8
print("✓ AppConfig model")
# Test DetectionResult
result = DetectionResult(
button_type=ButtonType.VORTEX, x=100, y=200, confidence=0.95, num_matches=15
)
assert result.confidence < 1.0
print("✓ DetectionResult model")
except Exception as e:
errors.append(f"Model validation: {e}")
print(f"✗ Model validation: {e}")
return errors
def validate_assets() -> List[str]:
"""Validate asset files exist."""
errors = []
print("\nValidating assets...")
from pathlib import Path
required_assets = [
"VortexDownloadButton.png",
"WebsiteDownloadButton.png",
"WabbajackDownloadButton.png",
"ClickHereButton.png",
"UnderstoodButton.png",
"StagingButton.png",
]
optional_assets = [
"VortexDownloadButtonNew.png",
"WebsiteDownloadButtonNew.png",
]
assets_path = Path("assets")
if not assets_path.exists():
errors.append("assets/ directory not found")
print("✗ assets/ directory not found")
return errors
for asset in required_assets:
asset_path = assets_path / asset
if asset_path.exists():
print(f"✓ {asset}")
else:
errors.append(f"Missing asset: {asset}")
print(f"✗ Missing asset: {asset}")
for asset in optional_assets:
asset_path = assets_path / asset
if asset_path.exists():
print(f"✓ {asset} (optional)")
else:
print(f"- Optional asset not found: {asset}")
return errors
def main() -> int:
"""Run all validations."""
print("=" * 60)
print("NexusAutoDL Validation Script")
print("=" * 60)
all_errors = []
# Run validations
all_errors.extend(validate_imports())
all_errors.extend(validate_models())
all_errors.extend(validate_assets())
# Summary
print("\n" + "=" * 60)
if all_errors:
print(f"❌ Validation FAILED with {len(all_errors)} error(s):")
for error in all_errors:
print(f" - {error}")
return 1
else:
print("✅ All validations PASSED!")
print("\nYou can now run:")
print(" python main.py --help")
return 0
if __name__ == "__main__":
sys.exit(main())