muthuk1 commited on
Commit
1ae3c99
·
verified ·
1 Parent(s): 0d2aefd

Add TigerGraph setup script

Browse files
Files changed (1) hide show
  1. graphrag/setup_tigergraph.py +52 -0
graphrag/setup_tigergraph.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Setup script for TigerGraph — Run this once to initialize the graph database.
3
+ Creates schema (Document, Chunk, Entity, Community vertices + edges)
4
+ and installs GSQL queries (vector search, entity search, graph traversal).
5
+ """
6
+ import os
7
+ import sys
8
+ import logging
9
+
10
+ logging.basicConfig(level=logging.INFO)
11
+ logger = logging.getLogger(__name__)
12
+
13
+
14
+ def setup_tigergraph():
15
+ """One-time TigerGraph setup: create schema and install queries."""
16
+ from graphrag.layers.graph_layer import GraphLayer
17
+
18
+ config = {
19
+ "host": os.getenv("TG_HOST", ""),
20
+ "graphname": os.getenv("TG_GRAPH", "GraphRAG"),
21
+ "username": os.getenv("TG_USERNAME", "tigergraph"),
22
+ "password": os.getenv("TG_PASSWORD", ""),
23
+ }
24
+
25
+ if not config["host"]:
26
+ logger.error("TG_HOST not set. Please set environment variables.")
27
+ logger.info("Required: TG_HOST, TG_PASSWORD")
28
+ logger.info("Optional: TG_GRAPH (default: GraphRAG), TG_USERNAME (default: tigergraph)")
29
+ sys.exit(1)
30
+
31
+ graph = GraphLayer(config=config)
32
+
33
+ logger.info("Connecting to TigerGraph Cloud...")
34
+ if not graph.connect():
35
+ logger.error("Connection failed. Check your credentials.")
36
+ sys.exit(1)
37
+
38
+ logger.info("Creating graph schema...")
39
+ result = graph.create_schema()
40
+ logger.info(f"Schema result: {result}")
41
+
42
+ logger.info("Installing GSQL queries...")
43
+ results = graph.install_queries()
44
+ for name, status in results.items():
45
+ logger.info(f" {name}: {status}")
46
+
47
+ logger.info("✅ TigerGraph setup complete!")
48
+ return True
49
+
50
+
51
+ if __name__ == "__main__":
52
+ setup_tigergraph()