muthuk1 commited on
Commit
2941bc4
·
verified ·
1 Parent(s): f486777

Fix #5: Install advanced GSQL queries (PPR, paths, activation) in setup_tigergraph.py

Browse files
Files changed (1) hide show
  1. graphrag/setup_tigergraph.py +14 -4
graphrag/setup_tigergraph.py CHANGED
@@ -1,7 +1,7 @@
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
@@ -12,8 +12,9 @@ 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", ""),
@@ -39,12 +40,21 @@ def setup_tigergraph():
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
 
 
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 all GSQL queries (basic + advanced novelty queries).
5
  """
6
  import os
7
  import sys
 
12
 
13
 
14
  def setup_tigergraph():
15
+ """One-time TigerGraph setup: create schema and install all queries."""
16
  from graphrag.layers.graph_layer import GraphLayer
17
+ from graphrag.layers.gsql_advanced import ALL_ADVANCED_QUERIES
18
 
19
  config = {
20
  "host": os.getenv("TG_HOST", ""),
 
40
  result = graph.create_schema()
41
  logger.info(f"Schema result: {result}")
42
 
43
+ logger.info("Installing core GSQL queries (vector search, entity search, traversal)...")
44
  results = graph.install_queries()
45
  for name, status in results.items():
46
  logger.info(f" {name}: {status}")
47
 
48
+ logger.info("Installing advanced GSQL queries (PPR, paths, spreading activation, neighborhood)...")
49
+ gn = config.get("graphname", "GraphRAG")
50
+ for name, query_template in ALL_ADVANCED_QUERIES.items():
51
+ try:
52
+ result = graph.conn.gsql(query_template.format(graphname=gn))
53
+ logger.info(f" {name}: {result}")
54
+ except Exception as e:
55
+ logger.warning(f" {name}: FAILED — {e}")
56
+
57
+ logger.info("✅ TigerGraph setup complete! All queries installed.")
58
  return True
59
 
60