File size: 7,036 Bytes
553fbf7 | 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 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | """
MINDI 1.5 Vision-Coder β Setup Validation Script
Comprehensive readiness check: environment, configs, directories,
API keys, GPU, and package imports.
"""
from __future__ import annotations
import importlib
import os
import sys
from pathlib import Path
# Ensure project root is on sys.path
PROJECT_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(PROJECT_ROOT))
def header(title: str) -> None:
print(f"\n{'='*50}")
print(f" {title}")
print(f"{'='*50}")
def check(label: str, passed: bool, detail: str = "") -> bool:
icon = "β
" if passed else "β"
msg = f" {icon} {label}"
if detail:
msg += f" β {detail}"
print(msg)
return passed
def validate_directories() -> int:
header("1. Directory Structure")
required_dirs = [
"configs", "src", "src/model", "src/agents", "src/search",
"src/sandbox", "src/training", "src/inference", "src/evaluation",
"src/tokenizer", "src/utils", "api", "api/routes", "api/middleware",
"scripts", "data", "data/raw", "data/processed", "data/knowledge_base",
"checkpoints", "logs", "tests", "docs", "frontend",
]
failures = 0
for d in required_dirs:
path = PROJECT_ROOT / d
if not check(d, path.is_dir()):
failures += 1
return failures
def validate_files() -> int:
header("2. Key Files")
required_files = [
".env", ".env.example", ".gitignore", "README.md",
"requirements.txt", "setup.py",
"configs/model_config.yaml", "configs/training_config.yaml",
"configs/data_config.yaml", "configs/search_config.yaml",
"src/__init__.py", "src/utils/__init__.py",
"src/utils/env_loader.py", "src/utils/config_loader.py",
"src/model/vision_encoder.py", "src/model/code_model.py",
"src/agents/orchestrator.py", "src/agents/ui_critic.py",
"src/agents/error_fixer.py", "src/search/search_agent.py",
"src/sandbox/sandbox_runner.py", "src/training/trainer.py",
"src/training/dataset.py", "src/inference/pipeline.py",
"src/evaluation/evaluator.py",
"api/main.py", "api/routes/generate.py", "api/middleware/auth.py",
"scripts/health_check.py", "scripts/train.py",
]
failures = 0
for f in required_files:
path = PROJECT_ROOT / f
if not check(f, path.is_file()):
failures += 1
return failures
def validate_env() -> int:
header("3. Environment Variables")
from src.utils.env_loader import EnvLoader
env = EnvLoader()
env.load()
result = env.validate()
failures = 0
required = ["HUGGINGFACE_TOKEN", "TAVILY_API_KEY", "WANDB_API_KEY", "E2B_API_KEY"]
for key in required:
value = os.environ.get(key, "")
if value:
masked = value[:8] + "..." + value[-4:]
check(key, True, masked)
else:
check(key, False, "NOT SET")
failures += 1
for w in result.warnings:
print(f" β οΈ {w}")
return failures
def validate_configs() -> int:
header("4. YAML Configurations")
from src.utils.config_loader import ConfigLoader
loader = ConfigLoader()
failures = 0
try:
m = loader.model
check("model_config.yaml", True, f"{m.name} v{m.version}")
except Exception as e:
check("model_config.yaml", False, str(e))
failures += 1
try:
t = loader.training
check("training_config.yaml", True, f"{t.epochs} epochs, lr={t.learning_rate}")
except Exception as e:
check("training_config.yaml", False, str(e))
failures += 1
try:
d = loader.data
check("data_config.yaml", True, f"{d.target_size:,} target samples")
except Exception as e:
check("data_config.yaml", False, str(e))
failures += 1
try:
s = loader.search
check("search_config.yaml", True, f"provider={s.provider}")
except Exception as e:
check("search_config.yaml", False, str(e))
failures += 1
return failures
def validate_packages() -> int:
header("5. Critical Package Imports")
packages = [
("torch", "PyTorch"),
("transformers", "HuggingFace Transformers"),
("peft", "PEFT (LoRA)"),
("datasets", "HuggingFace Datasets"),
("wandb", "Weights & Biases"),
("fastapi", "FastAPI"),
("httpx", "HTTPX"),
("PIL", "Pillow"),
("yaml", "PyYAML"),
("dotenv", "python-dotenv"),
("pydantic", "Pydantic"),
("playwright", "Playwright"),
]
failures = 0
for module, label in packages:
try:
importlib.import_module(module)
check(label, True)
except ImportError:
check(label, False, "not installed")
failures += 1
return failures
def validate_gpu() -> int:
header("6. GPU / CUDA")
failures = 0
try:
import torch
cuda_available = torch.cuda.is_available()
check("CUDA available", cuda_available)
if cuda_available:
gpu_name = torch.cuda.get_device_name(0)
vram = torch.cuda.get_device_properties(0).total_memory / (1024**3)
check("GPU", True, f"{gpu_name} ({vram:.1f} GB)")
check("PyTorch CUDA version", True, torch.version.cuda or "N/A")
else:
failures += 1
except Exception as e:
check("GPU check", False, str(e))
failures += 1
return failures
def validate_gitignore() -> int:
header("7. Security Check")
gitignore = PROJECT_ROOT / ".gitignore"
failures = 0
if gitignore.is_file():
content = gitignore.read_text(encoding="utf-8")
check(".env in .gitignore", ".env" in content)
check("venv/ in .gitignore", "venv" in content)
if ".env" not in content:
failures += 1
else:
check(".gitignore exists", False)
failures += 1
return failures
def main() -> None:
print("\nββββββββββββββββββββββββββββββββββββββββββββββββββββ")
print("β MINDI 1.5 Vision-Coder β Full Setup Validation β")
print("ββββββββββββββββββββββββββββββββββββββββββββββββββββ")
total_failures = 0
total_failures += validate_directories()
total_failures += validate_files()
total_failures += validate_env()
total_failures += validate_configs()
total_failures += validate_packages()
total_failures += validate_gpu()
total_failures += validate_gitignore()
header("RESULT")
if total_failures == 0:
print(" β
ALL CHECKS PASSED β MINDI 1.5 is ready!")
else:
print(f" β {total_failures} check(s) failed β review above")
sys.exit(0 if total_failures == 0 else 1)
if __name__ == "__main__":
main()
|