Skip to content

Commit

Permalink
fix python errors
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianmurariu committed Jul 23, 2024
1 parent e65814d commit aa944f9
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 144 deletions.
58 changes: 55 additions & 3 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ debug = true

[workspace.dependencies]
#[public-storage]
pometry-storage = { version = ">=0.8.1", path = "pometry-storage" }
# pometry-storage = { version = ">=0.8.1", path = "pometry-storage" }
#[private-storage]
# pometry-storage = { path = "pometry-storage-private", package = "pometry-storage-private" }
pometry-storage = { path = "pometry-storage-private", package = "pometry-storage-private" }
async-graphql = { version = "7.0.5", features = ["dynamic-schema"] }
async-graphql-poem = "7.0.5"
dynamic-graphql = "0.9.0"
Expand Down
112 changes: 3 additions & 109 deletions python/tests/test_disk_graph.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from raphtory import DiskGraph, Query, State, PyDirection
from raphtory import PyDirection, DiskGraphStorage
import pandas as pd
import tempfile

Expand Down Expand Up @@ -33,7 +33,7 @@


def create_graph(edges, dir):
return DiskGraph.load_from_pandas(dir, edges, "src", "dst", "time")
return DiskGraphStorage.load_from_pandas(dir, edges, "src", "dst", "time")


# in every test use with to create a temporary directory that will be deleted automatically
Expand All @@ -42,113 +42,7 @@ def create_graph(edges, dir):

def test_counts():
dir = tempfile.TemporaryDirectory()
graph = create_graph(edges, dir.name)
graph = create_graph(edges, dir.name).to_events()
assert graph.count_nodes() == 5
assert graph.count_edges() == 20


def test_simple_hop():
dir = tempfile.TemporaryDirectory()
graph = create_graph(edges, dir.name)
q = Query.from_node_ids([1]).hop(dir=PyDirection("OUT"), layer=None, limit=100)
state = State.path()
actual = q.run_to_vec(graph, state)

actual = [([n2.name, n1.name], n2.name) for ([n2, n1], n2) in actual]

expected = [
(["2", "1"], "2"),
(["3", "1"], "3"),
(["4", "1"], "4"),
(["5", "1"], "5"),
]

actual.sort()
expected.sort()

assert actual == expected


def test_simple_hop_from_node():
dir = tempfile.TemporaryDirectory()
graph = create_graph(edges, dir.name)
node = graph.node(1)
q = Query.from_node_ids([node]).out()
state = State.path()
actual = q.run_to_vec(graph, state)

actual = [([n2.name, n1.name], n2.name) for ([n2, n1], n2) in actual]

expected = [
(["2", "1"], "2"),
(["3", "1"], "3"),
(["4", "1"], "4"),
(["5", "1"], "5"),
]

actual.sort()
expected.sort()

assert actual == expected


def test_double_hop():
dir = tempfile.TemporaryDirectory()
graph = create_graph(edges, dir.name)
q = Query.from_node_ids([1]).out().out()
state = State.path()
actual = q.run_to_vec(graph, state)

actual = [([n3.name, n2.name, n1.name], n3.name) for ([n3, n2, n1], n3) in actual]

expected = [
(["1", "5", "1"], "1"),
(["2", "4", "1"], "2"),
(["5", "3", "1"], "5"),
(["2", "5", "1"], "2"),
(["4", "2", "1"], "4"),
(["4", "3", "1"], "4"),
(["1", "4", "1"], "1"),
(["3", "2", "1"], "3"),
(["3", "4", "1"], "3"),
(["5", "2", "1"], "5"),
(["1", "2", "1"], "1"),
(["5", "4", "1"], "5"),
(["2", "3", "1"], "2"),
(["1", "3", "1"], "1"),
(["3", "5", "1"], "3"),
(["4", "5", "1"], "4"),
]

actual.sort()
expected.sort()

assert actual == expected


def test_hop_twice_forward():
dir = tempfile.TemporaryDirectory()
edges = pd.DataFrame(
{
"src": [0, 0, 1, 1, 3, 3, 3, 4, 4, 4],
"dst": [1, 2, 3, 4, 5, 6, 6, 3, 4, 7],
"time": [11, 10, 12, 13, 5, 10, 15, 14, 14, 10],
}
).sort_values(["src", "dst", "time"])
graph = create_graph(edges, dir.name)
q = Query.from_node_ids([0, 1]).out().out()
state = State.path_window(keep_path=True, start_t=10, duration=100)
actual = q.run_to_vec(graph, state)

actual = [([n3.name, n2.name, n1.name], n3.name) for ([n3, n2, n1], n3) in actual]

expected = [
(["6", "3", "1"], "6"),
(["3", "1", "0"], "3"),
(["3", "4", "1"], "3"),
(["4", "4", "1"], "4"),
(["4", "1", "0"], "4"),
]
actual.sort()
expected.sort()
assert actual == expected
2 changes: 2 additions & 0 deletions python/tests/test_diskgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def test_disk_graph():
print_result=False,
)

g = g.to_events()

assert g.count_nodes() == 1624
assert g.layer("netflow").count_edges() == 2018
assert g.earliest_time == 7257601
Expand Down
38 changes: 19 additions & 19 deletions python/tests/test_graph_conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,35 +125,35 @@ def test_py_vis():
[
{
"color": "#97c2fc",
"id": 7678824742430955432,
"id": 'ServerA',
"image": "https://cdn-icons-png.flaticon.com/512/7584/7584620.png",
"label": "ServerA",
"shape": "dot",
},
{
"color": "#97c2fc",
"id": 7718004695861170879,
"id": 'ServerB',
"image": "https://cdn-icons-png.flaticon.com/512/7584/7584620.png",
"label": "ServerB",
"shape": "dot",
},
{
"color": "#97c2fc",
"id": 17918514325589227856,
"id": 'ServerC',
"image": "https://cdn-icons-png.flaticon.com/512/7584/7584620.png",
"label": "ServerC",
"shape": "dot",
},
{
"color": "#97c2fc",
"id": 14902018402467198225,
"id": 'ServerD',
"image": "https://cdn-icons-png.flaticon.com/512/7584/7584620.png",
"label": "ServerD",
"shape": "dot",
},
{
"color": "#97c2fc",
"id": 11577954539736240602,
"id": 'ServerE',
"image": "https://cdn-icons-png.flaticon.com/512/7584/7584620.png",
"label": "ServerE",
"shape": "dot",
Expand All @@ -168,63 +168,63 @@ def test_py_vis():
"arrowStrikethrough": False,
"arrows": "to",
"color": "#000000",
"from": 7678824742430955432,
"from": 'ServerA',
"title": "",
"to": 7718004695861170879,
"to": 'ServerB',
"value": 0.0,
},
{
"arrowStrikethrough": False,
"arrows": "to",
"color": "#000000",
"from": 7678824742430955432,
"from": 'ServerA',
"title": "",
"to": 17918514325589227856,
"to": 'ServerC',
"value": 0.0,
},
{
"arrowStrikethrough": False,
"arrows": "to",
"color": "#000000",
"from": 7718004695861170879,
"from": 'ServerB',
"title": "",
"to": 14902018402467198225,
"to": 'ServerD',
"value": 0.0,
},
{
"arrowStrikethrough": False,
"arrows": "to",
"color": "#000000",
"from": 17918514325589227856,
"from": 'ServerC',
"title": "",
"to": 7678824742430955432,
"to": 'ServerA',
"value": 0.0,
},
{
"arrowStrikethrough": False,
"arrows": "to",
"color": "#000000",
"from": 14902018402467198225,
"from": 'ServerD',
"title": "",
"to": 17918514325589227856,
"to": 'ServerC',
"value": 0.0,
},
{
"arrowStrikethrough": False,
"arrows": "to",
"color": "#000000",
"from": 14902018402467198225,
"from": 'ServerD',
"title": "",
"to": 11577954539736240602,
"to": 'ServerE',
"value": 0.0,
},
{
"arrowStrikethrough": False,
"arrows": "to",
"color": "#000000",
"from": 11577954539736240602,
"from": 'ServerE',
"title": "",
"to": 7718004695861170879,
"to": 'ServerB',
"value": 0.0,
},
],
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_iterables.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def test_propiterable():
assert sorted(total) == [2, 17, 18, 35, 38]

total = dict(zip(g.nodes.id, g.nodes.out_edges.properties.get("value_dec").sum()))
assert total == {1: 32, 2: 5, 3: 3, 4: 15, 5: None}
assert total == {'1': 32, '2': 5, '3': 3, '4': 15, '5': None}

total = g.nodes.out_edges.properties.get("value_dec").sum().sum()
assert total == 55
Expand Down
8 changes: 5 additions & 3 deletions raphtory/src/db/api/storage/storage_ops/deletions.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
use raphtory_api::core::{entities::VID, storage::timeindex::TimeIndexEntry};

use crate::{core::utils::errors::GraphError, db::api::mutation::internal::InternalDeletionOps};

use super::GraphStorage;

impl InternalDeletionOps for GraphStorage {
fn internal_delete_edge(
&self,
t: raphtory_api::core::storage::timeindex::TimeIndexEntry,
src: raphtory_api::core::entities::VID,
dst: raphtory_api::core::entities::VID,
t: TimeIndexEntry,
src: VID,
dst: VID,
layer: usize,
) -> Result<(), GraphError> {
match self {
Expand Down
Loading

0 comments on commit aa944f9

Please sign in to comment.