I am trying to run gsql queries from the graph data science library using tigergraphx as follows:
gsql_query = open('TigerGraph/gsql-graph-algorithms-tg_4.3.0_dev/algorithms/Community/louvain/tg_louvain.gsql', 'r').read()
self.datascope_graph.create_query(gsql_query)
self.datascope_graph.install_query('tg_louvain')
result = self.datascope_graph.run_query('tg_louvain', {
'v_type_set': ["gsbNode"],
'e_type_set': ["gsbEdge"],
'weight_attribute': "",
'maximum_iteration': 10,
'result_attribute': ["cluster_id"],
'print_info': True
})
But I am seeing this error:
2025-06-20 03:37:07,866 - tigergraphx.core.managers.query_manager - INFO - Installing query 'tg_louvain' for graph 'workflow0_graph'...
2025-06-20 03:37:50,848 - tigergraphx.core.managers.query_manager - INFO - Query 'tg_louvain' installed successfully.
rohila
2025-06-20 03:37:51,017 - tigergraphx.core.managers.query_manager - ERROR - Error running query tg_louvain: Expected list, but got str:
I can run the same ‘tg_louvain’ query from the gsql shell as follows:
run query tg_louvain(["gsbNode"], ["gsbEdge"], _, 10, "cluster_id", _, TRUE)
I am referring this for the syntax, but it is not comprehensive enough - Louvain :: Graph Data Science Library
What is the correct syntax?
I looked into the source code of the tigergraphx driver and found the point where it throws the error:
def run_installed_query_post(
self, graph_name: str, query_name: str, json: Optional[Dict[str, Any]] = None
) -> List:
result = self._request(
endpoint_name="run_installed_query_post",
json=json,
graph_name=graph_name,
query_name=query_name,
)
if not isinstance(result, list):
raise TypeError(f"Expected list, but got {type(result).__name__}: {result}")
return result
The above piece of code is in tigergraphx/core/tigergraph_api/api/query_api.py
Apparently, the query runs but it returns an empty string. Is this behavior expected for a 6 node, 10 edge graph?