Fix linting

This commit is contained in:
yangdx 2025-06-23 18:41:30 +08:00
parent a215939c41
commit 5099ac8213
3 changed files with 15 additions and 11 deletions

View file

@ -1336,7 +1336,9 @@ def create_document_routes(
description="Status of the deletion operation"
)
message: str = Field(description="Message describing the operation result")
doc_id: Optional[str] = Field(default=None, description="The ID of the document.")
doc_id: Optional[str] = Field(
default=None, description="The ID of the document."
)
@router.delete(
"/delete_by_doc_id",
@ -1477,4 +1479,3 @@ def create_document_routes(
raise HTTPException(status_code=500, detail=str(e))
return router

View file

@ -614,9 +614,11 @@ class StoragesStatus(str, Enum):
INITIALIZED = "initialized"
FINALIZED = "finalized"
@dataclass
class DeletionResult:
"""Represents the result of a deletion operation."""
status: Literal["success", "not_found", "failure"]
doc_id: str
message: str

View file

@ -1746,11 +1746,12 @@ class LightRAG:
# Use graph database lock to ensure atomic merges and updates
graph_db_lock = get_graph_db_lock(enable_logging=False)
async with graph_db_lock:
# Process entities
all_labels = await self.chunk_entity_relation_graph.get_all_labels()
for node_label in all_labels:
node_data = await self.chunk_entity_relation_graph.get_node(node_label)
node_data = await self.chunk_entity_relation_graph.get_node(
node_label
)
if node_data and "source_id" in node_data:
# Split source_id using GRAPH_FIELD_SEP
sources = set(node_data["source_id"].split(GRAPH_FIELD_SEP))
@ -1776,10 +1777,10 @@ class LightRAG:
if node_edges:
for src, tgt in node_edges:
# To avoid processing the same edge twice in an undirected graph
if (
(tgt, src) in relationships_to_delete
or (tgt, src) in relationships_to_rebuild
):
if (tgt, src) in relationships_to_delete or (
tgt,
src,
) in relationships_to_rebuild:
continue
edge_data = await self.chunk_entity_relation_graph.get_edge(
@ -1799,9 +1800,9 @@ class LightRAG:
)
elif remaining_sources != sources:
# Relationship needs to be rebuilt from remaining chunks
relationships_to_rebuild[
(src, tgt)
] = remaining_sources
relationships_to_rebuild[(src, tgt)] = (
remaining_sources
)
logger.debug(
f"Relationship {src}-{tgt} will be rebuilt from {len(remaining_sources)} remaining chunks"
)