Skip to content

Commit

Permalink
Refactor Node Temporal properties
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianmurariu committed Dec 16, 2024
1 parent e8b81a8 commit eda03ac
Show file tree
Hide file tree
Showing 79 changed files with 2,922 additions and 1,189 deletions.
81 changes: 42 additions & 39 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@ debug = 0
pometry-storage = { version = ">=0.8.1", path = "pometry-storage" }
#[private-storage]
# pometry-storage = { path = "pometry-storage-private", package = "pometry-storage-private" }
async-graphql = { version = "7.0.12", features = [
"dynamic-schema",
] }
async-graphql = { version = "7.0.13", features = ["dynamic-schema"] }
bincode = "1.3.3"
async-graphql-poem = "7.0.12"
async-graphql-poem = "7.0.13"
dynamic-graphql = "0.9.0"
reqwest = { version = "0.12.8", default-features = false, features = [
"rustls-tls",
Expand Down
2 changes: 1 addition & 1 deletion pometry-storage-private
9 changes: 4 additions & 5 deletions python/tests/graphql/edit_graph/test_graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pytest

from raphtory.graphql import GraphServer, RaphtoryClient, encode_graph, RemoteGraph
from raphtory.graphql import GraphServer, RaphtoryClient, encode_graph, decode_graph, RemoteGraph
from raphtory import graph_loader
from raphtory import Graph
import json
Expand All @@ -20,10 +20,9 @@ def test_encode_graph():
g.add_edge(3, "ben", "haaroon")

encoded = encode_graph(g)
assert (
encoded
== "EgxaCgoIX2RlZmF1bHQSDBIKCghfZGVmYXVsdBoFCgNiZW4aCQoFaGFtemEYARoLCgdoYWFyb29uGAIiAhABIgYIAhABGAEiBBACGAIqAhoAKgQSAhABKgQSAhADKgIKACoGEgQIARABKgYSBAgBEAIqBAoCCAEqBhIECAIQAioGEgQIAhADKgQKAggCKgQ6AhABKgIyACoIOgYIARACGAEqBDICCAEqCDoGCAIQAxgCKgQyAggC"
)
decoded_g = decode_graph(encoded)

assert g == decoded_g


def test_failed_server_start_in_time():
Expand Down
48 changes: 26 additions & 22 deletions python/tests/test_graphdb/test_graphdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ def no_static_property_test(key, value):
== expected_names_no_static
)

expected_names_no_static_at_1 = sorted(["prop 4", "prop 1", "prop 3"])
expected_names_no_static_at_1 = ["prop 1", "prop 2", "prop 3", "prop 4"]
assert (
sorted(g.at(1).node(1).properties.temporal.keys())
== expected_names_no_static_at_1
Expand Down Expand Up @@ -945,9 +945,8 @@ def check_temporal_properties(g):
["prop 4", "prop 1", "prop 2", "prop 3"]
)

assert sorted(g.at(1).edge(1, 2).properties.temporal.keys()) == sorted(
["prop 4", "prop 1", "prop 3"]
)
assert sorted(g.at(1).edge(1, 2).properties.temporal.keys()) == ["prop 1", "prop 2", "prop 3", "prop 4"]

# find all edges that match properties
[e] = g.at(1).find_edges({"prop 1": 1, "prop 3": "hi"})
assert e == g.edge(1, 2)
Expand Down Expand Up @@ -2122,25 +2121,30 @@ def test_materialize_graph():

# @with_disk_graph FIXME: need special handling for nodes additions from Graph, support for constant properties on edges
def check(g):
def check_g_inner(mg):
assert mg.node(1).properties.get("type") == "wallet"
assert mg.node(4).properties == {"abc": "xyz"}
assert mg.node(4).properties.constant.get("abc") == "xyz"
check_arr(mg.node(1).history(), [-1, 0, 1, 2])
check_arr(mg.node(4).history(), [6, 8])
assert mg.nodes.id.collect() == [1, 2, 3, 4]
assert set(mg.edges.id) == {(1, 1), (1, 2), (1, 3), (2, 1), (3, 2), (2, 4)}
assert g.nodes.id.collect() == mg.nodes.id.collect()
assert set(g.edges.id) == set(mg.edges.id)
assert mg.node(1).properties.constant == {}
assert mg.node(4).properties.constant == {"abc": "xyz"}
assert g.edge(1, 2).id == (1, 2)
assert mg.edge(1, 2).id == (1, 2)
assert mg.has_edge(1, 2)
assert g.has_edge(1, 2)
assert mg.has_edge(2, 1)
assert g.has_edge(2, 1)

check_g_inner(g)

mg = g.materialize()

assert mg.node(1).properties.get("type") == "wallet"
assert mg.node(4).properties == {"abc": "xyz"}
assert mg.node(4).properties.constant.get("abc") == "xyz"
check_arr(mg.node(1).history(), [-1, 0, 1, 2])
check_arr(mg.node(4).history(), [6, 8])
assert mg.nodes.id.collect() == [1, 2, 3, 4]
assert set(mg.edges.id) == {(1, 1), (1, 2), (1, 3), (2, 1), (3, 2), (2, 4)}
assert g.nodes.id.collect() == mg.nodes.id.collect()
assert set(g.edges.id) == set(mg.edges.id)
assert mg.node(1).properties.constant == {}
assert mg.node(4).properties.constant == {"abc": "xyz"}
assert g.edge(1, 2).id == (1, 2)
assert mg.edge(1, 2).id == (1, 2)
assert mg.has_edge(1, 2)
assert g.has_edge(1, 2)
assert mg.has_edge(2, 1)
assert g.has_edge(2, 1)
check_g_inner(mg)

sprop2 = {"sprop 3": 11, "sprop 4": 10}
mg.add_constant_properties(sprop2)
Expand Down Expand Up @@ -2761,7 +2765,7 @@ def test_NaN_NaT_as_properties():
@with_disk_graph
def check(g):
assert g.node(103).properties.temporal.get("floats").items() == [(30, 2.4)]
assert g.node(101).properties.temporal.get("floats") == None
assert g.node(101).properties.temporal.get("floats") == []

check(g)

Expand Down
1 change: 1 addition & 0 deletions raphtory-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ num-traits = { workspace = true }
twox-hash.workspace = true
tracing-subscriber = {workspace = true}
tracing = {workspace = true}
sorted_vector_map = {workspace = true}
[dev-dependencies]
proptest.workspace = true
quickcheck.workspace = true
Expand Down
Loading

0 comments on commit eda03ac

Please sign in to comment.