Skip to content

Commit 0d45309

Browse files
Stable serialise (#1683)
* serialise one node graph with proto and prost * add minimal support for properties * add better support for properties and start using ids * can encode props and encode and decode edges * added graph const and temporal properties * add test for edge properties * add test for edge deletions * arrange dependencies * add string interning and add protoc to the build * add protoc to rust doctest * try adding github token to binstall and protoc install * add protoc to benchmarks * attempt to fix the github token issues with protoc * more protoc * Graph and Persistend graph now work with pickle and the format is stable * move protobuf in a separate feature * fix the python workflow * fmt * add more protoc in yml * attempt to fix the disk storage * fix python failing * fix graphql lib import issues * change the proto format so it can be easily extended * try ubuntu 20.04 to avoid 143 error * some changes as per review * refactor StableDecode trait * use assert_graph_equals * fix compile issues
1 parent fd400bc commit 0d45309

22 files changed

+1549
-25
lines changed

.github/workflows/_release_python.yml

+12
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ jobs:
2424
permission: "write"
2525
env:
2626
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
- name: Install Protoc
28+
uses: arduino/setup-protoc@v3
29+
with:
30+
repo-token: ${{ secrets.GITHUB_TOKEN }}
2731
- name: Set up cargo cache
2832
uses: actions/cache@v3
2933
continue-on-error: false
@@ -121,6 +125,10 @@ jobs:
121125
permission: "write"
122126
env:
123127
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
128+
- name: Install Protoc
129+
uses: arduino/setup-protoc@v3
130+
with:
131+
repo-token: ${{ secrets.GITHUB_TOKEN }}
124132
- uses: actions/checkout@v3
125133
with:
126134
ref: ${{ inputs.base }}
@@ -157,6 +165,10 @@ jobs:
157165
permission: "write"
158166
env:
159167
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
168+
- name: Install Protoc
169+
uses: arduino/setup-protoc@v3
170+
with:
171+
repo-token: ${{ secrets.GITHUB_TOKEN }}
160172
- name: Set up cargo cache
161173
uses: actions/cache@v3
162174
continue-on-error: false

.github/workflows/_release_rust.yml

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ jobs:
3838
~/.cargo/git/db/
3939
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
4040
restore-keys: ${{ runner.os }}-cargo-
41+
- name: Install Protoc
42+
uses: arduino/setup-protoc@v3
43+
with:
44+
repo-token: ${{ secrets.GITHUB_TOKEN }}
4145
- uses: actions/checkout@v3
4246
- run: |
4347
git config --global user.email "[email protected]"

.github/workflows/benchmark.yml

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ jobs:
2525
name: Checkout
2626
- name: Update Rust
2727
run: rustup update
28+
- name: Install Protoc
29+
uses: arduino/setup-protoc@v3
30+
with:
31+
repo-token: ${{ secrets.GITHUB_TOKEN }}
2832
- name: Cargo cache
2933
uses: Swatinem/rust-cache@v2
3034
with:

.github/workflows/test_python_workflow.yml

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ jobs:
4646
toolchain: 1.77.0
4747
override: true
4848
components: rustfmt, clippy
49+
- name: Install Protoc
50+
uses: arduino/setup-protoc@v3
51+
with:
52+
repo-token: ${{ secrets.GITHUB_TOKEN }}
4953
- uses: webfactory/[email protected]
5054
name: Load raphtory-disk_graph key
5155
with:

.github/workflows/test_rust_disk_storage_workflow.yml

+8-5
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ jobs:
1414
runs-on: '${{ matrix.os }}'
1515
env:
1616
CARGO_NET_GIT_FETCH_WITH_CLI: true
17+
RUST_BACKTRACE: 1
1718
strategy:
1819
matrix:
1920
include:
2021
- os: macos-latest
21-
- os: ubuntu-latest
22+
- os: ubuntu-20.04
2223
- os: windows-latest
2324
steps:
2425
- uses: maxim-lobanov/setup-xcode@v1
@@ -36,7 +37,7 @@ jobs:
3637
override: true
3738
components: rustfmt, clippy
3839
- name: Free up space (ubuntu)
39-
if: matrix.os == 'ubuntu-latest'
40+
if: "contains(matrix.os, 'ubuntu')"
4041
run: |
4142
sudo rm -rf /usr/share/dotnet
4243
sudo rm -rf /usr/local/lib/android
@@ -52,10 +53,12 @@ jobs:
5253
name: Cargo cache
5354
with:
5455
cache-all-crates: true
55-
- name: Install bininstall
56-
uses: cargo-bins/cargo-binstall@main
56+
- name: Install Protoc
57+
uses: arduino/setup-protoc@v3
58+
with:
59+
repo-token: ${{ secrets.GITHUB_TOKEN }}
5760
- name: Install nextest
58-
run: cargo binstall -y --force cargo-nextest
61+
uses: taiki-e/install-action@nextest
5962
- name: Activate pometry-storage in Cargo.toml
6063
run: make pull-storage
6164
- name: Run all Tests (disk_graph)

.github/workflows/test_rust_workflow.yml

+12-5
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ jobs:
1414
runs-on: '${{ matrix.os }}'
1515
env:
1616
CARGO_NET_GIT_FETCH_WITH_CLI: true
17+
RUST_BACKTRACE: 1
1718
strategy:
1819
matrix:
1920
include:
2021
- os: macos-latest
21-
- os: ubuntu-latest
22+
- os: ubuntu-20.04
2223
- os: windows-latest
2324
steps:
2425
- uses: maxim-lobanov/setup-xcode@v1
@@ -36,12 +37,16 @@ jobs:
3637
override: true
3738
components: rustfmt, clippy
3839
- name: Free up space (ubuntu)
39-
if: matrix.os == 'ubuntu-latest'
40+
if: "contains(matrix.os, 'ubuntu')"
4041
run: |
4142
sudo rm -rf /usr/share/dotnet
4243
sudo rm -rf /usr/local/lib/android
4344
sudo rm -rf /opt/ghc
4445
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
46+
- name: Install Protoc
47+
uses: arduino/setup-protoc@v3
48+
with:
49+
repo-token: ${{ secrets.GITHUB_TOKEN }}
4550
- uses: webfactory/[email protected]
4651
name: Load pometry-storage key
4752
with:
@@ -52,10 +57,8 @@ jobs:
5257
name: Cargo cache
5358
with:
5459
cache-all-crates: true
55-
- name: Install bininstall
56-
uses: cargo-bins/cargo-binstall@main
5760
- name: Install nextest
58-
run: cargo binstall -y --force cargo-nextest
61+
uses: taiki-e/install-action@nextest
5962
- name: Run all Tests (no disk_graph)
6063
env:
6164
RUSTFLAGS: -Awarnings
@@ -80,6 +83,10 @@ jobs:
8083
toolchain: 1.77.0
8184
override: true
8285
components: rustfmt, clippy
86+
- name: Install Protoc
87+
uses: arduino/setup-protoc@v3
88+
with:
89+
repo-token: ${{ secrets.GITHUB_TOKEN }}
8390
- uses: Swatinem/rust-cache@v2
8491
name: Cargo cache
8592
with:

Cargo.lock

+79
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+5
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ url = "2.2"
127127
base64-compat = { package = "base64-compat", version = "1.0.0" }
128128
time = "0.3.36"
129129

130+
prost = "0.12"
131+
prost-types = "0.12"
132+
bytes = "1.6.0"
133+
prost-build = "0.12"
134+
130135
lazy_static = "1.4.0"
131136
pest = "2.7.8"
132137
pest_derive = "2.7.8"

python/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ crate-type = ["cdylib"]
1919

2020
[dependencies]
2121
pyo3 = { workspace = true }
22-
raphtory_core = { path = "../raphtory", version = "0.9.3", features = ["python", "search", "vectors"], package = "raphtory" }
22+
raphtory_core = { path = "../raphtory", version = "0.9.3", features = ["python", "search", "vectors", "proto"], package = "raphtory" }
2323
raphtory-graphql = { path = "../raphtory-graphql", version = "0.9.3",features = ["python"] }
2424
serde_json = { workspace = true }
2525
reqwest = { workspace = true }

python/tests/test_graphdb.py

+24
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import os
2020
import shutil
2121
import numpy as np
22+
import pickle
2223

2324
base_dir = Path(__file__).parent
2425
edges = [(1, 1, 2), (2, 1, 3), (-1, 2, 1), (0, 1, 1), (7, 3, 2), (1, 1, 1)]
@@ -59,6 +60,29 @@ def test_graph_len_edge_len():
5960
assert g.count_edges() == 5
6061

6162

63+
def test_graph_pickle():
64+
g = create_graph()
65+
# pickle graph
66+
with tempfile.TemporaryDirectory() as tmpdirname:
67+
pickle.dump(g, open(tmpdirname + "/graph.p", "wb"))
68+
# unpickle graph
69+
g2 = pickle.load(open(tmpdirname + "/graph.p", "rb"))
70+
71+
assert g2.count_nodes() == 3
72+
assert g2.count_edges() == 5
73+
74+
75+
def test_persistent_graph_pickle():
76+
g = create_graph_with_deletions()
77+
# pickle graph
78+
with tempfile.TemporaryDirectory() as tmpdirname:
79+
pickle.dump(g, open(tmpdirname + "/graph.p", "wb"))
80+
# unpickle graph
81+
g2 = pickle.load(open(tmpdirname + "/graph.p", "rb"))
82+
83+
assert g2.count_nodes() == 3
84+
assert g2.count_edges() == 5
85+
6286
def test_id_iterable():
6387
g = create_graph()
6488

raphtory-graphql/src/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ mod graphql_test {
5353
};
5454
use serde_json::json;
5555
use std::collections::{HashMap, HashSet};
56-
use tempfile::{tempdir, TempDir};
56+
use tempfile::tempdir;
57+
58+
#[cfg(feature = "storage")]
59+
use tempfile::TempDir;
5760

5861
#[tokio::test]
5962
async fn search_for_gandalf_query() {
@@ -266,7 +269,6 @@ mod graphql_test {
266269

267270
let req = Request::new(prop_has_key_filter);
268271
let res = schema.execute(req).await;
269-
let data = res.data.into_json().unwrap();
270272
let expected = json!({
271273
"graph": {
272274
"properties": {

0 commit comments

Comments
 (0)