Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
500 changes: 133 additions & 367 deletions docs/reference/graphql/graphql_API.md

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions python/python/raphtory/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ __all__ = [
"algorithms",
"graph_loader",
"graph_gen",
"vectors",
"node_state",
"filter",
"iterables",
Expand Down Expand Up @@ -668,6 +669,26 @@ class GraphView(object):
GraphView: The layered view
"""

def vectorise(
self,
model: VectorCache,
nodes: bool | str = True,
edges: bool | str = True,
verbose: bool = False,
) -> VectorisedGraph:
"""
Create a VectorisedGraph from the current graph.

Args:
model (VectorCache): Cache wrapping the embedding model used to embed documents.
nodes (bool | str): Enable for nodes to be embedded, disable for nodes to not be embedded or specify a custom document property to use if a string is provided. Defaults to True.
edges (bool | str): Enable for edges to be embedded, disable for edges to not be embedded or specify a custom document property to use if a string is provided. Defaults to True.
verbose (bool): Enable to print logs reporting progress. Defaults to False.

Returns:
VectorisedGraph: A VectorisedGraph with all the documents and their embeddings, with an initial empty selection.
"""

def window(self, start: TimeInput, end: TimeInput) -> GraphView:
"""
Create a view of the GraphView including all events between `start` (inclusive) and `end` (exclusive)
Expand Down
34 changes: 32 additions & 2 deletions python/python/raphtory/graphql/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,39 @@ class GraphServer(object):
RunningGraphServer: The running server
"""

def turn_off_index(self) -> None:
def vectorise_all_graphs(
self,
embeddings: OpenAIEmbeddings,
nodes: bool | str = True,
edges: bool | str = True,
) -> None:
"""
Vectorise all graphs in the server working directory.

Arguments:
embeddings (OpenAIEmbeddings): the embeddings to use
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:
None:
"""
Turn off index for all graphs.

def vectorise_graph(
self,
name: list[str],
embeddings: OpenAIEmbeddings,
nodes: bool | str = True,
edges: bool | str = True,
) -> None:
"""
Vectorise the graph name in the server working directory.

Arguments:
name (list[str]): the name of the graph to vectorise.
embeddings (OpenAIEmbeddings): the embeddings to use
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:
None:
Expand Down
34 changes: 34 additions & 0 deletions python/python/raphtory/node_state/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7818,6 +7818,17 @@ class OutputNodeState(object):
Optional[dict]: the value for the node or the default value
"""

def groups(self, cols: list[str]) -> list[tuple[dict, Nodes]]:
"""
Group by value

Arguments:
cols (list[str]): columns by which to group nodes

Returns:
list[tuple[dict, Nodes]]: The grouped nodes
"""

def items(self) -> Iterator[Tuple[Node, Dict]]:
"""
Iterate over items
Expand Down Expand Up @@ -7854,6 +7865,17 @@ class OutputNodeState(object):
Nodes: The nodes
"""

def sort_by(self, sort_params: Dict) -> OutputNodeState:
"""
Get value for node

Arguments:
sort_params (Dict): Map of sort keys to sort option ('asc' or 'desc'). None defaults to 'asc'

Returns:
OutputNodeState: Sorted NodeState
"""

def to_parquet(self, file_path: str, id_column: str = "id") -> None:
"""
Convert OutputNodeState to Parquet
Expand All @@ -7866,6 +7888,18 @@ class OutputNodeState(object):
None:
"""

def top_k(self, sort_params: Dict, k: int) -> OutputNodeState:
"""
Get value for node

Arguments:
sort_params (Dict): Map of sort keys to sort option ('asc' or 'desc'). None defaults to 'asc'
k (int): Number of top entries to return.

Returns:
OutputNodeState: Sorted NodeState
"""

def values(self) -> Iterator[Dict]:
"""
Iterate over values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ def test_graph_persistence_across_restarts():

# Verify persistence: check that nodes and edges are still there
query_nodes = """{graph(path: "persistent_graph") {nodes {sorted (sortBys: [{id: true}]){ list {name} }}}}"""
query_edges = """{graph(path: "persistent_graph") {edges {sorted (sortBys: [{src: true, dst: true}]){ list {id} }}}}"""
query_edges = """{graph(path: "persistent_graph") {edges {sorted (sortBys: [{src: {id: true}, dst: {id: true}}]){ list {id} }}}}"""

assert client.query(query_nodes) == {
"graph": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def test_graph_edge_sort_by_src(graph):
query {
graph(path: "g") {
edges {
sorted(sortBys: [{ src: true }]) {
sorted(sortBys: [{ src: { id: true } }]) {
list {
src {
id
Expand Down Expand Up @@ -182,7 +182,7 @@ def test_graph_edge_sort_by_dst(graph):
query {
graph(path: "g") {
edges {
sorted(sortBys: [{ dst: true }]) {
sorted(sortBys: [{ dst: { id: true } }]) {
list {
dst {
id
Expand Down Expand Up @@ -635,7 +635,7 @@ def test_graph_edge_sort_by_combined_2(graph):
query {
graph(path: "g") {
edges {
sorted(sortBys: [{ dst: true }, { time: EARLIEST }, { property: "eprop3" }, { time: LATEST, reverse: true }]) {
sorted(sortBys: [{ dst: { id: true } }, { time: EARLIEST }, { property: "eprop3" }, { time: LATEST, reverse: true }]) {
list {
src {
id
Expand Down
Loading