I wanted to run some experiments using graph algo library. It looks like the documentation for installing them is a little bit inconsistent. I’m aware I can install them manually via GSQL.
gsql-graph-algorithms/algorithms/Centrality/pagerank at master · tigergraph/gsql-graph-algorithms · GitHub refers to a tg box algos install
command. However GitHub - TigerGraph-DevLabs/TigerGraph-CLI (which seems to be the the tool referred as tg
) does not have a box
command - at least it’s not mentioned in the respective docs.
Further tgcli
docs mention a tgcli server algos
command but lack an example on how to actually use it.
So my question: what is the most easy way to install multiple (or even better: all) algos in a automated way?
Cheers,
grizard
Hi, Grizard!
To install TigerGraph algorithms in an automated way, you can use pyTigerGraph’s featurizer functions. Here is a sample notebook!
To use the function, you will need to install pyTigerGraph with GDS functionality.
pip install pyTigerGraph[gds]
Next, create a connection (replacing the parameters to fit your solution).
import pyTigerGraph as tg
conn = tg.TigerGraphConnection(host = "HOST", graphname = "GRAPHNAME", username = "USERNAME", password = "PASSWORD") # Replace the parameters with the connection values for your solution
conn.apiToken = conn.getToken(conn.createSecret()) # Create an API token
Finally, create a featurizer and install algorithms.
f = conn.gds.featurizer() # Create the featurizer
print(f.installAlgorithm("tg_pagerank_wt")) # Install weighted pagerank query if not already installed
Once again, check out this notebook for more in-depth examples.
Hope this helps! Good luck with your graph algorithm experimentation!
1 Like
Thanks Shreya for pointing me to the python library’s featurizer. This works well for most of the algos.
However I’ve found that specifically for
- tg_pagerank_pers
- tg_wcc
- tg_wcc_small_world
the installAlgorithm
does not work. Those are also not visible when using listAlgorithms()
. My suspicion is the yml metadata in GitHub - tigergraph/gsql-graph-algorithms: GSQL Graph Algorithms is not correct. Is there any way to point featurizer to use another repo as base?
That is the desired functionality of listAlgorithms()
. Unfortunately not all of our algorithms in the library are compatible with the featurizer
functionality yet, but it is something we are working on. In an upcoming release of pyTigerGraph, we will have functionality for users to define their own queries for the featurizer to use.
In the meantime, you should be able to use the conn.gsql()
functionality of pyTigerGraph as follows:
conn.gsql('''
CREATE QUERY query_name(PARAMETERS HERE) FOR GRAPH graph_name {
query logic here
}
INSTALL QUERY query_name
''')
Hope this helps!
3 Likes