add colors!
build / build (push) Successful in 12s
pytest / pytest (push) Successful in 29s

This commit is contained in:
Matteo Rosati
2026-04-23 21:49:46 +02:00
parent 3fcc3904b4
commit a14edebafe
10 changed files with 24 additions and 12 deletions
+3 -2
View File
@@ -54,10 +54,11 @@ def delete_data(collection_name: str, where: dict[str, str]) -> int:
return int(result.get("deleted", 0))
def count_collection(collection_name: str) -> int:
def count_collection(collection_name: str) -> str:
_, collection = _get_client_and_collection(collection_name)
count = collection.count()
return collection.count()
return f"The '{collection_name}' collection contains [bold green]{count}[/] records."
def add_data(
+2 -1
View File
@@ -3,6 +3,7 @@ from __future__ import annotations
from typing import Annotated, Callable
import typer
from rich import print
from chromadb.errors import InternalError, NotFoundError
from chromy.handlers.import_data import handle_import
@@ -27,7 +28,7 @@ def _run(handler: ExitCodeHandler) -> None:
def _fail(message: str) -> None:
typer.echo(message)
print("[bold red]Error[/]:", message)
raise typer.Exit(1)
+1
View File
@@ -1,5 +1,6 @@
from __future__ import annotations
from rich import print
from chromy.chroma_functions import count_collection
+2 -1
View File
@@ -1,9 +1,10 @@
from __future__ import annotations
from rich import print
from chromy.chroma_functions import create_collection
def handle_create_collection(collection: str) -> int:
collection_name = create_collection(collection)
print(f"Created collection '{collection_name}'.")
print(f"[bold green]Created[/]: collection '{collection_name}'.")
return 0
+3 -2
View File
@@ -1,5 +1,6 @@
from __future__ import annotations
from rich import print
from chromy.chroma_functions import delete_collection, delete_data
@@ -22,7 +23,7 @@ def _parse_where_clause(where_clause: str) -> dict[str, str]:
def handle_delete_collection(collection: str) -> int:
delete_collection(collection)
print(f"Deleted collection '{collection}'.")
print(f"[bold green]Deleted[/] collection '{collection}'.")
return 0
@@ -31,7 +32,7 @@ def handle_delete_records(collection: str, where_clause: str) -> int:
deleted = delete_data(collection, where)
condition, value = next(iter(where.items()))
print(
f"Deleted {deleted} record(s) from collection '{collection}' "
f"[bold green]Deleted[/] {deleted} record(s) from collection '{collection}' "
f"where {condition}={value}."
)
return 0
+3 -1
View File
@@ -2,6 +2,7 @@ from __future__ import annotations
import os
from pathlib import Path
from rich import print
from chromy.utilities import ingest_file
@@ -25,5 +26,6 @@ def _get_absolute_path(file: str) -> str:
def handle_import(collection: str, file: str) -> int:
records_added = ingest_file(collection, _get_absolute_path(file))
print(f"Added {records_added} records to collection '{collection}'.")
print(
f"[bold green]Added[/] {records_added} records to collection '{collection}'.")
return 0