-
Notifications
You must be signed in to change notification settings - Fork 262
feat: Add progress bar and pretty print for CLI #261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
482f314
2c2ae7f
c7d462c
3a15a43
8e94746
dd1d8d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,12 @@ | ||
| import contextlib | ||
| import logging | ||
| import sys | ||
| from collections.abc import Sequence | ||
| from pathlib import Path | ||
|
|
||
| import numpy as np | ||
| from model2vec.model import StaticModel | ||
| from tqdm import tqdm | ||
| from vicinity.backends.basic import BasicArgs | ||
|
|
||
| from semble.chunking import chunk_source | ||
|
|
@@ -72,6 +74,7 @@ def create_index_from_path( | |
| content: ContentType | Sequence[ContentType] = (ContentType.CODE,), | ||
| display_root: Path | None = None, | ||
| previous: PreviousIndex | None = None, | ||
| show_progress_bar: bool = False, | ||
| ) -> tuple[BM25, SelectableBasicBackend, list[Chunk], dict[str, FileManifestEntry]]: | ||
| """Create an index from a resolved directory, optionally reusing a previous index's unchanged files. | ||
|
|
||
|
|
@@ -80,6 +83,7 @@ def create_index_from_path( | |
| :param content: Content types to index. | ||
| :param display_root: If set, chunk file paths are stored relative to this root. | ||
| :param previous: A previously built index to reuse unchanged files' chunks/embeddings/postings from. | ||
| :param show_progress_bar: Show a progress bar on stderr while indexing. | ||
| :raises ValueError: if no items were found, no index can be created. | ||
| :return: A BM25 index, semantic index, list of chunks, and file manifest. | ||
| """ | ||
|
|
@@ -98,7 +102,10 @@ def create_index_from_path( | |
|
|
||
| skipped_large: list[str] = [] | ||
|
|
||
| for file_path in walk_files(path, resolved_extensions): | ||
| files = list(walk_files(path, resolved_extensions)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Converting Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
| for file_path in tqdm( | ||
| files, desc="Indexing", unit="file", file=sys.stderr, leave=False, colour="green", disable=not show_progress_bar | ||
| ): | ||
| language = detect_language(file_path) | ||
| with contextlib.suppress(OSError): | ||
| file_status = get_file_status(file_path, None) | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
--prettyis used, repository-controlled file paths and source content are printed without escaping control characters. A local or cloned repository can include ANSI or OSC sequences that the terminal interprets, allowing output spoofing or terminal manipulation. Escape or neutralize terminal control sequences before printing these values.How this was verified: File names and text read from the indexed repository flow through
format_resultsunchanged and are passed directly toprinton the terminal-facing pretty-output path.