-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_setup.py
More file actions
152 lines (114 loc) · 4.08 KB
/
verify_setup.py
File metadata and controls
152 lines (114 loc) · 4.08 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
"""
Quick Verification Script - Day 4-5
Tests that all components are working before building the full graph
"""
import sys
from pathlib import Path
# Add project root to path
project_root = Path(__file__).parent
sys.path.insert(0, str(project_root))
def test_imports():
"""Test that all modules can be imported"""
print("\n[1/4] Testing imports...")
try:
from backend.core.relationship_extractor import RelationshipExtractor
print(" [OK] RelationshipExtractor imported")
except ImportError as e:
print(f" [ERROR] Failed to import RelationshipExtractor: {e}")
return False
try:
from backend.database.neo4j_manager import Neo4jManager
print(" [OK] Neo4jManager imported")
except ImportError as e:
print(f" [ERROR] Failed to import Neo4jManager: {e}")
return False
try:
from backend.core.nlp_processor import NLPProcessor
print(" [OK] NLPProcessor imported")
except ImportError as e:
print(f" [ERROR] Failed to import NLPProcessor: {e}")
return False
print(" [OK] All imports successful")
return True
def test_neo4j_connection():
"""Test Neo4j connection"""
print("\n[2/4] Testing Neo4j connection...")
try:
from backend.database.neo4j_manager import Neo4jManager
manager = Neo4jManager()
if manager.verify_connection():
print(" [OK] Neo4j connection successful")
# Get current stats
stats = manager.get_graph_stats()
print(f" [INFO] Current graph size:")
print(f" - Nodes: {stats['total_nodes']}")
print(f" - Relationships: {stats['total_relationships']}")
manager.close()
return True
else:
print(" [ERROR] Neo4j connection failed")
return False
except Exception as e:
print(f" [ERROR] Neo4j test failed: {e}")
print(" [HELP] Make sure Neo4j is running:")
print(" docker ps")
print(" docker-compose up -d")
return False
def test_sample_documents():
"""Test that sample documents exist"""
print("\n[3/4] Checking sample documents...")
sample_dir = Path("data/sample/txt")
if not sample_dir.exists():
print(f" [ERROR] Sample directory not found: {sample_dir}")
return False
sample_files = list(sample_dir.glob("*.txt"))
if not sample_files:
print(f" [ERROR] No .txt files found in {sample_dir}")
return False
print(f" [OK] Found {len(sample_files)} sample documents:")
for f in sample_files:
print(f" - {f.name}")
return True
def test_nlp_model():
"""Test that spaCy model is available"""
print("\n[4/4] Testing spaCy model...")
try:
import spacy
nlp = spacy.load("en_core_web_lg")
print(" [OK] spaCy model loaded successfully")
return True
except Exception as e:
print(f" [ERROR] Failed to load spaCy model: {e}")
print(" [HELP] Download the model with:")
print(" python -m spacy download en_core_web_lg")
return False
def main():
"""Run all verification tests"""
print("\n" + "="*80)
print("DAY 4-5 VERIFICATION TESTS")
print("="*80)
tests = [
test_imports,
test_neo4j_connection,
test_sample_documents,
test_nlp_model
]
results = []
for test in tests:
result = test()
results.append(result)
print("\n" + "="*80)
print("VERIFICATION SUMMARY")
print("="*80)
passed = sum(results)
total = len(results)
print(f"\nTests passed: {passed}/{total}")
if passed == total:
print("\n[OK] ALL TESTS PASSED!")
print("\nYou're ready to build the knowledge graph:")
print(" python build_knowledge_graph.py")
else:
print("\n[WARNING] Some tests failed. Fix the issues above before proceeding.")
print("\n")
if __name__ == "__main__":
main()