fixed already edge
This commit is contained in:
@@ -239,39 +239,36 @@ async def _merge_edges_then_upsert(
|
|||||||
|
|
||||||
if await knowledge_graph_inst.has_edge(src_id, tgt_id):
|
if await knowledge_graph_inst.has_edge(src_id, tgt_id):
|
||||||
already_edge = await knowledge_graph_inst.get_edge(src_id, tgt_id)
|
already_edge = await knowledge_graph_inst.get_edge(src_id, tgt_id)
|
||||||
|
if not already_edge:
|
||||||
|
return
|
||||||
# Handle the case where get_edge returns None or missing fields
|
# Handle the case where get_edge returns None or missing fields
|
||||||
if already_edge:
|
|
||||||
# Get weight with default 0.0 if missing
|
# Get weight with default 0.0 if missing
|
||||||
if "weight" in already_edge:
|
if "weight" in already_edge:
|
||||||
already_weights.append(already_edge["weight"])
|
already_weights.append(already_edge["weight"])
|
||||||
else:
|
else:
|
||||||
logger.warning(
|
logger.warning(f"Edge between {src_id} and {tgt_id} missing weight field")
|
||||||
f"Edge between {src_id} and {tgt_id} missing weight field"
|
already_weights.append(0.0)
|
||||||
)
|
|
||||||
already_weights.append(0.0)
|
|
||||||
|
|
||||||
# Get source_id with empty string default if missing or None
|
# Get source_id with empty string default if missing or None
|
||||||
if "source_id" in already_edge and already_edge["source_id"] is not None:
|
if "source_id" in already_edge and already_edge["source_id"] is not None:
|
||||||
already_source_ids.extend(
|
already_source_ids.extend(
|
||||||
split_string_by_multi_markers(
|
split_string_by_multi_markers(
|
||||||
already_edge["source_id"], [GRAPH_FIELD_SEP]
|
already_edge["source_id"], [GRAPH_FIELD_SEP]
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
# Get description with empty string default if missing or None
|
# Get description with empty string default if missing or None
|
||||||
if (
|
if "description" in already_edge and already_edge["description"] is not None:
|
||||||
"description" in already_edge
|
already_description.append(already_edge["description"])
|
||||||
and already_edge["description"] is not None
|
|
||||||
):
|
|
||||||
already_description.append(already_edge["description"])
|
|
||||||
|
|
||||||
# Get keywords with empty string default if missing or None
|
# Get keywords with empty string default if missing or None
|
||||||
if "keywords" in already_edge and already_edge["keywords"] is not None:
|
if "keywords" in already_edge and already_edge["keywords"] is not None:
|
||||||
already_keywords.extend(
|
already_keywords.extend(
|
||||||
split_string_by_multi_markers(
|
split_string_by_multi_markers(
|
||||||
already_edge["keywords"], [GRAPH_FIELD_SEP]
|
already_edge["keywords"], [GRAPH_FIELD_SEP]
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
# Process edges_data with None checks
|
# Process edges_data with None checks
|
||||||
weight = sum([dp["weight"] for dp in edges_data] + already_weights)
|
weight = sum([dp["weight"] for dp in edges_data] + already_weights)
|
||||||
|
Reference in New Issue
Block a user