File tree Expand file tree Collapse file tree
src/vectorcode/subcommands Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import logging
12import os
23
34from chromadb .api import AsyncClientAPI
45
56from vectorcode .cli_utils import Config
67from vectorcode .common import get_client , get_collections
78
9+ logger = logging .getLogger (name = __name__ )
10+
811
912async def run_clean_on_client (client : AsyncClientAPI , pipe_mode : bool ):
1013 async for collection in get_collections (client ):
1114 meta = collection .metadata
15+ logger .debug (f"{ meta .get ('path' )} : { await collection .count ()} chunk(s)" )
1216 if await collection .count () == 0 or not os .path .isdir (meta ["path" ]):
1317 await client .delete_collection (collection .name )
18+ logger .info (f"Deleted collection for { meta ['path' ]} " )
1419 if not pipe_mode :
1520 print (f"Deleted { meta ['path' ]} ." )
1621
Original file line number Diff line number Diff line change 1+ import logging
2+
13from chromadb .errors import InvalidCollectionException
24
35from vectorcode .cli_utils import Config
46from vectorcode .common import get_client , get_collection
57
8+ logger = logging .getLogger (name = __name__ )
9+
610
711async def drop (config : Config ) -> int :
812 client = await get_client (config )
@@ -11,7 +15,8 @@ async def drop(config: Config) -> int:
1115 collection_path = collection .metadata ["path" ]
1216 await client .delete_collection (collection .name )
1317 print (f"Collection for { collection_path } has been deleted." )
18+ logger .info (f"Deteted collection at { collection_path } ." )
1419 return 0
1520 except (ValueError , InvalidCollectionException ):
16- print (f"There's no existing collection for { config .project_root } " )
21+ logger . error (f"There's no existing collection for { config .project_root } " )
1722 return 1
Original file line number Diff line number Diff line change 1+ import logging
12import os
23import shutil
3- import sys
44
55from vectorcode .cli_utils import Config
66
7+ logger = logging .getLogger (name = __name__ )
8+
79
810async def init (configs : Config ) -> int :
911 project_config_dir = os .path .join (str (configs .project_root ), ".vectorcode" )
1012 if os .path .isdir (project_config_dir ) and not configs .force :
11- print (
13+ logger . warning (
1214 f"{ configs .project_root } is already initialised for VectorCode." ,
13- file = sys .stderr ,
1415 )
1516 return 1
1617
@@ -21,6 +22,7 @@ async def init(configs: Config) -> int:
2122 os .path .expanduser ("~" ), ".config" , "vectorcode" , item
2223 )
2324 if os .path .isfile (global_file_path ):
25+ logger .debug (f"Copying global { item } to { project_config_dir } " )
2426 shutil .copyfile (global_file_path , local_file_path )
2527
2628 print (f"VectorCode project root has been initialised at { configs .project_root } " )
Original file line number Diff line number Diff line change @@ -32,8 +32,6 @@ async def test_init_already_initialized(capsys):
3232 # Try to initialize again without force
3333 return_code = await init (configs )
3434 assert return_code == 1
35- captured = capsys .readouterr ()
36- assert f"{ temp_dir } is already initialised for VectorCode." in captured .err
3735
3836
3937@pytest .mark .asyncio
You can’t perform that action at this time.
0 commit comments