Skip to content
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

Feature/par execution continued #1630

Merged
merged 29 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b3bbd65
wip node_state interface
ljeub-pometry Mar 22, 2024
ead9834
Implement NodeState apis
ljeub-pometry Mar 25, 2024
86595ff
implement NodeStateOps for LazyNodeState
ljeub-pometry Mar 25, 2024
3288d66
return LazyNodeState for Nodes operations
ljeub-pometry Mar 25, 2024
300972d
improvements to node state
ljeub-pometry Mar 27, 2024
2aa474e
fixes after rebase
ljeub-pometry Apr 17, 2024
af6131d
fix rebase
ljeub-pometry May 7, 2024
bbbba54
compiles but python interface not useful yet
ljeub-pometry May 8, 2024
7df4f13
add some methods to node state
ljeub-pometry May 8, 2024
7de1cba
python macro work
ljeub-pometry May 22, 2024
6879228
start thinking about better python iterators
ljeub-pometry May 28, 2024
272abc5
this compiles
ljeub-pometry May 29, 2024
5bd72c2
cleanup
ljeub-pometry May 29, 2024
3b24ce5
add more methods to the python implementation
ljeub-pometry May 30, 2024
e21f71b
add sum and median in python
ljeub-pometry May 30, 2024
f28df64
clean up imports
ljeub-pometry May 31, 2024
3eab9c4
clean up
ljeub-pometry Jun 3, 2024
6e3c8bf
fix the node types filter
ljeub-pometry Jun 3, 2024
e363a1a
fix import
ljeub-pometry Jun 3, 2024
d521c12
generalise collect and only implement it for the lazy state
ljeub-pometry Jun 3, 2024
cebf10e
more cleanup
ljeub-pometry Jun 3, 2024
19e44e2
simplify the testing
ljeub-pometry Jun 3, 2024
f992222
try splitting up the workflows for the rust tests
ljeub-pometry Jun 5, 2024
19d5f04
fix the workflows
ljeub-pometry Jun 5, 2024
2e26fd4
fix the bechmark
ljeub-pometry Jun 5, 2024
36b10b8
more benchmark fixes
ljeub-pometry Jun 5, 2024
ad20136
add repr for node state
ljeub-pometry Jun 5, 2024
40a77c1
add equality check support for python node state
ljeub-pometry Jun 5, 2024
4b78187
fmt
fabianmurariu Jun 11, 2024
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
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ jobs:
name: Run Rust tests
uses: ./.github/workflows/test_rust_workflow.yml
secrets: inherit
call-test-rust-storage-workflow-in-local-repo:
name: Run Rust storage tests
uses: ./.github/workflows/test_rust_disk_storage_workflow.yml
secrets: inherit
call-test-python-workflow-in-local-repo:
name: Run Python tests
uses: ./.github/workflows/test_python_workflow.yml
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/test_during_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true


jobs:
rust-format-check:
name: Rust format check
Expand All @@ -18,6 +17,11 @@ jobs:
uses: ./.github/workflows/test_rust_workflow.yml
secrets: inherit
needs: rust-format-check
call-test-rust-storage-workflow-in-local-repo:
name: Run Rust storage tests
uses: ./.github/workflows/test_rust_disk_storage_workflow.yml
secrets: inherit
needs: rust-format-check
call-test-python-workflow-in-local-repo:
name: Run Python tests
uses: ./.github/workflows/test_python_workflow.yml
Expand Down
91 changes: 91 additions & 0 deletions .github/workflows/test_rust_disk_storage_workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Run Rust test
on:
workflow_call:
inputs:
skip_tests:
type: boolean
default: false
required: false
# DO NOT CHANGE NAME OF WORKFLOW, USED IN OTHER WORKFLOWS KEEP "Rust Tests"
jobs:
rust-test:
if: ${{ !inputs.skip_tests }}
name: Rust Tests
runs-on: '${{ matrix.os }}'
env:
CARGO_NET_GIT_FETCH_WITH_CLI: true
strategy:
matrix:
include:
- os: macos-latest
- os: ubuntu-latest
- os: windows-latest
steps:
- uses: maxim-lobanov/setup-xcode@v1
name: Xcode version
if: "contains(matrix.os, 'macOS')"
with:
xcode-version: latest-stable
- uses: actions/checkout@v3
name: Checkout
- uses: actions-rs/toolchain@v1
name: Setup Rust
with:
profile: minimal
toolchain: 1.77.0
override: true
components: rustfmt, clippy
- name: Free up space (ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- uses: webfactory/[email protected]
name: Load pometry-storage key
with:
ssh-private-key: ${{ secrets.RA_SSH_PRIVATE_KEY }}
- name: Rust version
run: rustc --version --verbose
- uses: Swatinem/rust-cache@v2
name: Cargo cache
with:
cache-all-crates: true
- name: Install bininstall
uses: cargo-bins/cargo-binstall@main
- name: Install nextest
run: cargo binstall -y --force cargo-nextest
- name: Activate pometry-storage in Cargo.toml
run: make pull-storage
- name: Run all Tests (disk_graph)
env:
RUSTFLAGS: -Awarnings
TEMPDIR: ${{ runner.temp }}
run: |
cargo nextest run --all --no-default-features --features "storage"
- name: Run Tests (features=io)
env:
RUSTFLAGS: -Awarnings
run: |
cargo check -p raphtory --no-default-features --features "io"
- name: Run Tests (features=python)
env:
RUSTFLAGS: -Awarnings
run: |
cargo check -p raphtory --no-default-features --features "python"
- name: Run Tests (features=search)
env:
RUSTFLAGS: -Awarnings
run: |
cargo check -p raphtory --no-default-features --features "search"
- name: Run Tests (features=vectors)
env:
RUSTFLAGS: -Awarnings
run: |
cargo check -p raphtory --no-default-features --features "vectors"
- name: Run Tests (features=storage)
env:
RUSTFLAGS: -Awarnings
run: |
cargo check -p raphtory --no-default-features --features "storage"
35 changes: 1 addition & 34 deletions .github/workflows/test_rust_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
required: false
# DO NOT CHANGE NAME OF WORKFLOW, USED IN OTHER WORKFLOWS KEEP "Rust Tests"
jobs:
rust-test:
rust-test-no-storage:
if: ${{ !inputs.skip_tests }}
name: Rust Tests
runs-on: '${{ matrix.os }}'
Expand Down Expand Up @@ -62,39 +62,6 @@ jobs:
TEMPDIR: ${{ runner.temp }}
run: |
cargo nextest run --all --no-default-features
- name: Activate pometry-storage in Cargo.toml
run: make pull-storage
- name: Run all Tests (disk_graph)
env:
RUSTFLAGS: -Awarnings
TEMPDIR: ${{ runner.temp }}
run: |
cargo nextest run --all --no-default-features --features "storage"
- name: Run Tests (features=io)
env:
RUSTFLAGS: -Awarnings
run: |
cargo check -p raphtory --no-default-features --features "io"
- name: Run Tests (features=python)
env:
RUSTFLAGS: -Awarnings
run: |
cargo check -p raphtory --no-default-features --features "python"
- name: Run Tests (features=search)
env:
RUSTFLAGS: -Awarnings
run: |
cargo check -p raphtory --no-default-features --features "search"
- name: Run Tests (features=vectors)
env:
RUSTFLAGS: -Awarnings
run: |
cargo check -p raphtory --no-default-features --features "vectors"
- name: Run Tests (features=storage)
env:
RUSTFLAGS: -Awarnings
run: |
cargo check -p raphtory --no-default-features --features "storage"
doc-test:
if: ${{ !inputs.skip_tests }}
name: "Doc tests"
Expand Down
2 changes: 1 addition & 1 deletion js-raphtory/src/graph/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl From<JsProp> for JsValue {
)
.into(),
Prop::Graph(v) => Graph(UnderGraph::TGraph(Arc::new(v))).into(),
Prop::PersistentGraph(v) => todo!("PersistentGraph not yet implemented"),
Prop::PersistentGraph(_v) => todo!("PersistentGraph not yet implemented"),
Prop::List(v) => {
let v: Array = v.iter().map(|v| JsValue::from(JsProp(v.clone()))).collect();
v.into()
Expand Down
34 changes: 17 additions & 17 deletions raphtory-benchmark/benches/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ use criterion::{
black_box, measurement::WallTime, BatchSize, Bencher, BenchmarkGroup, BenchmarkId,
};
use rand::{distributions::Uniform, seq::*, Rng};
use raphtory::{core::entities::LayerIds, db::api::view::StaticGraphViewOps, prelude::*};
use raphtory::{
core::entities::{LayerIds, VID},
db::api::view::StaticGraphViewOps,
prelude::*,
};
use std::collections::HashSet;

fn make_index_gen() -> Box<dyn Iterator<Item = u64>> {
Expand Down Expand Up @@ -285,7 +289,7 @@ pub fn run_analysis_benchmarks<F, G>(
.map(|e| (e.src().id(), e.dst().id(), e.time().expect("need time")))
.collect::<Vec<_>>();

let nodes: HashSet<u64> = graph.nodes().id().collect();
let nodes: HashSet<u64> = graph.nodes().id().into_iter().collect();

bench(group, "num_edges", parameter, |b: &mut Bencher| {
b.iter(|| graph.count_edges())
Expand Down Expand Up @@ -422,19 +426,15 @@ pub fn run_analysis_benchmarks<F, G>(
let mg = graph.materialize();
black_box(mg)
})
})

// Too noisy due to degree variability and confuses criterion
// bench(
// group,
// "max_neighbour_degree",
// parameter,
// |b: &mut Bencher| {
// let mut rng = rand::thread_rng();
// let v = graph
// .node(*nodes.iter().choose(&mut rng).expect("non-empty graph"))
// .expect("existing node");
// b.iter(|| v.neighbours().degree().max())
// },
// );
});

bench(
group,
"max_neighbour_degree",
parameter,
|b: &mut Bencher| {
let v = graph.node(VID(0)).expect("graph should not be empty");
b.iter(|| v.neighbours().degree().max())
},
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ where
}

if let Some(max_label) = find_max_label(&label_count) {
if max_label != labels[&node] {
if max_label != labels[node] {
labels.insert(node.clone(), max_label);
changed = true;
}
Expand Down
12 changes: 9 additions & 3 deletions raphtory/src/algorithms/metrics/degree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
//! print!("Average degree: {:?}", average_degree(&windowed_graph));
//! ```
//!
use crate::db::api::view::*;
use crate::{db::api::view::*, prelude::*};
use rayon::prelude::*;

/// The maximum degree of any node in the graph
pub fn max_degree<'graph, G: GraphViewOps<'graph>>(graph: &G) -> usize {
Expand Down Expand Up @@ -80,9 +81,14 @@ pub fn average_degree<'graph, G: GraphViewOps<'graph>>(graph: &'graph G) -> f64
let (deg_sum, count) = graph
.nodes()
.degree()
.fold((0usize, 0usize), |(deg_sum, count), deg| {
.par_values()
.fold_with((0usize, 0usize), |(deg_sum, count), deg| {
(deg_sum + deg, count + 1)
});
})
.reduce_with(|(deg_sum1, count1), (deg_sum2, count2)| {
(deg_sum1 + deg_sum2, count1 + count2)
})
.unwrap_or((0, 1));

deg_sum as f64 / count as f64
}
Expand Down
2 changes: 1 addition & 1 deletion raphtory/src/algorithms/pathing/dijkstra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pub fn dijkstra_single_source_shortest_paths<G: StaticGraphViewOps, T: AsNodeRef
let mut current_node_name = node_name.clone();
while let Some(prev_node) = predecessor.get(&current_node_name) {
path.push(prev_node.clone());
current_node_name = prev_node.clone();
current_node_name.clone_from(prev_node);
}
path.reverse();
paths.insert(node_name.clone(), (cost.clone(), path));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use itertools::Itertools;
use num_integer::average_floor;
extern crate num_integer;

use crate::{
core::entities::nodes::node_ref::AsNodeRef,
db::{
Expand Down Expand Up @@ -62,8 +61,6 @@ fn populate_edges<G: StaticGraphViewOps, V: AsNodeRef>(g: &G, new_graph: &Graph,
}
to_process.push(nb.clone());
}
} else {
return;
}
}

Expand Down
6 changes: 6 additions & 0 deletions raphtory/src/core/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ impl<T: PartialEq + Default> PartialEq for LockVec<T> {
}
}

impl<T: Default> Default for LockVec<T> {
fn default() -> Self {
Self::new()
}
}

impl<T: Default> LockVec<T> {
pub fn new() -> Self {
Self {
Expand Down
1 change: 1 addition & 0 deletions raphtory/src/db/api/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod mutation;
pub mod properties;
pub mod state;
pub mod storage;
pub mod view;
8 changes: 3 additions & 5 deletions raphtory/src/db/api/properties/temporal_props.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,9 @@ impl<P: PropertiesOps> TemporalPropertyView<P> {
current_entry = Some((t, prop.clone()));
}
last_seen_value = Some(prop.clone());
} else {
if last_seen_value != Some(prop.clone()) {
result.push((t, prop.clone()));
last_seen_value = Some(prop.clone());
}
} else if last_seen_value != Some(prop.clone()) {
result.push((t, prop.clone()));
last_seen_value = Some(prop.clone());
}
}

Expand Down
1 change: 1 addition & 0 deletions raphtory/src/db/api/state/group_by.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading
Loading