File tree Expand file tree Collapse file tree 5 files changed +7
-22
lines changed
subcommands/query/reranker Expand file tree Collapse file tree 5 files changed +7
-22
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ def __init__(self, config: Optional[Config] = None) -> None:
8585 super ().__init__ (config )
8686
8787 def chunk (self , data : TextIOWrapper ) -> Generator [Chunk , None , None ]:
88- logger .info ("Started chunking using FileChunker." , data .name )
88+ logger .info ("Started chunking %s using FileChunker." , data .name )
8989 lines = data .readlines ()
9090 if len (lines ) == 0 :
9191 return
Original file line number Diff line number Diff line change 55import socket
66import subprocess
77import sys
8- import traceback
98from typing import AsyncGenerator
109
1110import chromadb
@@ -159,9 +158,8 @@ def get_embedding_function(configs: Config) -> chromadb.EmbeddingFunction | None
159158 "\n For errors caused by missing dependency, consult the documentation of pipx (or whatever package manager that you installed VectorCode with) for instructions to inject libraries into the virtual environment."
160159 )
161160 logger .error (
162- f"Failed to use { configs .embedding_function } with the following error: " ,
161+ f"Failed to use { configs .embedding_function } with following error. " ,
163162 )
164- logger .error (traceback .format_exc ())
165163 raise
166164
167165
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ async def async_main():
6161 case CliAction .chunks :
6262 from vectorcode .subcommands import chunks
6363
64- return_val = await chunks (final_configs )
64+ return await chunks (final_configs )
6565 case CliAction .hooks :
6666 logger .warning (
6767 "`vectorcode hooks` has been deprecated and will be removed in 0.7.0."
@@ -109,9 +109,8 @@ async def async_main():
109109 from vectorcode .subcommands import clean
110110
111111 return_val = await clean (final_configs )
112- except Exception as e :
112+ except Exception :
113113 return_val = 1
114- traceback .print_exception (e , file = sys .stderr )
115114 logger .error (traceback .format_exc ())
116115 finally :
117116 if server_process is not None :
Original file line number Diff line number Diff line change @@ -41,13 +41,11 @@ class CustomReranker(RerankerBase):
4141 if issubclass (cls , RerankerBase ):
4242 if __supported_rerankers .get (cls .__name__ ):
4343 error_message = f"{ cls .__name__ } has been registered."
44- logger .error (error_message )
4544 raise AttributeError (error_message )
4645 __supported_rerankers [cls .__name__ ] = cls
4746 return cls
4847 else :
4948 error_message = f'{ cls } should be a subclass of "RerankerBase"'
50- logger .error (error_message )
5149 raise TypeError (error_message )
5250
5351
@@ -66,16 +64,7 @@ def get_reranker(configs: Config) -> RerankerBase:
6664 ):
6765 return __supported_rerankers [configs .reranker ].create (configs )
6866
69- # TODO: replace the following with an Exception before the release of 0.6.0.
70- logger .warning (
71- f""""reranker" option should be set to one of the following: { list (i .__name__ for i in get_available_rerankers ())} .
72- To choose a CrossEncoderReranker model, you can set the "model_name_or_path" key in the "reranker_params" option to the name/path of the model.
73- To use NaiveReranker, set the "reranker" option to "NaiveReranker".
74- The old configuration syntax will be DEPRECATED in v0.6.0
75- """
76- )
7767 if not configs .reranker :
7868 return NaiveReranker (configs )
7969 else :
80- logger .error (f"{ configs .reranker } is not a valid reranker type!" )
8170 raise RerankerInitialisationError ()
Original file line number Diff line number Diff line change @@ -373,10 +373,9 @@ async def test_async_main_exception_handling(monkeypatch):
373373 mock_query = AsyncMock (side_effect = Exception ("Test Exception" ))
374374 monkeypatch .setattr ("vectorcode.subcommands.query" , mock_query )
375375
376- with patch ("sys.stderr.write" ) as mock_stderr :
377- return_code = await async_main ()
378- assert return_code == 1
379- mock_stderr .assert_called ()
376+ with patch ("vectorcode.main.logger" ) as mock_logger :
377+ assert await async_main () == 1
378+ mock_logger .error .assert_called_once ()
380379
381380
382381@pytest .mark .asyncio
You can’t perform that action at this time.
0 commit comments