-
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathdrop.py
More file actions
24 lines (19 loc) · 896 Bytes
/
Copy pathdrop.py
File metadata and controls
24 lines (19 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import logging
from chromadb.errors import InvalidCollectionException
from vectorcode.cli_utils import Config
from vectorcode.common import ClientManager, get_collection
logger = logging.getLogger(name=__name__)
async def drop(config: Config) -> int:
async with ClientManager().get_client(config) as client:
try:
collection = await get_collection(client, config)
collection_path = collection.metadata["path"]
await client.delete_collection(collection.name)
print(f"Collection for {collection_path} has been deleted.")
logger.info(f"Deteted collection at {collection_path}.")
return 0
except (ValueError, InvalidCollectionException) as e:
logger.error(
f"{e.__class__.__name__}: There's no existing collection for {config.project_root}"
)
return 1