Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/vectorcode/chunking.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __init__(self, config: Optional[Config] = None) -> None:
super().__init__(config)

def chunk(self, data: TextIOWrapper) -> Generator[Chunk, None, None]:
logger.info("Started chunking using FileChunker.", data.name)
logger.info("Started chunking %s using FileChunker.", data.name)
lines = data.readlines()
if len(lines) == 0:
return
Expand Down
4 changes: 1 addition & 3 deletions src/vectorcode/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import socket
import subprocess
import sys
import traceback
from typing import AsyncGenerator

import chromadb
Expand Down Expand Up @@ -159,9 +158,8 @@ def get_embedding_function(configs: Config) -> chromadb.EmbeddingFunction | None
"\nFor 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."
)
logger.error(
f"Failed to use {configs.embedding_function} with the following error:",
f"Failed to use {configs.embedding_function} with following error.",
)
logger.error(traceback.format_exc())
raise


Expand Down
5 changes: 2 additions & 3 deletions src/vectorcode/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async def async_main():
case CliAction.chunks:
from vectorcode.subcommands import chunks

return_val = await chunks(final_configs)
return await chunks(final_configs)
case CliAction.hooks:
logger.warning(
"`vectorcode hooks` has been deprecated and will be removed in 0.7.0."
Expand Down Expand Up @@ -109,9 +109,8 @@ async def async_main():
from vectorcode.subcommands import clean

return_val = await clean(final_configs)
except Exception as e:
except Exception:
return_val = 1
traceback.print_exception(e, file=sys.stderr)
logger.error(traceback.format_exc())
finally:
if server_process is not None:
Expand Down
11 changes: 0 additions & 11 deletions src/vectorcode/subcommands/query/reranker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@ class CustomReranker(RerankerBase):
if issubclass(cls, RerankerBase):
if __supported_rerankers.get(cls.__name__):
error_message = f"{cls.__name__} has been registered."
logger.error(error_message)
raise AttributeError(error_message)
__supported_rerankers[cls.__name__] = cls
return cls
else:
error_message = f'{cls} should be a subclass of "RerankerBase"'
logger.error(error_message)
raise TypeError(error_message)


Expand All @@ -66,16 +64,7 @@ def get_reranker(configs: Config) -> RerankerBase:
):
return __supported_rerankers[configs.reranker].create(configs)

# TODO: replace the following with an Exception before the release of 0.6.0.
logger.warning(
f""""reranker" option should be set to one of the following: {list(i.__name__ for i in get_available_rerankers())}.
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.
To use NaiveReranker, set the "reranker" option to "NaiveReranker".
The old configuration syntax will be DEPRECATED in v0.6.0
"""
)
if not configs.reranker:
return NaiveReranker(configs)
else:
logger.error(f"{configs.reranker} is not a valid reranker type!")
raise RerankerInitialisationError()
7 changes: 3 additions & 4 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,9 @@ async def test_async_main_exception_handling(monkeypatch):
mock_query = AsyncMock(side_effect=Exception("Test Exception"))
monkeypatch.setattr("vectorcode.subcommands.query", mock_query)

with patch("sys.stderr.write") as mock_stderr:
return_code = await async_main()
assert return_code == 1
mock_stderr.assert_called()
with patch("vectorcode.main.logger") as mock_logger:
assert await async_main() == 1
mock_logger.error.assert_called_once()


@pytest.mark.asyncio
Expand Down