-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_subsample.py
More file actions
executable file
·92 lines (80 loc) · 2.72 KB
/
test_subsample.py
File metadata and controls
executable file
·92 lines (80 loc) · 2.72 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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Quick test to verify the subsampling script works without errors.
"""
import sys
import os
sys.path.insert(0, '.')
from subsample_dataset import get_runtime_info, setup_logging
def test_runtime_info():
"""Test that get_runtime_info() works without errors."""
print("Testing get_runtime_info()...")
try:
info = get_runtime_info()
print("✓ get_runtime_info() completed successfully")
print(f" Platform: {info['platform']}")
print(f" Python version: {info['python_version']}")
print(f" Hostname: {info['hostname']}")
print(f" CPU count: {info['cpu_count']}")
print(f" Memory info keys: {len(info['memory_info'])} items")
print(f" Environment variables: {info['environment_variables']}")
return True
except Exception as e:
print(f"✗ get_runtime_info() failed: {e}")
return False
def test_logging():
"""Test that logging setup works."""
print("\nTesting logging setup...")
try:
import tempfile
with tempfile.NamedTemporaryFile(suffix='.log', delete=False) as f:
log_file = f.name
logger = setup_logging(log_file, "INFO")
logger.info("Test log message")
print(f"✓ Logging setup successful, log file: {log_file}")
# Clean up
os.unlink(log_file)
return True
except Exception as e:
print(f"✗ Logging setup failed: {e}")
return False
def test_imports():
"""Test that all required imports work."""
print("\nTesting imports...")
try:
import anndata as ad
import numpy as np
import pandas as pd
import scanpy as sc
import scipy.sparse as sp
from tqdm.auto import tqdm
print("✓ All required packages imported successfully")
print(f" anndata: {ad.__version__}")
print(f" numpy: {np.__version__}")
print(f" pandas: {pd.__version__}")
print(f" scanpy: {sc.__version__}")
return True
except ImportError as e:
print(f"✗ Import failed: {e}")
return False
if __name__ == "__main__":
print("=== Subsampling Infrastructure Test ===")
tests = [
test_imports,
test_runtime_info,
test_logging
]
results = []
for test in tests:
results.append(test())
print(f"\n=== Test Summary ===")
passed = sum(results)
total = len(results)
print(f"Passed: {passed}/{total}")
if passed == total:
print("✓ All tests passed! The subsampling script should work correctly.")
sys.exit(0)
else:
print("✗ Some tests failed. Please check the errors above.")
sys.exit(1)