Fix linting
Browse files
lightrag/kg/milvus_impl.py
CHANGED
|
@@ -546,12 +546,12 @@ class MilvusVectorDBStorage(BaseVectorStorage):
|
|
| 546 |
if not self._client.has_collection(self.namespace):
|
| 547 |
logger.error(f"Collection {self.namespace} does not exist")
|
| 548 |
raise ValueError(f"Collection {self.namespace} does not exist")
|
| 549 |
-
|
| 550 |
# Load the collection if it's not already loaded
|
| 551 |
# In Milvus, collections need to be loaded before they can be searched
|
| 552 |
self._client.load_collection(self.namespace)
|
| 553 |
logger.debug(f"Collection {self.namespace} loaded successfully")
|
| 554 |
-
|
| 555 |
except Exception as e:
|
| 556 |
logger.error(f"Failed to load collection {self.namespace}: {e}")
|
| 557 |
raise
|
|
@@ -637,10 +637,10 @@ class MilvusVectorDBStorage(BaseVectorStorage):
|
|
| 637 |
collection_name=self.namespace, schema=schema
|
| 638 |
)
|
| 639 |
self._create_indexes_after_collection()
|
| 640 |
-
|
| 641 |
# Load the newly created collection
|
| 642 |
self._ensure_collection_loaded()
|
| 643 |
-
|
| 644 |
logger.info(f"Successfully force-created collection {self.namespace}")
|
| 645 |
|
| 646 |
except Exception as create_error:
|
|
@@ -731,7 +731,7 @@ class MilvusVectorDBStorage(BaseVectorStorage):
|
|
| 731 |
) -> list[dict[str, Any]]:
|
| 732 |
# Ensure collection is loaded before querying
|
| 733 |
self._ensure_collection_loaded()
|
| 734 |
-
|
| 735 |
embedding = await self.embedding_func(
|
| 736 |
[query], _priority=5
|
| 737 |
) # higher priority for query
|
|
@@ -798,7 +798,7 @@ class MilvusVectorDBStorage(BaseVectorStorage):
|
|
| 798 |
try:
|
| 799 |
# Ensure collection is loaded before querying
|
| 800 |
self._ensure_collection_loaded()
|
| 801 |
-
|
| 802 |
# Search for relations where entity is either source or target
|
| 803 |
expr = f'src_id == "{entity_name}" or tgt_id == "{entity_name}"'
|
| 804 |
|
|
@@ -839,7 +839,7 @@ class MilvusVectorDBStorage(BaseVectorStorage):
|
|
| 839 |
try:
|
| 840 |
# Ensure collection is loaded before deleting
|
| 841 |
self._ensure_collection_loaded()
|
| 842 |
-
|
| 843 |
# Delete vectors by IDs
|
| 844 |
result = self._client.delete(collection_name=self.namespace, pks=ids)
|
| 845 |
|
|
@@ -865,7 +865,7 @@ class MilvusVectorDBStorage(BaseVectorStorage):
|
|
| 865 |
try:
|
| 866 |
# Ensure collection is loaded before querying
|
| 867 |
self._ensure_collection_loaded()
|
| 868 |
-
|
| 869 |
# Include all meta_fields (created_at is now always included) plus id
|
| 870 |
output_fields = list(self.meta_fields) + ["id"]
|
| 871 |
|
|
@@ -899,7 +899,7 @@ class MilvusVectorDBStorage(BaseVectorStorage):
|
|
| 899 |
try:
|
| 900 |
# Ensure collection is loaded before querying
|
| 901 |
self._ensure_collection_loaded()
|
| 902 |
-
|
| 903 |
# Include all meta_fields (created_at is now always included) plus id
|
| 904 |
output_fields = list(self.meta_fields) + ["id"]
|
| 905 |
|
|
|
|
| 546 |
if not self._client.has_collection(self.namespace):
|
| 547 |
logger.error(f"Collection {self.namespace} does not exist")
|
| 548 |
raise ValueError(f"Collection {self.namespace} does not exist")
|
| 549 |
+
|
| 550 |
# Load the collection if it's not already loaded
|
| 551 |
# In Milvus, collections need to be loaded before they can be searched
|
| 552 |
self._client.load_collection(self.namespace)
|
| 553 |
logger.debug(f"Collection {self.namespace} loaded successfully")
|
| 554 |
+
|
| 555 |
except Exception as e:
|
| 556 |
logger.error(f"Failed to load collection {self.namespace}: {e}")
|
| 557 |
raise
|
|
|
|
| 637 |
collection_name=self.namespace, schema=schema
|
| 638 |
)
|
| 639 |
self._create_indexes_after_collection()
|
| 640 |
+
|
| 641 |
# Load the newly created collection
|
| 642 |
self._ensure_collection_loaded()
|
| 643 |
+
|
| 644 |
logger.info(f"Successfully force-created collection {self.namespace}")
|
| 645 |
|
| 646 |
except Exception as create_error:
|
|
|
|
| 731 |
) -> list[dict[str, Any]]:
|
| 732 |
# Ensure collection is loaded before querying
|
| 733 |
self._ensure_collection_loaded()
|
| 734 |
+
|
| 735 |
embedding = await self.embedding_func(
|
| 736 |
[query], _priority=5
|
| 737 |
) # higher priority for query
|
|
|
|
| 798 |
try:
|
| 799 |
# Ensure collection is loaded before querying
|
| 800 |
self._ensure_collection_loaded()
|
| 801 |
+
|
| 802 |
# Search for relations where entity is either source or target
|
| 803 |
expr = f'src_id == "{entity_name}" or tgt_id == "{entity_name}"'
|
| 804 |
|
|
|
|
| 839 |
try:
|
| 840 |
# Ensure collection is loaded before deleting
|
| 841 |
self._ensure_collection_loaded()
|
| 842 |
+
|
| 843 |
# Delete vectors by IDs
|
| 844 |
result = self._client.delete(collection_name=self.namespace, pks=ids)
|
| 845 |
|
|
|
|
| 865 |
try:
|
| 866 |
# Ensure collection is loaded before querying
|
| 867 |
self._ensure_collection_loaded()
|
| 868 |
+
|
| 869 |
# Include all meta_fields (created_at is now always included) plus id
|
| 870 |
output_fields = list(self.meta_fields) + ["id"]
|
| 871 |
|
|
|
|
| 899 |
try:
|
| 900 |
# Ensure collection is loaded before querying
|
| 901 |
self._ensure_collection_loaded()
|
| 902 |
+
|
| 903 |
# Include all meta_fields (created_at is now always included) plus id
|
| 904 |
output_fields = list(self.meta_fields) + ["id"]
|
| 905 |
|