added some comments

This commit is contained in:
Yannick Stephan
2025-02-16 16:04:07 +01:00
parent abad9f235c
commit 2b2c81a722
13 changed files with 35 additions and 39 deletions

View File

@@ -634,4 +634,5 @@ class AGEStorage(BaseGraphStorage):
raise NotImplementedError
async def index_done_callback(self) -> None:
# AGES handles persistence automatically
pass

View File

@@ -198,9 +198,7 @@ class ChromaVectorDBStorage(BaseVectorStorage):
pass
async def delete_entity(self, entity_name: str) -> None:
"""Delete a single entity by its name"""
raise NotImplementedError
async def delete_entity_relation(self, entity_name: str) -> None:
"""Delete relations for a given entity by scanning metadata"""
raise NotImplementedError

View File

@@ -223,10 +223,6 @@ class FaissVectorDBStorage(BaseVectorStorage):
)
async def delete_entity(self, entity_name: str) -> None:
"""
Delete a single entity by computing its hashed ID
the same way your code does it with `compute_mdhash_id`.
"""
entity_id = compute_mdhash_id(entity_name, prefix="ent-")
logger.debug(f"Attempting to delete entity {entity_name} with ID {entity_id}")
await self.delete([entity_id])
@@ -247,11 +243,7 @@ class FaissVectorDBStorage(BaseVectorStorage):
logger.debug(f"Deleted {len(relations)} relations for {entity_name}")
async def index_done_callback(self) -> None:
"""
Called after indexing is done (save Faiss index + metadata).
"""
self._save_faiss_index()
logger.info("Faiss index saved successfully.")
# --------------------------------------------------------------------------------
# Internal helper methods

View File

@@ -88,6 +88,7 @@ class GremlinStorage(BaseGraphStorage):
self._driver.close()
async def index_done_callback(self) -> None:
# Gremlin handles persistence automatically
pass
@staticmethod

View File

@@ -130,12 +130,11 @@ class MilvusVectorDBStorage(BaseVectorStorage):
]
async def index_done_callback(self) -> None:
# Milvus handles persistence automatically
pass
async def delete_entity(self, entity_name: str) -> None:
"""Delete a single entity by its name"""
raise NotImplementedError
async def delete_entity_relation(self, entity_name: str) -> None:
"""Delete relations for a given entity by scanning metadata"""
raise NotImplementedError

View File

@@ -114,6 +114,7 @@ class MongoKVStorage(BaseKVStorage):
return None
async def index_done_callback(self) -> None:
# Mongo handles persistence automatically
pass
async def drop(self) -> None:
@@ -202,7 +203,7 @@ class MongoDocStatusStorage(DocStatusStorage):
}
async def index_done_callback(self) -> None:
# Implement the method here
# Mongo handles persistence automatically
pass
@@ -771,6 +772,7 @@ class MongoGraphStorage(BaseGraphStorage):
return result
async def index_done_callback(self) -> None:
# Mongo handles persistence automatically
pass
@@ -919,14 +921,13 @@ class MongoVectorDBStorage(BaseVectorStorage):
]
async def index_done_callback(self) -> None:
# Mongo handles persistence automatically
pass
async def delete_entity(self, entity_name: str) -> None:
"""Delete a single entity by its name"""
raise NotImplementedError
async def delete_entity_relation(self, entity_name: str) -> None:
"""Delete relations for a given entity by scanning metadata"""
raise NotImplementedError

View File

@@ -167,6 +167,5 @@ class NanoVectorDBStorage(BaseVectorStorage):
logger.error(f"Error deleting relations for {entity_name}: {e}")
async def index_done_callback(self) -> None:
# Protect file write operation
async with self._save_lock:
self._client.save()

View File

@@ -18,7 +18,11 @@ from tenacity import (
from ..utils import logger
from ..base import BaseGraphStorage
from ..types import KnowledgeGraph, KnowledgeGraphNode, KnowledgeGraphEdge
import pipmaster as pm
if not pm.is_installed("neo4j"):
pm.install("neo4j")
try:
from neo4j import (
AsyncGraphDatabase,
@@ -145,6 +149,7 @@ class Neo4JStorage(BaseGraphStorage):
await self._driver.close()
async def index_done_callback(self) -> None:
# Noe4J handles persistence automatically
pass
async def _label_exists(self, label: str) -> bool:

View File

@@ -317,11 +317,8 @@ class OracleKVStorage(BaseKVStorage):
await self.db.execute(upsert_sql, _data)
async def index_done_callback(self) -> None:
if is_namespace(
self.namespace,
(NameSpace.KV_STORE_FULL_DOCS, NameSpace.KV_STORE_TEXT_CHUNKS),
):
logger.info("full doc and chunk data had been saved into oracle db!")
# Oracle handles persistence automatically
pass
async def drop(self) -> None:
raise NotImplementedError
@@ -339,12 +336,6 @@ class OracleVectorDBStorage(BaseVectorStorage):
)
self.cosine_better_than_threshold = cosine_threshold
async def upsert(self, data: dict[str, dict[str, Any]]) -> None:
pass
async def index_done_callback(self) -> None:
pass
#################### query method ###############
async def query(self, query: str, top_k: int) -> list[dict[str, Any]]:
embeddings = await self.embedding_func([query])
@@ -366,12 +357,17 @@ class OracleVectorDBStorage(BaseVectorStorage):
# print("vector search result:",results)
return results
async def upsert(self, data: dict[str, dict[str, Any]]) -> None:
raise NotImplementedError
async def index_done_callback(self) -> None:
# Oracles handles persistence automatically
pass
async def delete_entity(self, entity_name: str) -> None:
"""Delete a single entity by its name"""
raise NotImplementedError
async def delete_entity_relation(self, entity_name: str) -> None:
"""Delete relations for a given entity by scanning metadata"""
raise NotImplementedError
@@ -476,6 +472,7 @@ class OracleGraphStorage(BaseGraphStorage):
return embeddings, nodes_ids
async def index_done_callback(self) -> None:
# Oracles handles persistence automatically
pass
#################### query method #################

View File

@@ -298,6 +298,7 @@ class PGKVStorage(BaseKVStorage):
await self.db.execute(upsert_sql, _data)
async def index_done_callback(self) -> None:
# PG handles persistence automatically
pass
async def drop(self) -> None:
@@ -404,9 +405,6 @@ class PGVectorStorage(BaseVectorStorage):
await self.db.execute(upsert_sql, data)
async def index_done_callback(self) -> None:
pass
#################### query method ###############
async def query(self, query: str, top_k: int) -> list[dict[str, Any]]:
embeddings = await self.embedding_func([query])
@@ -422,12 +420,14 @@ class PGVectorStorage(BaseVectorStorage):
results = await self.db.query(sql, params=params, multirows=True)
return results
async def index_done_callback(self) -> None:
# PG handles persistence automatically
pass
async def delete_entity(self, entity_name: str) -> None:
"""Delete a single entity by its name"""
raise NotImplementedError
async def delete_entity_relation(self, entity_name: str) -> None:
"""Delete relations for a given entity by scanning metadata"""
raise NotImplementedError
@@ -500,6 +500,7 @@ class PGDocStatusStorage(DocStatusStorage):
}
async def index_done_callback(self) -> None:
# PG handles persistence automatically
pass
async def upsert(self, data: dict[str, dict[str, Any]]) -> None:
@@ -569,6 +570,7 @@ class PGGraphStorage(BaseGraphStorage):
}
async def index_done_callback(self) -> None:
# PG handles persistence automatically
pass
@staticmethod

View File

@@ -153,12 +153,11 @@ class QdrantVectorDBStorage(BaseVectorStorage):
return [{**dp.payload, "id": dp.id, "distance": dp.score} for dp in results]
async def index_done_callback(self) -> None:
# Qdrant handles persistence automatically
pass
async def delete_entity(self, entity_name: str) -> None:
"""Delete a single entity by its name"""
raise NotImplementedError
async def delete_entity_relation(self, entity_name: str) -> None:
"""Delete relations for a given entity by scanning metadata"""
raise NotImplementedError

View File

@@ -64,4 +64,5 @@ class RedisKVStorage(BaseKVStorage):
await self._redis.delete(*keys)
async def index_done_callback(self) -> None:
# Redis handles persistence automatically
pass

View File

@@ -211,6 +211,7 @@ class TiDBKVStorage(BaseKVStorage):
return left_data
async def index_done_callback(self) -> None:
# Ti handles persistence automatically
pass
async def drop(self) -> None:
@@ -339,15 +340,14 @@ class TiDBVectorDBStorage(BaseVectorStorage):
return await self.db.query(SQL, params, multirows=True)
async def delete_entity(self, entity_name: str) -> None:
"""Delete a single entity by its name"""
raise NotImplementedError
async def delete_entity_relation(self, entity_name: str) -> None:
"""Delete relations for a given entity by scanning metadata"""
raise NotImplementedError
async def index_done_callback(self) -> None:
raise NotImplementedError
# Ti handles persistence automatically
pass
@final
@@ -489,6 +489,7 @@ class TiDBGraphStorage(BaseGraphStorage):
return []
async def index_done_callback(self) -> None:
# Ti handles persistence automatically
pass
async def delete_node(self, node_id: str) -> None: