-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_import_debug.py
More file actions
92 lines (85 loc) · 3.41 KB
/
test_import_debug.py
File metadata and controls
92 lines (85 loc) · 3.41 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
"""
Debug script to identify import issues in PyMapGIS.
"""
import sys
import time
def test_import(module_name, description=""):
"""Test importing a module with timeout."""
print(f"Testing {module_name}... {description}")
start_time = time.time()
try:
if module_name == "pymapgis":
import pymapgis
print(f"✅ {module_name} imported successfully in {time.time() - start_time:.2f}s")
return True
elif module_name == "pymapgis.cache":
from pymapgis.cache import stats
print(f"✅ {module_name} imported successfully in {time.time() - start_time:.2f}s")
return True
elif module_name == "pymapgis.io":
from pymapgis.io import read
print(f"✅ {module_name} imported successfully in {time.time() - start_time:.2f}s")
return True
elif module_name == "pymapgis.serve":
from pymapgis.serve import serve
print(f"✅ {module_name} imported successfully in {time.time() - start_time:.2f}s")
return True
elif module_name == "pymapgis.vector":
from pymapgis.vector import buffer
print(f"✅ {module_name} imported successfully in {time.time() - start_time:.2f}s")
return True
elif module_name == "pymapgis.raster":
from pymapgis.raster import reproject
print(f"✅ {module_name} imported successfully in {time.time() - start_time:.2f}s")
return True
elif module_name == "pymapgis.viz":
from pymapgis.viz import explore
print(f"✅ {module_name} imported successfully in {time.time() - start_time:.2f}s")
return True
elif module_name == "pymapgis.cli":
from pymapgis.cli import app
print(f"✅ {module_name} imported successfully in {time.time() - start_time:.2f}s")
return True
else:
exec(f"import {module_name}")
print(f"✅ {module_name} imported successfully in {time.time() - start_time:.2f}s")
return True
except Exception as e:
print(f"❌ {module_name} failed: {e}")
import traceback
traceback.print_exc()
return False
def main():
print("PyMapGIS Import Debug Test")
print("=" * 50)
# Test basic dependencies first
modules_to_test = [
("geopandas", "Core geospatial library"),
("xarray", "Array processing library"),
("rioxarray", "Raster I/O library"),
("fastapi", "Web framework"),
("typer", "CLI framework"),
("requests_cache", "HTTP caching"),
("fsspec", "File system abstraction"),
("pymapgis.settings", "Settings module"),
("pymapgis.cache", "Cache module"),
("pymapgis.io", "IO module"),
("pymapgis.vector", "Vector module"),
("pymapgis.raster", "Raster module"),
("pymapgis.viz", "Visualization module"),
("pymapgis.serve", "Serve module"),
("pymapgis.cli", "CLI module"),
("pymapgis", "Main package"),
]
results = {}
for module, desc in modules_to_test:
results[module] = test_import(module, desc)
print()
print("Summary:")
print("=" * 50)
for module, success in results.items():
status = "✅ OK" if success else "❌ FAILED"
print(f"{module:25} {status}")
if __name__ == "__main__":
main()