-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_environment_test.py
More file actions
76 lines (60 loc) · 1.97 KB
/
Copy pathbasic_environment_test.py
File metadata and controls
76 lines (60 loc) · 1.97 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
# Stop if we hit a KeyboardInterrupt
# Summary
# Test basic Python
# Test core modules one by one
#!/usr/bin/env python3
import logging
import sys
"""
Basic Environment Test Script
Tests imports one by one to identify issues
"""
def test_import(module_name, description):
"""Test importing a module and report status."""
try:
logging.info("🔍 Testing {description}...")
__import__(module_name)
logging.info("✅ {description} OK")
return True
except KeyboardInterrupt:
logging.info("❌ {description} - KeyboardInterrupt")
return False
except Exception as e:
logging.info(f"❌ {description} - Error: {e}")
return False
def main():
"""Test all critical imports."""
logging.info("🧪 Basic Environment Test")
logging.info("=" * 50)
logging.info("🔍 Testing basic Python...")
logging.info("✅ Basic Python OK")
tests = [
("torch", "PyTorch"),
("numpy", "NumPy"),
("pandas", "Pandas"),
("sklearn", "Scikit-learn"),
("transformers", "Transformers"),
("datasets", "Datasets"),
]
results = []
for module, description in tests:
result = test_import(module, description)
results.append(result)
if not result and "KeyboardInterrupt" in str(sys.exc_info()[1]):
logging.info("\n🚨 STOPPED: {description} caused KeyboardInterrupt")
break
logging.info(f"\n{'=' * 50}")
logging.info("📊 TEST SUMMARY:")
working = sum(results)
total = len(results)
logging.info("✅ Working: {working}/{total}")
logging.info("❌ Failed: {total - working}/{total}")
if working == total:
logging.info("🎉 All tests passed! Environment is working.")
return True
else:
logging.info("⚠️ Some tests failed. Environment has issues.")
return False
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)