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..5f5d925f 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,8 @@ def __init__( read_parallelism, read_batch_size, write_batch_size, + symmetrize_edges, + use_experimental_views, *args, **kwargs, ) diff --git a/tests/test.py b/tests/test.py index c9d7d259..bec8c021 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] = {} @@ -523,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