Skip to content

Commit

Permalink
fix some python tests and remote warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianmurariu committed Dec 13, 2024
1 parent 139f1f5 commit 21706cf
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 40 deletions.
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
11 changes: 10 additions & 1 deletion raphtory-graphql/src/python/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::url_encode::{url_encode_graph, UrlDecodeError};
use crate::url_encode::{url_decode_graph, url_encode_graph, UrlDecodeError};
use async_graphql::{dynamic::ValueAccessor, Value as GraphqlValue};
use pyo3::{
exceptions::{PyTypeError, PyValueError},
Expand Down Expand Up @@ -116,6 +116,15 @@ pub(crate) fn encode_graph(graph: MaterializedGraph) -> PyResult<String> {
}
}

#[pyfunction]
pub(crate) fn decode_graph(graph: &str) -> PyResult<MaterializedGraph> {
let result = url_decode_graph(graph);
match result {
Ok(g) => Ok(g),
Err(e) => Err(PyValueError::new_err(format!("Error decoding: {:?}", e))),
}
}

impl From<UrlDecodeError> for PyErr {
fn from(value: UrlDecodeError) -> Self {
adapt_err_value(&value)
Expand Down
3 changes: 2 additions & 1 deletion raphtory-graphql/src/python/pymodule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::python::{
raphtory_client::PyRaphtoryClient, remote_edge::PyRemoteEdge, remote_graph::PyRemoteGraph,
remote_node::PyRemoteNode, PyEdgeAddition, PyNodeAddition, PyUpdate,
},
encode_graph,
decode_graph, encode_graph,
global_plugins::PyGlobalPlugins,
server::{running_server::PyRunningGraphServer, server::PyGraphServer},
};
Expand All @@ -23,6 +23,7 @@ pub fn base_graphql_module(py: Python<'_>) -> Result<Bound<PyModule>, PyErr> {
graphql_module.add_class::<PyEdgeAddition>()?;

graphql_module.add_function(wrap_pyfunction!(encode_graph, &graphql_module)?)?;
graphql_module.add_function(wrap_pyfunction!(decode_graph, &graphql_module)?)?;

Ok(graphql_module)
}
24 changes: 0 additions & 24 deletions raphtory/src/core/entities/properties/tprop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use chrono::{DateTime, NaiveDateTime, Utc};
use raphtory_api::core::storage::arc_str::ArcStr;
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, iter, ops::Range, sync::Arc};
// TODO TProp struct could be replaced with Option<TCell<Prop>>, with the only issue (or advantage) that then the type can change?

#[derive(Debug, Default, PartialEq, Clone, Serialize, Deserialize)]
pub enum TProp {
Expand Down Expand Up @@ -135,29 +134,6 @@ impl TProp {
}
}

pub(crate) fn remove(&mut self, t: &TimeIndexEntry) -> Option<Prop> {
match self {
TProp::Empty => None,
TProp::Str(cell) => cell.remove(t).map(Prop::Str),
TProp::I32(cell) => cell.remove(t).map(Prop::I32),
TProp::I64(cell) => cell.remove(t).map(Prop::I64),
TProp::U8(cell) => cell.remove(t).map(Prop::U8),
TProp::U16(cell) => cell.remove(t).map(Prop::U16),
TProp::U32(cell) => cell.remove(t).map(Prop::U32),
TProp::U64(cell) => cell.remove(t).map(Prop::U64),
TProp::F32(cell) => cell.remove(t).map(Prop::F32),
TProp::F64(cell) => cell.remove(t).map(Prop::F64),
TProp::Bool(cell) => cell.remove(t).map(Prop::Bool),
TProp::DTime(cell) => cell.remove(t).map(Prop::DTime),
TProp::NDTime(cell) => cell.remove(t).map(Prop::NDTime),
TProp::Graph(cell) => cell.remove(t).map(Prop::Graph),
TProp::PersistentGraph(cell) => cell.remove(t).map(Prop::PersistentGraph),
TProp::Document(cell) => cell.remove(t).map(Prop::Document),
TProp::List(cell) => cell.remove(t).map(Prop::List),
TProp::Map(cell) => cell.remove(t).map(Prop::Map),
}
}

pub(crate) fn set(&mut self, t: TimeIndexEntry, prop: Prop) -> Result<(), GraphError> {
if matches!(self, TProp::Empty) {
*self = TProp::from(t, prop);
Expand Down
4 changes: 1 addition & 3 deletions raphtory/src/db/api/mutation/import_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ use crate::{
mutation::internal::{
InternalAdditionOps, InternalDeletionOps, InternalPropertyAdditionOps,
},
properties::internal::{
TemporalPropertiesOps, TemporalPropertiesRowView, TemporalPropertyViewOps,
},
properties::internal::{TemporalPropertiesOps, TemporalPropertiesRowView},
view::{internal::InternalMaterialize, StaticGraphViewOps},
},
graph::{edge::EdgeView, node::NodeView},
Expand Down
4 changes: 1 addition & 3 deletions raphtory/src/db/api/storage/graph/nodes/row.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use crate::core::{storage::TColumns, Prop};
#[cfg(feature = "storage")]
use pometry_storage::{
graph::TemporalGraph, properties::TemporalProps, timestamps::TimeStamps, tprops::DiskTProp,
};
use raphtory_api::core::{entities::VID, storage::timeindex::TimeIndexEntry};

use crate::core::{storage::TColumns, Prop};

#[derive(Debug, Copy, Clone)]
pub enum Row<'a> {
Expand Down
5 changes: 2 additions & 3 deletions raphtory/src/search/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ use crate::{
},
prelude::*,
};
use itertools::Itertools;
use raphtory_api::core::{
entities::GidType,
storage::{arc_str::ArcStr, dict_mapper::MaybeNew},
Expand All @@ -46,10 +45,10 @@ use tantivy::{
query::QueryParser,
schema::{
Field, IndexRecordOption, JsonObjectOptions, Schema, SchemaBuilder, TextFieldIndexing,
TextOptions, Value, FAST, INDEXED, STORED, TEXT,
TextOptions, Value, FAST, INDEXED, STORED,
},
tokenizer::{LowerCaser, SimpleTokenizer, TextAnalyzer},
Document, Index, IndexReader, IndexSettings, IndexWriter, TantivyDocument, TantivyError,
Index, IndexReader, IndexSettings, IndexWriter, TantivyDocument, TantivyError,
};

#[derive(Clone)]
Expand Down

0 comments on commit 21706cf

Please sign in to comment.