Server#

class raphtory.graphql.GraphServer(work_dir, cache_capacity=None, cache_tti_seconds=None, log_level=None, tracing=None, otlp_agent_host=None, otlp_agent_port=None, otlp_tracing_service_name=None, config_path=None)#

Bases: object

A class for defining and running a Raphtory GraphQL server

Methods:

run([port, timeout_ms])

Run the server until completion.

set_embeddings(cache[, embedding, ...])

Setup the server to vectorise graphs with a default template.

start([port, timeout_ms])

Start the server and return a handle to it.

turn_off_index()

Turn off index for all graphs

with_global_search_function(name, input, ...)

Register a function in the GraphQL schema for document search among all the graphs.

with_vectorised_graphs(graph_names[, ...])

Vectorise a subset of the graphs of the server.

run(port=1736, timeout_ms=180000)#

Run the server until completion.

Parameters:
  • port (int) – The port to use. Defaults to 1736.

  • timeout_ms (int) – Timeout for waiting for the server to start. Defaults to 180000.

set_embeddings(cache, embedding=None, graph_template=None, node_template=None, edge_template=None)#

Setup the server to vectorise graphs with a default template.

Parameters:
  • cache (str) – the directory to use as cache for the embeddings.

  • embedding (Callable, optional) – the embedding function to translate documents to embeddings.

  • graph_template (str, optional) – the template to use for graphs.

  • node_template (str, optional) – the template to use for nodes.

  • edge_template (str, optional) – the template to use for edges.

Returns:

A new server object with embeddings setup.

Return type:

GraphServer

start(port=1736, timeout_ms=5000)#

Start the server and return a handle to it.

Parameters:
  • port (int) – the port to use. Defaults to 1736.

  • timeout_ms (int) – wait for server to be online. Defaults to 5000. The server is stopped if not online within timeout_ms but manages to come online as soon as timeout_ms finishes!

Returns:

The running server

Return type:

RunningGraphServer

turn_off_index()#

Turn off index for all graphs

with_global_search_function(name, input, function)#

Register a function in the GraphQL schema for document search among all the graphs.

The function needs to take a GraphqlGraphs object as the first argument followed by a pre-defined set of keyword arguments. Supported types are str, int, and float. They have to be specified using the input parameter as a dict where the keys are the names of the parameters and the values are the types, expressed as strings.

Parameters:
  • name (str) – the name of the function in the GraphQL schema.

  • input (dict) – the keyword arguments expected by the function.

  • function (Callable) – the function to run.

Returns:

A new server object with the function registered

Return type:

GraphServer

with_vectorised_graphs(graph_names, graph_template=None, node_template=None, edge_template=None)#

Vectorise a subset of the graphs of the server.

Parameters:
  • graph_names (list[str]) – the names of the graphs to vectorise. All by default.

  • graph_template (str, optional) – the template to use for graphs.

  • node_template (str, optional) – the template to use for nodes.

  • edge_template (str, optional) – the template to use for edges.

Returns:

A new server object containing the vectorised graphs.

Return type:

GraphServer