From aa2881f40fd735acbf1c0d91ed9125b0e42a014e Mon Sep 17 00:00:00 2001 From: Anthony Mahanna Date: Wed, 21 Aug 2024 12:55:45 -0400 Subject: [PATCH 1/4] new: `use_experimental_views` --- nx_arangodb/classes/digraph.py | 2 ++ nx_arangodb/classes/graph.py | 9 +++++---- nx_arangodb/classes/multidigraph.py | 2 ++ nx_arangodb/classes/multigraph.py | 3 +++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/nx_arangodb/classes/digraph.py b/nx_arangodb/classes/digraph.py index a887fd58..054b1510 100644 --- a/nx_arangodb/classes/digraph.py +++ b/nx_arangodb/classes/digraph.py @@ -34,6 +34,7 @@ def __init__( read_batch_size: int = 100000, write_batch_size: int = 50000, symmetrize_edges: bool = False, + use_experimental_views: bool = False, *args: Any, **kwargs: Any, ): @@ -48,6 +49,7 @@ def __init__( read_batch_size, write_batch_size, symmetrize_edges, + use_experimental_views, *args, **kwargs, ) diff --git a/nx_arangodb/classes/graph.py b/nx_arangodb/classes/graph.py index a809ac5e..a7601b74 100644 --- a/nx_arangodb/classes/graph.py +++ b/nx_arangodb/classes/graph.py @@ -55,18 +55,19 @@ def __init__( read_batch_size: int = 100000, write_batch_size: int = 50000, symmetrize_edges: bool = False, + use_experimental_views: bool = False, *args: Any, **kwargs: Any, ): self._db = None self.__name = None self._graph_exists_in_db = False + self.__use_experimental_views = use_experimental_views self._set_db(db) if self._db is not None: self._set_graph_name(name) - # We need to store the data transfer properties as some functions will need them self.read_parallelism = read_parallelism self.read_batch_size = read_batch_size self.write_batch_size = write_batch_size @@ -395,7 +396,7 @@ def clear_nxcg_cache(self): @cached_property def nodes(self): - if self.graph_exists_in_db: + if self.__use_experimental_views and self.graph_exists_in_db: logger.warning("nxadb.CustomNodeView is currently EXPERIMENTAL") return CustomNodeView(self) @@ -403,7 +404,7 @@ def nodes(self): @cached_property def adj(self): - if self.graph_exists_in_db: + if self.__use_experimental_views and self.graph_exists_in_db: logger.warning("nxadb.CustomAdjacencyView is currently EXPERIMENTAL") return CustomAdjacencyView(self._adj) @@ -411,7 +412,7 @@ def adj(self): @cached_property def edges(self): - if self.graph_exists_in_db: + if self.__use_experimental_views and self.graph_exists_in_db: if self.is_directed(): logger.warning("CustomEdgeView for Directed Graphs not yet implemented") return super().edges diff --git a/nx_arangodb/classes/multidigraph.py b/nx_arangodb/classes/multidigraph.py index d208bf32..4600bcfc 100644 --- a/nx_arangodb/classes/multidigraph.py +++ b/nx_arangodb/classes/multidigraph.py @@ -33,6 +33,7 @@ def __init__( read_batch_size: int = 100000, write_batch_size: int = 50000, symmetrize_edges: bool = False, + use_experimental_views: bool = False, *args: Any, **kwargs: Any, ): @@ -47,6 +48,7 @@ def __init__( read_batch_size, write_batch_size, symmetrize_edges, + use_experimental_views, *args, **kwargs, ) diff --git a/nx_arangodb/classes/multigraph.py b/nx_arangodb/classes/multigraph.py index 9a7d63c1..65b80d2a 100644 --- a/nx_arangodb/classes/multigraph.py +++ b/nx_arangodb/classes/multigraph.py @@ -33,6 +33,8 @@ def __init__( read_parallelism: int = 10, read_batch_size: int = 100000, write_batch_size: int = 50000, + symmetrize_edges: bool = False, + use_experimental_views: bool = False, *args: Any, **kwargs: Any, ): @@ -46,6 +48,7 @@ def __init__( read_parallelism, read_batch_size, write_batch_size, + use_experimental_views, *args, **kwargs, ) From 9d4954a820e7b0d8e698d87d7ec992f9d8e32634 Mon Sep 17 00:00:00 2001 From: Anthony Mahanna Date: Wed, 21 Aug 2024 13:05:15 -0400 Subject: [PATCH 2/4] set experimental views --- tests/test.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/test.py b/tests/test.py index c9d7d259..f6e9d388 100644 --- a/tests/test.py +++ b/tests/test.py @@ -329,7 +329,7 @@ def test_node_dict_update_existing_single_collection( ) -> None: # This tests uses the existing nodes and updates each # of them using the update method using a single collection - G_1 = nxadb.Graph(name="KarateGraph", foo="bar") + G_1 = nxadb.Graph(name="KarateGraph", foo="bar", use_experimental_views=True) nodes_ids_list = G_1.nodes local_nodes_dict = {} @@ -379,7 +379,9 @@ def test_node_dict_update_multiple_collections( assert db.collection(e_1_name).count() == 0 assert db.collection(e_2_name).count() == 0 - G_1 = graph_cls(name=graph_name, default_node_type=v_1_name) + G_1 = graph_cls( + name=graph_name, default_node_type=v_1_name, use_experimental_views=True + ) assert len(G_1.nodes) == 0 assert len(G_1.edges) == 0 @@ -419,7 +421,7 @@ def test_node_dict_update_multiple_collections( def test_edge_adj_dict_update_existing_single_collection_graph_and_digraph( load_karate_graph: Any, graph_cls: type[nxadb.Graph] ) -> None: - G_1 = graph_cls(name="KarateGraph", foo="bar") + G_1 = graph_cls(name="KarateGraph", foo="bar", use_experimental_views=True) local_adj = G_1.adj local_edges_dict: Union[GraphAdjDict | DiGraphAdjDict] = {} @@ -468,7 +470,7 @@ def test_edge_adj_dict_update_existing_single_collection_graph_and_digraph( def test_edge_adj_dict_update_existing_single_collection_MultiGraph_and_MultiDiGraph( load_karate_graph: Any, graph_cls: type[nxadb.Graph] ) -> None: - G_1 = graph_cls(name="KarateGraph", foo="bar") + G_1 = graph_cls(name="KarateGraph", foo="bar", use_experimental_views=True) local_adj = G_1.adj local_edges_dict: Union[MultiGraphAdjDict | MultiDiGraphAdjDict] = {} From 491a03162940979b583651b409252e5ce7a67fd9 Mon Sep 17 00:00:00 2001 From: Anthony Mahanna Date: Wed, 21 Aug 2024 13:09:50 -0400 Subject: [PATCH 3/4] attempt fix: constructor --- nx_arangodb/classes/multigraph.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nx_arangodb/classes/multigraph.py b/nx_arangodb/classes/multigraph.py index 65b80d2a..5f5d925f 100644 --- a/nx_arangodb/classes/multigraph.py +++ b/nx_arangodb/classes/multigraph.py @@ -48,6 +48,7 @@ def __init__( read_parallelism, read_batch_size, write_batch_size, + symmetrize_edges, use_experimental_views, *args, **kwargs, From 48118b6a1b41b589bb1dc93fc9586e8b89a4a3aa Mon Sep 17 00:00:00 2001 From: Anthony Mahanna Date: Wed, 21 Aug 2024 13:22:50 -0400 Subject: [PATCH 4/4] set experimental again --- tests/test.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test.py b/tests/test.py index f6e9d388..bec8c021 100644 --- a/tests/test.py +++ b/tests/test.py @@ -525,7 +525,9 @@ def test_edge_dict_update_multiple_collections(load_two_relation_graph: Any) -> assert db.collection(e_1_name).count() == 0 assert db.collection(e_2_name).count() == 0 - G_1 = nxadb.Graph(name=graph_name, default_node_type=v_1_name) + G_1 = nxadb.Graph( + name=graph_name, default_node_type=v_1_name, use_experimental_views=True + ) assert len(G_1.nodes) == 0 assert len(G_1.edges) == 0