Skip to content

Commit

Permalink
fix: GraphNotEmpty logic
Browse files Browse the repository at this point in the history
  • Loading branch information
aMahanna committed Sep 26, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 8ab094b commit 753b632
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions nx_arangodb/classes/graph.py
Original file line number Diff line number Diff line change
@@ -446,18 +446,18 @@ def edge_type_func(u: str, v: str) -> str:
def _load_nx_graph(
self, nx_graph: nx.Graph, write_batch_size: int, write_async: bool
) -> None:
v_count = sum(
self.db.collection(v).count() for v in self.adb_graph.vertex_collections()
)
collections = list(self.adb_graph.vertex_collections())
collections += [e["edge_collection"] for e in self.adb_graph.edge_definitions()]

e_count = sum(
self.db.collection(e["edge_collection"]).count()
for e in self.adb_graph.edge_definitions()
)
for col in collections:
cursor = self.db.aql.execute(
"FOR doc IN @@collection LIMIT 1 RETURN 1",
bind_vars={"@collection": col},
)

if v_count > 0 or e_count > 0:
m = f"Graph '{self.adb_graph.name}' already has data. Use **overwrite_graph=True** to clear it." # noqa: E501
raise GraphNotEmpty(m)
if not cursor.empty():
m = f"Graph '{self.adb_graph.name}' already has data (in '{col}'). Use **overwrite_graph=True** to clear it." # noqa: E501
raise GraphNotEmpty(m)

controller = ADBNX_Controller

0 comments on commit 753b632

Please sign in to comment.