GraphServer#
- class 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, auth_public_key=None, auth_enabled_for_reads=None, config_path=None)#
Bases:
object
A class for defining and running a Raphtory GraphQL server
- Parameters:
work_dir (str | PathLike) – the working directory for the server
cache_capacity (int, optional) – the maximum number of graphs to keep in memory at once
cache_tti_seconds (int, optional) – the inactive time in seconds after which a graph is evicted from the cache
log_level (str, optional) – the log level for the server
tracing (bool, optional) – whether tracing should be enabled
otlp_agent_host (str, optional) – OTLP agent host for tracing
otlp_agent_port (str, optional) – OTLP agent port for tracing
otlp_tracing_service_name (str, optional) – The OTLP tracing service name
config_path (str | PathLike, optional) – Path to the config file
Methods:
run
([port, timeout_ms])Run the server until completion.
set_embeddings
(cache[, embedding, graphs, ...])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 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.
- set_embeddings(cache, embedding=None, graphs=..., nodes=..., edges=...)#
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.
graphs (bool | str) – if graphs have to be embedded or not or the custom template to use if a str is provided. Defaults to True.
nodes (bool | str) – if nodes have to be embedded or not or the custom template to use if a str is provided. Defaults to True.
edges (bool | str) – if edges have to be embedded or not or the custom template to use if a str is provided. Defaults to True.
- Returns:
A new server object with embeddings setup.
- Return type:
- start(port=1736, timeout_ms=5000)#
Start the server and return a handle to it.
- Parameters:
- Returns:
The running server
- Return type:
- turn_off_index()#
Turn off index for all graphs
- Returns:
The server with indexing disabled
- Return type:
- 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.
- with_vectorised_graphs(graph_names, graphs=..., nodes=..., edges=...)#
Vectorise a subset of the graphs of the server.
- Parameters:
graph_names (list[str]) – the names of the graphs to vectorise. All by default.
graphs (bool | str) – if graphs have to be embedded or not or the custom template to use if a str is provided. Defaults to True.
nodes (bool | str) – if nodes have to be embedded or not or the custom template to use if a str is provided. Defaults to True.
edges (bool | str) – if edges have to be embedded or not or the custom template to use if a str is provided. Defaults to True.
- Returns:
A new server object containing the vectorised graphs.
- Return type: