Skip to content

Commit 6ff75f9

Browse files
author
Zhe Yu
committed
logger for update
1 parent 5f6db1f commit 6ff75f9

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/vectorcode/subcommands/update.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import asyncio
2+
import logging
23
import os
34
import sys
45
from asyncio import Lock
@@ -11,6 +12,8 @@
1112
from vectorcode.common import get_client, get_collection, verify_ef
1213
from vectorcode.subcommands.vectorise import chunked_add, show_stats
1314

15+
logger = logging.getLogger(name=__name__)
16+
1417

1518
async def update(configs: Config) -> int:
1619
client = await get_client(configs)
@@ -49,6 +52,7 @@ async def update(configs: Config) -> int:
4952
with tqdm.tqdm(
5053
total=len(files), desc="Vectorising files...", disable=configs.pipe
5154
) as bar:
55+
logger.info(f"Updating embeddings for {len(files)} file(s).")
5256
try:
5357
tasks = [
5458
asyncio.create_task(
@@ -73,6 +77,7 @@ async def update(configs: Config) -> int:
7377
return 1
7478

7579
if len(orphanes):
80+
logger.info(f"Removing {len(orphanes)} orphaned files from database.")
7681
await collection.delete(where={"path": {"$in": list(orphanes)}})
7782

7883
show_stats(configs, stats)

src/vectorcode/subcommands/vectorise.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ async def chunked_add(
6464
async with collection_lock:
6565
await collection.delete(where={"path": full_path_str})
6666

67+
logger.debug(f"Vectorising {file_path}")
6768
try:
6869
async with semaphore:
6970
chunks: list[Chunk | str] = list(
@@ -192,7 +193,7 @@ async def vectorise(configs: Config) -> int:
192193
with open(spec_path) as fin:
193194
spec = pathspec.GitIgnoreSpec.from_lines(fin.readlines())
194195
files = exclude_paths_by_spec((str(i) for i in files), spec)
195-
else:
196+
else: # pragma: nocover
196197
logger.info("Ignoring exclude specs.")
197198

198199
stats = {"add": 0, "update": 0, "removed": 0}

0 commit comments

Comments
 (0)