Skip to content

impl index spec #2103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 32 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d4485db
impl index spec
shivamka1 May 22, 2025
ce6e2d9
fallback to raphtory apis for properties for which indexes are not cr…
shivamka1 May 23, 2025
425556f
impl index spec for python
shivamka1 May 27, 2025
94b2a61
impl get index spec
shivamka1 May 27, 2025
9243580
fix loading index spec based index
shivamka1 May 27, 2025
8675021
move all index tests in one place
shivamka1 May 28, 2025
16d1ead
add test
shivamka1 May 28, 2025
f88b9cd
impl py get_index_spec
shivamka1 May 28, 2025
aa570c4
rw indexspec
shivamka1 May 28, 2025
054cfde
check if index needs update
shivamka1 May 28, 2025
c07aab4
impl update index
shivamka1 May 28, 2025
5e17d7d
add test
shivamka1 May 28, 2025
d478677
more test
shivamka1 May 28, 2025
72add5a
update only existing prop index, don't add any new prop index via upd…
shivamka1 May 28, 2025
ec8777a
add tests
shivamka1 May 28, 2025
9912a76
Merge branch 'master' into features/index_spec
shivamka1 May 28, 2025
ac08e60
fmt
shivamka1 May 28, 2025
98aa850
fix issues with property indexes, add/fix tests
shivamka1 May 29, 2025
d1e0ac0
ref
shivamka1 May 30, 2025
397afb8
add update index to create_index_in_ram_with_spec, add test
shivamka1 May 30, 2025
290908e
ref py tests
shivamka1 May 30, 2025
ab59db1
impl gql node type filtering for list of node types
shivamka1 May 30, 2025
b0fe461
add test
shivamka1 May 30, 2025
d08d0b1
fix test
shivamka1 May 30, 2025
0953cd4
ref
shivamka1 May 30, 2025
165172c
fix tests
shivamka1 Jun 2, 2025
199a086
rid UnknownProperty
shivamka1 Jun 2, 2025
908650e
add comment
shivamka1 Jun 2, 2025
ecb90ca
rid name and prop type from index spec
shivamka1 Jun 2, 2025
d806701
fix indexspec for python
shivamka1 Jun 2, 2025
5756687
fix race
shivamka1 Jun 2, 2025
e4ab6aa
impl suggestions from review
shivamka1 Jun 2, 2025
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
85 changes: 85 additions & 0 deletions python/test_utils/filters_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,88 @@ def init_edges_graph2(graph):
graph.edge(src, dst).add_constant_properties(props)

return graph


import tempfile
from raphtory.graphql import GraphServer
import json
import re

PORT = 1737


def create_test_graph(g):
g.add_node(
1,
"a",
{
"prop1": 60,
"prop2": 31.3,
"prop3": "abc123",
"prop4": True,
"prop5": [1, 2, 3],
},
"fire_nation"
)
g.add_node(
1,
"b",
{"prop1": 10, "prop2": 31.3, "prop3": "abc223", "prop4": False},
"fire_nation"
)
g.add_node(
1,
"c",
{
"prop1": 20,
"prop2": 31.3,
"prop3": "abc333",
"prop4": True,
"prop5": [5, 6, 7],
},
"water_tribe"
)
g.add_node(
1,
"d",
{"prop1": 30, "prop2": 31.3, "prop3": "abc444", "prop4": False},
"air_nomads"
)
g.add_edge(
2,
"a",
"d",
{
"eprop1": 60,
"eprop2": 0.4,
"eprop3": "xyz123",
"eprop4": True,
"eprop5": [1, 2, 3],
},
)
g.add_edge(
2,
"b",
"d",
{
"eprop1": 10,
"eprop2": 1.7,
"eprop3": "xyz123",
"eprop4": True,
"eprop5": [3, 4, 5],
},
)
g.add_edge(
2,
"c",
"d",
{
"eprop1": 30,
"eprop2": 6.4,
"eprop3": "xyz123",
"eprop4": False,
"eprop5": [10],
},
)
return g

18 changes: 18 additions & 0 deletions python/test_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,24 @@ def run_graphql_error_test(query, expected_error_message, graph):
), f"Expected '{expected_error_message}', but got '{error_message}'"


def run_graphql_error_test(query, expected_error_message, graph):
tmp_work_dir = tempfile.mkdtemp()
with GraphServer(tmp_work_dir).start(PORT) as server:
client = server.get_client()
client.send_graph(path="g", graph=graph)

with pytest.raises(Exception) as excinfo:
client.query(query)

full_error_message = str(excinfo.value)
match = re.search(r'"message":"(.*?)"', full_error_message)
error_message = match.group(1) if match else ""

assert (
error_message == expected_error_message
), f"Expected '{expected_error_message}', but got '{error_message}'"


def run_group_graphql_error_test(queries_and_expected_error_messages, graph):
tmp_work_dir = tempfile.mkdtemp()
with GraphServer(tmp_work_dir).start(PORT) as server:
Expand Down
52 changes: 30 additions & 22 deletions python/tests/test_base_install/test_graphql/test_edge_sorting.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import pytest

from raphtory import Graph, PersistentGraph

from utils import run_graphql_test


Expand Down Expand Up @@ -67,12 +65,7 @@ def create_test_graph(g):
return g


EVENT_GRAPH = create_test_graph(Graph())

PERSISTENT_GRAPH = create_test_graph(PersistentGraph())


@pytest.mark.parametrize("graph", [EVENT_GRAPH, PERSISTENT_GRAPH])
@pytest.mark.parametrize("graph", [Graph, PersistentGraph])
def test_graph_edge_sort_by_nothing(graph):
query = """
query {
Expand Down Expand Up @@ -107,10 +100,11 @@ def test_graph_edge_sort_by_nothing(graph):
}
}
}
graph = create_test_graph(graph())
run_graphql_test(query, expected_output, graph)


@pytest.mark.parametrize("graph", [EVENT_GRAPH, PERSISTENT_GRAPH])
@pytest.mark.parametrize("graph", [Graph, PersistentGraph])
def test_graph_edge_sort_by_src(graph):
query = """
query {
Expand Down Expand Up @@ -145,10 +139,11 @@ def test_graph_edge_sort_by_src(graph):
}
}
}
graph = create_test_graph(graph())
run_graphql_test(query, expected_output, graph)


@pytest.mark.parametrize("graph", [EVENT_GRAPH, PERSISTENT_GRAPH])
@pytest.mark.parametrize("graph", [Graph, PersistentGraph])
def test_graph_edge_sort_by_dst(graph):
query = """
query {
Expand Down Expand Up @@ -183,10 +178,11 @@ def test_graph_edge_sort_by_dst(graph):
}
}
}
graph = create_test_graph(graph())
run_graphql_test(query, expected_output, graph)


@pytest.mark.parametrize("graph", [EVENT_GRAPH, PERSISTENT_GRAPH])
@pytest.mark.parametrize("graph", [Graph, PersistentGraph])
def test_graph_edge_sort_by_earliest_time(graph):
query = """
query {
Expand Down Expand Up @@ -221,10 +217,11 @@ def test_graph_edge_sort_by_earliest_time(graph):
}
}
}
graph = create_test_graph(graph())
run_graphql_test(query, expected_output, graph)


@pytest.mark.parametrize("graph", [EVENT_GRAPH, PERSISTENT_GRAPH])
@pytest.mark.parametrize("graph", [Graph, PersistentGraph])
def test_graph_edge_sort_by_earliest_time_reversed(graph):
query = """
query {
Expand Down Expand Up @@ -260,10 +257,11 @@ def test_graph_edge_sort_by_earliest_time_reversed(graph):
}
}
}
graph = create_test_graph(graph())
run_graphql_test(query, expected_output, graph)


@pytest.mark.parametrize("graph", [EVENT_GRAPH])
@pytest.mark.parametrize("graph", [Graph])
def test_graph_edge_sort_by_latest_time(graph):
query = """
query {
Expand Down Expand Up @@ -298,10 +296,11 @@ def test_graph_edge_sort_by_latest_time(graph):
}
}
}
graph = create_test_graph(graph())
run_graphql_test(query, expected_output, graph)


@pytest.mark.parametrize("graph", [PERSISTENT_GRAPH])
@pytest.mark.parametrize("graph", [PersistentGraph])
def test_graph_edge_sort_by_latest_time_persistent_graph(graph):
query = """
query {
Expand Down Expand Up @@ -337,10 +336,11 @@ def test_graph_edge_sort_by_latest_time_persistent_graph(graph):
}
}
}
graph = create_test_graph(graph())
run_graphql_test(query, expected_output, graph)


@pytest.mark.parametrize("graph", [EVENT_GRAPH, PERSISTENT_GRAPH])
@pytest.mark.parametrize("graph", [Graph, PersistentGraph])
def test_graph_edge_sort_by_eprop1(graph):
query = """
query {
Expand Down Expand Up @@ -375,10 +375,11 @@ def test_graph_edge_sort_by_eprop1(graph):
}
}
}
graph = create_test_graph(graph())
run_graphql_test(query, expected_output, graph)


@pytest.mark.parametrize("graph", [EVENT_GRAPH, PERSISTENT_GRAPH])
@pytest.mark.parametrize("graph", [Graph, PersistentGraph])
def test_graph_edge_sort_by_eprop2(graph):
query = """
query {
Expand Down Expand Up @@ -413,10 +414,11 @@ def test_graph_edge_sort_by_eprop2(graph):
}
}
}
graph = create_test_graph(graph())
run_graphql_test(query, expected_output, graph)


@pytest.mark.parametrize("graph", [EVENT_GRAPH, PERSISTENT_GRAPH])
@pytest.mark.parametrize("graph", [Graph, PersistentGraph])
def test_graph_edge_sort_by_eprop3(graph):
query = """
query {
Expand Down Expand Up @@ -451,10 +453,11 @@ def test_graph_edge_sort_by_eprop3(graph):
}
}
}
graph = create_test_graph(graph())
run_graphql_test(query, expected_output, graph)


@pytest.mark.parametrize("graph", [EVENT_GRAPH, PERSISTENT_GRAPH])
@pytest.mark.parametrize("graph", [Graph, PersistentGraph])
def test_graph_edge_sort_by_eprop4(graph):
query = """
query {
Expand Down Expand Up @@ -489,10 +492,11 @@ def test_graph_edge_sort_by_eprop4(graph):
}
}
}
graph = create_test_graph(graph())
run_graphql_test(query, expected_output, graph)


@pytest.mark.parametrize("graph", [EVENT_GRAPH, PERSISTENT_GRAPH])
@pytest.mark.parametrize("graph", [Graph, PersistentGraph])
def test_graph_edge_sort_by_eprop5(graph):
query = """
query {
Expand Down Expand Up @@ -527,10 +531,11 @@ def test_graph_edge_sort_by_eprop5(graph):
}
}
}
graph = create_test_graph(graph())
run_graphql_test(query, expected_output, graph)


@pytest.mark.parametrize("graph", [EVENT_GRAPH, PERSISTENT_GRAPH])
@pytest.mark.parametrize("graph", [Graph, PersistentGraph])
def test_graph_edge_sort_by_nonexistent_prop(graph):
query = """
query {
Expand Down Expand Up @@ -565,10 +570,11 @@ def test_graph_edge_sort_by_nonexistent_prop(graph):
}
}
}
graph = create_test_graph(graph())
run_graphql_test(query, expected_output, graph)


@pytest.mark.parametrize("graph", [EVENT_GRAPH, PERSISTENT_GRAPH])
@pytest.mark.parametrize("graph", [Graph, PersistentGraph])
def test_graph_edge_sort_by_combined(graph):
query = """
query {
Expand Down Expand Up @@ -603,10 +609,11 @@ def test_graph_edge_sort_by_combined(graph):
}
}
}
graph = create_test_graph(graph())
run_graphql_test(query, expected_output, graph)


@pytest.mark.parametrize("graph", [EVENT_GRAPH, PERSISTENT_GRAPH])
@pytest.mark.parametrize("graph", [Graph, PersistentGraph])
def test_graph_edge_sort_by_combined_2(graph):
query = """
query {
Expand Down Expand Up @@ -641,4 +648,5 @@ def test_graph_edge_sort_by_combined_2(graph):
}
}
}
graph = create_test_graph(graph())
run_graphql_test(query, expected_output, graph)
Loading
Loading