forked from billion-token-one-task/Deepgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
62 lines (50 loc) · 1.74 KB
/
main.py
File metadata and controls
62 lines (50 loc) · 1.74 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
#!/usr/bin/env python3.12
"""DeepGraph - Hierarchical ML Research Knowledge Engine."""
import sys
from pathlib import Path
# Add project root to path
sys.path.insert(0, str(Path(__file__).parent))
from config import (
APP_NAME,
BACKFILL_GRAPH_ON_START,
REFRESH_MERGE_CANDIDATES_ON_START,
ROOT_NODE_ID,
WEB_HOST,
WEB_PORT,
WORKSPACE_DIR,
PDF_CACHE_DIR,
)
from db.database import init_db
from db.evidence_graph import (
backfill_entity_resolutions,
backfill_graph_from_structured_data,
refresh_merge_candidates,
)
from db.taxonomy import seed_taxonomy, backfill_result_taxonomy
from web.app import app
def main():
# Ensure directories exist
WORKSPACE_DIR.mkdir(parents=True, exist_ok=True)
PDF_CACHE_DIR.mkdir(parents=True, exist_ok=True)
# Initialize database
print("Initializing database...", flush=True)
init_db()
print("Database ready.", flush=True)
# Seed taxonomy tree
print("Seeding taxonomy tree...", flush=True)
seed_taxonomy()
print("Taxonomy ready.", flush=True)
print("Backfilling result taxonomy links...", flush=True)
backfill_result_taxonomy()
print("Result taxonomy ready.", flush=True)
print("Backfilling entity resolution map...", flush=True)
backfill_entity_resolutions()
print("Entity resolutions ready.", flush=True)
# Skip heavy backfills on startup for faster boot
# These can run in the background via pipeline
print("Skipping graph/merge backfill (run in pipeline instead).", flush=True)
# Start web server
print(f"Starting {APP_NAME} at http://{WEB_HOST}:{WEB_PORT} (root node: {ROOT_NODE_ID})", flush=True)
app.run(host=WEB_HOST, port=WEB_PORT, debug=False, threaded=True)
if __name__ == "__main__":
main()