Spaces:
Running
Running
github-actions[bot]
commited on
Commit
·
b1922c7
1
Parent(s):
6978916
Auto-sync from demo at Wed Jan 14 13:01:22 UTC 2026
Browse files
graphgen/models/storage/graph/kuzu_storage.py
CHANGED
|
@@ -343,12 +343,12 @@ class KuzuStorage(BaseGraphStorage):
|
|
| 343 |
Note: We explicitly ensure nodes exist before merging the edge to avoid errors,
|
| 344 |
although GraphGen generally creates nodes before edges.
|
| 345 |
"""
|
| 346 |
-
# Ensure source node exists
|
| 347 |
-
if not self.has_node(source_node_id):
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
|
| 353 |
try:
|
| 354 |
json_data = json.dumps(edge_data, ensure_ascii=False)
|
|
|
|
| 343 |
Note: We explicitly ensure nodes exist before merging the edge to avoid errors,
|
| 344 |
although GraphGen generally creates nodes before edges.
|
| 345 |
"""
|
| 346 |
+
# Ensure source node exists and target node exists
|
| 347 |
+
if not self.has_node(source_node_id) or not self.has_node(target_node_id):
|
| 348 |
+
print(
|
| 349 |
+
f"Cannot upsert edge {source_node_id}->{target_node_id} as one or both nodes do not exist."
|
| 350 |
+
)
|
| 351 |
+
return
|
| 352 |
|
| 353 |
try:
|
| 354 |
json_data = json.dumps(edge_data, ensure_ascii=False)
|
graphgen/models/storage/graph/networkx_storage.py
CHANGED
|
@@ -156,6 +156,14 @@ class NetworkXStorage(BaseGraphStorage):
|
|
| 156 |
def upsert_edge(
|
| 157 |
self, source_node_id: str, target_node_id: str, edge_data: dict[str, any]
|
| 158 |
):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
self._graph.add_edge(source_node_id, target_node_id, **edge_data)
|
| 160 |
|
| 161 |
def update_edge(
|
|
|
|
| 156 |
def upsert_edge(
|
| 157 |
self, source_node_id: str, target_node_id: str, edge_data: dict[str, any]
|
| 158 |
):
|
| 159 |
+
# Ensure both nodes exist before adding the edge
|
| 160 |
+
if not self._graph.has_node(source_node_id) or not self._graph.has_node(
|
| 161 |
+
target_node_id
|
| 162 |
+
):
|
| 163 |
+
print(
|
| 164 |
+
f"Cannot upsert edge {source_node_id} -> {target_node_id} because one or both nodes do not exist."
|
| 165 |
+
)
|
| 166 |
+
return
|
| 167 |
self._graph.add_edge(source_node_id, target_node_id, **edge_data)
|
| 168 |
|
| 169 |
def update_edge(
|