mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-10-09 05:08:37 +00:00
refactor(client): replace all AsyncMilvusClient usage of has_collection() with list_collections()
Signed-off-by: Mustafa Elbehery <melbeher@redhat.com>
This commit is contained in:
parent
5482396459
commit
295d8b99c3
2 changed files with 15 additions and 12 deletions
|
@ -67,7 +67,8 @@ class MilvusIndex(EmbeddingIndex):
|
|||
|
||||
async def delete(self):
|
||||
try:
|
||||
if await self.client.has_collection(self.collection_name):
|
||||
collections = await self.client.list_collections()
|
||||
if self.collection_name in collections:
|
||||
await self.client.drop_collection(collection_name=self.collection_name)
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to check or delete collection {self.collection_name}: {e}")
|
||||
|
@ -78,7 +79,8 @@ class MilvusIndex(EmbeddingIndex):
|
|||
)
|
||||
|
||||
try:
|
||||
collection_exists = await self.client.has_collection(self.collection_name)
|
||||
collections = await self.client.list_collections()
|
||||
collection_exists = self.collection_name in collections
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to check collection existence: {self.collection_name} ({e})")
|
||||
# If it's an event loop issue, try to recreate the client
|
||||
|
@ -87,7 +89,8 @@ class MilvusIndex(EmbeddingIndex):
|
|||
|
||||
if hasattr(self, "_parent_adapter"):
|
||||
await self._parent_adapter._recreate_client()
|
||||
collection_exists = await self.client.has_collection(self.collection_name)
|
||||
collections = await self.client.list_collections()
|
||||
collection_exists = self.collection_name in collections
|
||||
else:
|
||||
# Assume collection doesn't exist if we can't check
|
||||
collection_exists = False
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue