Featurizer
The Featurizer class provides methods for installing and running Graph Data Science Algorithms onto a TigerGraph server.
The CALL function (see Using an Algorithm) for supporting packaged queries in GSQL is not available through pyTigerGraph.
Use the methods on this page instead.
|
listAlgorithms()
listAlgorithms(category: str = None)
Print the list of available algorithms in GDS.
Parameter:
-
category (str)
: The class of the algorithms, if it is None the entire list will be printed out.
Returns:
Prints the information for algorithms within the specified category.
installAlgorithm()
installAlgorithm(query_name: str, query_path: str = None, global_change: bool = False) → str
Checks if the query is already installed. If the query is not installed, it installs the query and changes the schema if an attribute needs to be added.
Parameters:
-
query_name (str)
: The name of the query to be installed. -
query_path (str)
: If using a custom query, the path to the.gsql
file that contains the query. Note: you must have thequery_name
parameter match the name of the query in the file. -
global_change (bool)
: False by default. Set to true if you want to runGLOBAL SCHEMA_CHANGE JOB
. For algorithms that are not schema free we need to specify this argument.
See Global vs Local Schema Changes for more details.
runAlgorithm()
runAlgorithm(query_name: str, params: dict = None, feat_name: str = None, feat_type: str = None, custom_query: bool = False, schema_name: list = None, global_schema: bool = False, timeout: int = 2147480, sizeLimit: int = None) → Any
Runs a TigerGraph Graph Data Science Algorithm. If a built-in algorithm is not installed, it will automatically install before execution.
Custom algorithms will have to be installed using the installAlgorithm()
method.
If the query accepts input parameters and the parameters have not been provided, calling this function runs the query with the default values for the parameters.
If the there isn’t a default value in the query definition and no parameters are provided, the function raises a ValueError
.
Parameters:
-
query_name (str)
: The name of the query to be executed. -
params (dict)
: Query parameters. A dictionary that corresponds to the algorithm parameters. If specifying vertices as sources or destinations, must use the following form:{"id": "vertex_id", "type": "vertex_type"}
, such asparams = {"source": {"id": "Bob", "type": "Person"}}
-
feat_name (str)
: An attribute name that needs to be added to the vertex/edge -
feat_type (str)
: Type of attribute that needs to be added to the vertex/edge. Only needed ifcustom_query
is set toTrue
. -
custom_query (bool)
: If the query is a custom query. Defaults to False. -
schema_name
: List of Vertices/Edges that the attr_name need to added to them. -
global_schema (bool)
: False by default. Set to true if you want to runGLOBAL SCHEMA_CHANGE JOB
.
See Global vs Local Schema Changes for more details. -
timeout (int)
: Maximum duration for successful query execution (in milliseconds). -
sizeLimit (int)
: Maximum size of response (in bytes).
Returns:
The output of the query, a list of output elements (vertex sets, edge sets, variables, accumulators, etc.)