-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_dependencies.py
More file actions
134 lines (114 loc) Β· 4.34 KB
/
test_dependencies.py
File metadata and controls
134 lines (114 loc) Β· 4.34 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
#!/usr/bin/env python3
"""
Test Dependencies
This script tests if all required dependencies can be imported correctly.
"""
def test_dependencies():
"""Test all required dependencies."""
print("π§ͺ TESTING DEPENDENCIES")
print("=" * 50)
dependencies = {
'torch': 'PyTorch for deep learning',
'transformers': 'HuggingFace Transformers',
'datasets': 'HuggingFace Datasets',
'numpy': 'Numerical computing',
'pandas': 'Data manipulation',
'scipy': 'Scientific computing',
'matplotlib': 'Plotting library',
'seaborn': 'Statistical visualization',
'tqdm': 'Progress bars',
'huggingface_hub': 'HuggingFace Hub',
'networkx': 'Network analysis',
'requests': 'HTTP requests',
'PIL': 'Image processing',
'sklearn': 'Machine learning utilities',
'jsonschema': 'JSON validation'
}
# Optional dependencies
optional_dependencies = {
'sae_lens': 'SAELens for GemmaScope SAEs (optional)',
}
failed_deps = []
optional_failed = []
# Test core dependencies
print("\nπ¦ CORE DEPENDENCIES:")
for dep, description in dependencies.items():
try:
if dep == 'PIL':
import PIL
elif dep == 'sklearn':
import sklearn
else:
__import__(dep)
print(f"β
{dep:<15} - {description}")
except ImportError as e:
print(f"β {dep:<15} - {description}")
print(f" Error: {e}")
failed_deps.append(dep)
# Test optional dependencies
print("\nπ¦ OPTIONAL DEPENDENCIES:")
for dep, description in optional_dependencies.items():
try:
__import__(dep)
print(f"β
{dep:<15} - {description}")
except ImportError as e:
print(f"β οΈ {dep:<15} - {description}")
print(f" Error: {e}")
optional_failed.append(dep)
# Summary
print("\n" + "=" * 50)
print("π DEPENDENCY TEST SUMMARY")
print("=" * 50)
if failed_deps:
print(f"β FAILED CORE DEPENDENCIES ({len(failed_deps)}):")
for dep in failed_deps:
print(f" - {dep}")
print(f"\nπ‘ Install with: pip install {' '.join(failed_deps)}")
else:
print("β
ALL CORE DEPENDENCIES INSTALLED")
if optional_failed:
print(f"\nβ οΈ MISSING OPTIONAL DEPENDENCIES ({len(optional_failed)}):")
for dep in optional_failed:
print(f" - {dep}")
print(f"\nπ‘ Install with: pip install {' '.join(optional_failed)}")
else:
print("β
ALL OPTIONAL DEPENDENCIES INSTALLED")
# Test specific imports for verification experiments
print("\n㪠TESTING VERIFICATION EXPERIMENT IMPORTS:")
try:
import sys
import os
# Test path setup
sys.path.append(os.path.join(os.path.dirname(__file__), 'core', 'extractors'))
# Test real_gemma_scope_extractor import
try:
from real_gemma_scope_extractor import RealGemmaScopeExtractor
print("β
RealGemmaScopeExtractor import successful")
except ImportError as e:
print(f"β RealGemmaScopeExtractor import failed: {e}")
# Test other verification imports
try:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
print("β
Transformers imports successful")
except ImportError as e:
print(f"β Transformers imports failed: {e}")
try:
import pandas as pd
import numpy as np
print("β
Data processing imports successful")
except ImportError as e:
print(f"β Data processing imports failed: {e}")
except Exception as e:
print(f"β Verification experiment setup failed: {e}")
print("\n" + "=" * 50)
if failed_deps:
print("β DEPENDENCY TEST FAILED")
print("Please install missing dependencies before running verification experiments.")
return False
else:
print("β
DEPENDENCY TEST PASSED")
print("All required dependencies are installed. Ready to run verification experiments!")
return True
if __name__ == "__main__":
test_dependencies()