Fix linting
This commit is contained in:
parent
a215939c41
commit
5099ac8213
3 changed files with 15 additions and 11 deletions
|
|
@ -1336,7 +1336,9 @@ def create_document_routes(
|
||||||
description="Status of the deletion operation"
|
description="Status of the deletion operation"
|
||||||
)
|
)
|
||||||
message: str = Field(description="Message describing the operation result")
|
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(
|
@router.delete(
|
||||||
"/delete_by_doc_id",
|
"/delete_by_doc_id",
|
||||||
|
|
@ -1477,4 +1479,3 @@ def create_document_routes(
|
||||||
raise HTTPException(status_code=500, detail=str(e))
|
raise HTTPException(status_code=500, detail=str(e))
|
||||||
|
|
||||||
return router
|
return router
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -614,9 +614,11 @@ class StoragesStatus(str, Enum):
|
||||||
INITIALIZED = "initialized"
|
INITIALIZED = "initialized"
|
||||||
FINALIZED = "finalized"
|
FINALIZED = "finalized"
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class DeletionResult:
|
class DeletionResult:
|
||||||
"""Represents the result of a deletion operation."""
|
"""Represents the result of a deletion operation."""
|
||||||
|
|
||||||
status: Literal["success", "not_found", "failure"]
|
status: Literal["success", "not_found", "failure"]
|
||||||
doc_id: str
|
doc_id: str
|
||||||
message: str
|
message: str
|
||||||
|
|
|
||||||
|
|
@ -1746,11 +1746,12 @@ class LightRAG:
|
||||||
# Use graph database lock to ensure atomic merges and updates
|
# Use graph database lock to ensure atomic merges and updates
|
||||||
graph_db_lock = get_graph_db_lock(enable_logging=False)
|
graph_db_lock = get_graph_db_lock(enable_logging=False)
|
||||||
async with graph_db_lock:
|
async with graph_db_lock:
|
||||||
|
|
||||||
# Process entities
|
# Process entities
|
||||||
all_labels = await self.chunk_entity_relation_graph.get_all_labels()
|
all_labels = await self.chunk_entity_relation_graph.get_all_labels()
|
||||||
for node_label in 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:
|
if node_data and "source_id" in node_data:
|
||||||
# Split source_id using GRAPH_FIELD_SEP
|
# Split source_id using GRAPH_FIELD_SEP
|
||||||
sources = set(node_data["source_id"].split(GRAPH_FIELD_SEP))
|
sources = set(node_data["source_id"].split(GRAPH_FIELD_SEP))
|
||||||
|
|
@ -1776,10 +1777,10 @@ class LightRAG:
|
||||||
if node_edges:
|
if node_edges:
|
||||||
for src, tgt in node_edges:
|
for src, tgt in node_edges:
|
||||||
# To avoid processing the same edge twice in an undirected graph
|
# To avoid processing the same edge twice in an undirected graph
|
||||||
if (
|
if (tgt, src) in relationships_to_delete or (
|
||||||
(tgt, src) in relationships_to_delete
|
tgt,
|
||||||
or (tgt, src) in relationships_to_rebuild
|
src,
|
||||||
):
|
) in relationships_to_rebuild:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
edge_data = await self.chunk_entity_relation_graph.get_edge(
|
edge_data = await self.chunk_entity_relation_graph.get_edge(
|
||||||
|
|
@ -1799,9 +1800,9 @@ class LightRAG:
|
||||||
)
|
)
|
||||||
elif remaining_sources != sources:
|
elif remaining_sources != sources:
|
||||||
# Relationship needs to be rebuilt from remaining chunks
|
# Relationship needs to be rebuilt from remaining chunks
|
||||||
relationships_to_rebuild[
|
relationships_to_rebuild[(src, tgt)] = (
|
||||||
(src, tgt)
|
remaining_sources
|
||||||
] = remaining_sources
|
)
|
||||||
logger.debug(
|
logger.debug(
|
||||||
f"Relationship {src}-{tgt} will be rebuilt from {len(remaining_sources)} remaining chunks"
|
f"Relationship {src}-{tgt} will be rebuilt from {len(remaining_sources)} remaining chunks"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue