Skip to content

Commit

Permalink
fix: drop instead of truncate
Browse files Browse the repository at this point in the history
  • Loading branch information
aMahanna committed Sep 30, 2024
1 parent 69124a4 commit 11347c9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 20 deletions.
9 changes: 5 additions & 4 deletions nx_arangodb/classes/digraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,11 @@ class DiGraph(Graph, nx.DiGraph):
as expected.
overwrite_graph : bool (optional, default: False)
Whether to truncate the graph collections when the graph is loaded from
the database. If set to True, the graph collections will be truncated
before loading the graph data. NOTE: This parameter only applies if the
graph already exists in the database.
Whether to drop & re-create the graph collections before loading
**incoming_graph_data** into the graph. NOTE: This parameter only
applies if the graph already exists in the database. NOTE: Dropping
the graph collections will erase all properties of the collections, including
created indexes.
args: positional arguments for nx.Graph
Additional arguments passed to nx.Graph.
Expand Down
20 changes: 12 additions & 8 deletions nx_arangodb/classes/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,11 @@ class Graph(nx.Graph):
as expected.
overwrite_graph : bool (optional, default: False)
Whether to truncate the graph collections when the graph is loaded from
the database. If set to True, the graph collections will be truncated
before loading the graph data. NOTE: This parameter only applies if the
graph already exists in the database.
Whether to drop & re-create the graph collections before loading
**incoming_graph_data** into the graph. NOTE: This parameter only
applies if the graph already exists in the database. NOTE: Dropping
the graph collections will erase all properties of the collections, including
created indexes.
args: positional arguments for nx.Graph
Additional arguments passed to nx.Graph.
Expand Down Expand Up @@ -231,13 +232,16 @@ def __init__(
self.__set_arangodb_backend_config(read_parallelism, read_batch_size)

if overwrite_graph:
logger.info("Truncating graph collections...")
logger.info("Overwriting graph collections...")

for col in self.adb_graph.vertex_collections():
self.db.collection(col).truncate()
self.db.delete_collection(col)
self.db.create_collection(col)

for col in self.adb_graph.edge_definitions():
self.db.collection(col["edge_collection"]).truncate()
for ed in self.adb_graph.edge_definitions():
col = ed["edge_collection"]
self.db.delete_collection(col)
self.db.create_collection(col, edge=True)

if isinstance(incoming_graph_data, nx.Graph):
self._load_nx_graph(incoming_graph_data, write_batch_size, write_async)
Expand Down
9 changes: 5 additions & 4 deletions nx_arangodb/classes/multidigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,11 @@ class MultiDiGraph(MultiGraph, DiGraph, nx.MultiDiGraph):
as expected.
overwrite_graph : bool (optional, default: False)
Whether to truncate the graph collections when the graph is loaded from
the database. If set to True, the graph collections will be truncated
before loading the graph data. NOTE: This parameter only applies if the
graph already exists in the database.
Whether to drop & re-create the graph collections before loading
**incoming_graph_data** into the graph. NOTE: This parameter only
applies if the graph already exists in the database. NOTE: Dropping
the graph collections will erase all properties of the collections, including
created indexes.
args: positional arguments for nx.Graph
Additional arguments passed to nx.Graph.
Expand Down
9 changes: 5 additions & 4 deletions nx_arangodb/classes/multigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,11 @@ class MultiGraph(Graph, nx.MultiGraph):
as expected.
overwrite_graph : bool (optional, default: False)
Whether to truncate the graph collections when the graph is loaded from
the database. If set to True, the graph collections will be truncated
before loading the graph data. NOTE: This parameter only applies if the
graph already exists in the database.
Whether to drop & re-create the graph collections before loading
**incoming_graph_data** into the graph. NOTE: This parameter only
applies if the graph already exists in the database. NOTE: Dropping
the graph collections will erase all properties of the collections, including
created indexes.
args: positional arguments for nx.Graph
Additional arguments passed to nx.Graph.
Expand Down

0 comments on commit 11347c9

Please sign in to comment.