-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathverify_setup.py
More file actions
executable file
·37 lines (33 loc) · 1.13 KB
/
Copy pathverify_setup.py
File metadata and controls
executable file
·37 lines (33 loc) · 1.13 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
#!/usr/bin/env python3
"""Fast, API-free installation and repository sanity check."""
from pathlib import Path
import importlib
import sys
REQUIRED = [
"numpy", "torch", "transformers", "sentence_transformers",
"sklearn", "beir", "openai", "requests", "tqdm"
]
missing = []
for name in REQUIRED:
try:
importlib.import_module(name)
except Exception as exc:
missing.append((name, str(exc)))
required_paths = [
Path("main.py"), Path("main_adaptive.py"), Path("run_defense.py"),
Path("src/defense.py"), Path("gpt3.5_config.json.template"),
]
missing_paths = [str(p) for p in required_paths if not p.exists()]
print(f"Python: {sys.version.split()[0]}")
print(f"CUDA available: {__import__('torch').cuda.is_available() if not any(n == 'torch' for n, _ in missing) else 'unknown'}")
if missing:
print("Missing/import-failing packages:")
for name, error in missing:
print(f" - {name}: {error}")
if missing_paths:
print("Missing repository files:")
for path in missing_paths:
print(f" - {path}")
if missing or missing_paths:
raise SystemExit(1)
print("TRIS setup check passed.")