local-deep-research 0.5.2__py3-none-any.whl → 0.5.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,188 +0,0 @@
1
- #!/usr/bin/env python
2
- """
3
- Migration test script for Local Deep Research.
4
- This script checks the contents of both the legacy and new databases to diagnose migration issues.
5
- """
6
-
7
- import os
8
- import sqlite3
9
- import sys
10
- import time
11
-
12
-
13
- def check_db_content(db_path, description):
14
- """Check what tables and how many rows are in a database."""
15
- if not os.path.exists(db_path):
16
- print(f"❌ {description} database not found at: {db_path}")
17
- return False
18
-
19
- print(f"📊 Examining {description} database at: {db_path}")
20
- try:
21
- conn = sqlite3.connect(db_path)
22
- cursor = conn.cursor()
23
-
24
- # Get list of tables
25
- cursor.execute("SELECT name FROM sqlite_master WHERE type='table'")
26
- tables = [
27
- row[0]
28
- for row in cursor.fetchall()
29
- if not row[0].startswith("sqlite_")
30
- ]
31
-
32
- if not tables:
33
- print(" ℹ️ No user tables found in database")
34
- conn.close()
35
- return False
36
-
37
- print(f" 📋 Tables found: {', '.join(tables)}")
38
-
39
- # For each table, count rows
40
- for table in tables:
41
- cursor.execute(f"SELECT COUNT(*) FROM {table}")
42
- count = cursor.fetchone()[0]
43
- print(f" 📝 Table '{table}' has {count} rows")
44
-
45
- # If table has rows, show sample
46
- if count > 0:
47
- cursor.execute(f"SELECT * FROM {table} LIMIT 1")
48
- columns = [description[0] for description in cursor.description]
49
- print(f" Columns: {', '.join(columns)}")
50
-
51
- # For specific tables, get key columns
52
- if table in [
53
- "research_history",
54
- "research_logs",
55
- "research",
56
- "settings",
57
- ]:
58
- key_cols = (
59
- "id, query, status"
60
- if table == "research_history"
61
- else "id, key, value"
62
- if table == "settings"
63
- else "id, message"
64
- )
65
- cursor.execute(f"SELECT {key_cols} FROM {table} LIMIT 3")
66
- sample = cursor.fetchall()
67
- for row in sample:
68
- print(f" Sample data: {row}")
69
-
70
- conn.close()
71
- return True
72
- except Exception as e:
73
- print(f"❌ Error examining database: {e}")
74
- return False
75
-
76
-
77
- def main():
78
- """Main function to test the migration."""
79
- # Import necessary constants
80
- try:
81
- # Set up paths
82
- current_dir = os.path.dirname(os.path.abspath(__file__))
83
- project_root = os.path.abspath(os.path.join(current_dir, "..", ".."))
84
-
85
- # Determine paths
86
- data_dir = os.path.join(project_root, "data")
87
- new_db_path = os.path.join(data_dir, "ldr.db")
88
-
89
- legacy_research_history_db = os.path.join(
90
- project_root, "src", "local_deep_research", "research_history.db"
91
- )
92
- legacy_deep_research_db = os.path.join(data_dir, "deep_research.db")
93
-
94
- # Print paths for verification
95
- print("=" * 60)
96
- print("DATABASE PATHS")
97
- print("=" * 60)
98
- print(f"New database path: {new_db_path}")
99
- print(f"Legacy research history DB: {legacy_research_history_db}")
100
- print(f"Legacy deep research DB: {legacy_deep_research_db}")
101
- print("=" * 60)
102
-
103
- # Check all databases
104
- check_db_content(legacy_research_history_db, "Legacy research_history")
105
- check_db_content(legacy_deep_research_db, "Legacy deep_research")
106
-
107
- # Now check for the new database or create it if needed
108
- if os.path.exists(new_db_path):
109
- check_db_content(new_db_path, "New ldr")
110
- else:
111
- print(f"ℹ️ New database doesn't exist yet at: {new_db_path}")
112
- print("Would you like to run a test migration? (y/n)")
113
- choice = input("> ").lower()
114
- if choice == "y":
115
- # Run the migration script directly
116
- try:
117
- from src.local_deep_research.setup_data_dir import (
118
- setup_data_dir,
119
- )
120
- except ImportError:
121
- # If that fails, try with the direct import
122
- sys.path.append(
123
- os.path.dirname(
124
- os.path.dirname(os.path.abspath(__file__))
125
- )
126
- )
127
- from local_deep_research.setup_data_dir import (
128
- setup_data_dir,
129
- )
130
-
131
- setup_data_dir()
132
-
133
- # Import migration function
134
- try:
135
- from src.local_deep_research.web.database.migrate_to_ldr_db import (
136
- migrate_to_ldr_db,
137
- )
138
- except ImportError:
139
- # If that fails, try with the direct import
140
- from local_deep_research.web.database.migrate_to_ldr_db import (
141
- migrate_to_ldr_db,
142
- )
143
-
144
- print("Running migration...")
145
- success = migrate_to_ldr_db()
146
-
147
- # Wait briefly to ensure file system has time to update
148
- time.sleep(1)
149
-
150
- if success:
151
- print("\n✅ Migration completed. Checking new database:")
152
- check_db_content(new_db_path, "New ldr")
153
- else:
154
- print("❌ Migration failed")
155
-
156
- # Get the paths from the migration script to verify
157
- try:
158
- try:
159
- from src.local_deep_research.web.models.database import (
160
- DB_PATH,
161
- LEGACY_DEEP_RESEARCH_DB,
162
- LEGACY_RESEARCH_HISTORY_DB,
163
- )
164
- except ImportError:
165
- from local_deep_research.web.models.database import (
166
- DB_PATH,
167
- LEGACY_DEEP_RESEARCH_DB,
168
- LEGACY_RESEARCH_HISTORY_DB,
169
- )
170
-
171
- print("\n" + "=" * 60)
172
- print("PATHS FROM DATABASE MODULE")
173
- print("=" * 60)
174
- print(f"DB_PATH: {DB_PATH}")
175
- print(f"LEGACY_RESEARCH_HISTORY_DB: {LEGACY_RESEARCH_HISTORY_DB}")
176
- print(f"LEGACY_DEEP_RESEARCH_DB: {LEGACY_DEEP_RESEARCH_DB}")
177
- except ImportError as e:
178
- print(f"Could not import paths from database module: {e}")
179
-
180
- except Exception as e:
181
- print(f"Error in test script: {e}")
182
- return 1
183
-
184
- return 0
185
-
186
-
187
- if __name__ == "__main__":
188
- sys.exit(main())