-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_debug_output.py
More file actions
109 lines (91 loc) · 3 KB
/
test_debug_output.py
File metadata and controls
109 lines (91 loc) · 3 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
#!/usr/bin/env python3
"""
Test script to verify:
1. BAAI model loading works without timeout interference
2. Debug output is properly saved
"""
import sys
from pathlib import Path
# Add project paths
project_root = Path('.').resolve()
src_path = project_root / 'layered-context-graph' / 'src'
sys.path.insert(0, str(src_path))
# Import required modules
from partitioning.unified_partition_manager import UnifiedPartitionManager, PartitionConfig
from models.baai_model import BAAIModel
from models.qwq_model import QwQModel
import os
print("=== Testing Debug Output ===\n")
# Initialize models
print("1. Loading BAAI model...")
baai_model = BAAIModel(model_path='bge-en-icl')
print("✓ BAAI model loaded successfully (no timeout!)")
print("\n2. Initializing QwQ model with Ollama...")
os.environ['OLLAMA_HOST'] = 'http://172.17.0.1:11434'
qwq_model = QwQModel(qwq_model_path='QwQ_LCoT_7B_Instruct')
# Configure for Ollama
try:
import ollama
qwq_model.ollama_client = ollama.Client(host=os.environ['OLLAMA_HOST'])
qwq_model.heavy_model_loaded = True
qwq_model.use_heavy_model = True
qwq_model.set_fixed_context_size(31000)
print("✓ QwQ model configured for Ollama")
except Exception as e:
print(f"✗ Failed to configure Ollama: {e}")
sys.exit(1)
# Test document
test_text = """
# Test Document
This is a test document with code:
```python
def hello():
print("Hello, World!")
```
And some text after the code.
"""
print("\n3. Testing debug output with small document...")
# Create config with debug enabled
config = PartitionConfig(
segmentation_method='linked_list',
segmentation_params={
'create_summaries': True,
'min_segment_size': 100,
'max_segment_size': 500,
'merge_code_text': True,
'debug_output': True # Enable debug output
}
)
# Process document
manager = UnifiedPartitionManager(config)
try:
print(" Processing document...")
root_id = manager.process_as_linked_list(
test_text,
baai_model=baai_model,
llm_model=qwq_model,
debug_mode=True
)
print(f" ✓ Document processed successfully!")
print(f" Root ID: {root_id}")
print(f" Segments: {len(manager.segments)}")
# Check if debug files were created
debug_dir = Path("../segmentation_debug_outputs")
if debug_dir.exists():
sessions = list(debug_dir.glob("session_*"))
if sessions:
latest_session = max(sessions, key=lambda p: p.stat().st_mtime)
files = list(latest_session.glob("*.txt"))
print(f"\n ✓ Debug output saved to: {latest_session}")
print(f" Files created: {len(files)}")
for f in files[:5]: # Show first 5 files
print(f" - {f.name}")
else:
print(" ⚠ No debug session folders found")
else:
print(" ⚠ Debug directory not created")
except Exception as e:
print(f" ✗ Error: {e}")
import traceback
traceback.print_exc()
print("\n=== Test Complete ===")