Show package versions

This commit is contained in:
Yiorgis Gozadinos 2025-09-23 12:34:32 +03:00
parent 5ea5de274c
commit c0de22c9cd
No known key found for this signature in database
2 changed files with 22 additions and 8 deletions

View file

@ -138,9 +138,13 @@ Shows:
- path to the database - path to the database
- stored haiku.rag version (from settings) - stored haiku.rag version (from settings)
- embeddings provider/model and vector dimension - embeddings provider/model and vector dimension
- LanceDB version
- number of documents - number of documents
At the end, a separate “Versions” section lists runtime package versions:
- haiku.rag
- lancedb
- docling
### Vacuum (Optimize and Cleanup) ### Vacuum (Optimize and Cleanup)
Reduce disk usage by optimizing and pruning old table versions across all tables: Reduce disk usage by optimizing and pruning old table versions across all tables:

View file

@ -38,9 +38,6 @@ class HaikuRAGApp:
f" [repr.attrib_name]path[/repr.attrib_name]: {self.db_path}" f" [repr.attrib_name]path[/repr.attrib_name]: {self.db_path}"
) )
# Prevent accidental creation: require existing local path
# (For cloud/object storage users, info should be invoked with proper env vars and
# an existing local cache/path if applicable.)
if not self.db_path.exists(): if not self.db_path.exists():
self.console.print("[red]Database path does not exist.[/red]") self.console.print("[red]Database path does not exist.[/red]")
return return
@ -53,11 +50,18 @@ class HaikuRAGApp:
self.console.print(f"[red]Failed to open database: {e}[/red]") self.console.print(f"[red]Failed to open database: {e}[/red]")
return return
# Resolve LanceDB version (best-effort)
try: try:
ldb_version = pkg_version("lancedb") ldb_version = pkg_version("lancedb")
except Exception: except Exception:
ldb_version = "unknown" ldb_version = "unknown"
try:
hr_version = pkg_version("haiku.rag")
except Exception:
hr_version = "unknown"
try:
docling_version = pkg_version("docling")
except Exception:
docling_version = "unknown"
# Read settings (if present) to find stored haiku.rag version and embedding config # Read settings (if present) to find stored haiku.rag version and embedding config
stored_version = "unknown" stored_version = "unknown"
@ -81,13 +85,11 @@ class HaikuRAGApp:
else None else None
) )
# Count documents efficiently (best-effort, avoiding full scans)
num_docs = 0 num_docs = 0
if "documents" in table_names: if "documents" in table_names:
docs_tbl = db.open_table("documents") docs_tbl = db.open_table("documents")
num_docs = int(docs_tbl.count_rows()) # type: ignore[attr-defined] num_docs = int(docs_tbl.count_rows()) # type: ignore[attr-defined]
# Render collected info
self.console.print( self.console.print(
f" [repr.attrib_name]haiku.rag version (db)[/repr.attrib_name]: {stored_version}" f" [repr.attrib_name]haiku.rag version (db)[/repr.attrib_name]: {stored_version}"
) )
@ -103,11 +105,19 @@ class HaikuRAGApp:
self.console.print( self.console.print(
" [repr.attrib_name]embeddings[/repr.attrib_name]: unknown" " [repr.attrib_name]embeddings[/repr.attrib_name]: unknown"
) )
self.console.print(
f" [repr.attrib_name]documents[/repr.attrib_name]: {num_docs}"
)
self.console.rule()
self.console.print("[bold]Versions[/bold]")
self.console.print(
f" [repr.attrib_name]haiku.rag[/repr.attrib_name]: {hr_version}"
)
self.console.print( self.console.print(
f" [repr.attrib_name]lancedb[/repr.attrib_name]: {ldb_version}" f" [repr.attrib_name]lancedb[/repr.attrib_name]: {ldb_version}"
) )
self.console.print( self.console.print(
f" [repr.attrib_name]documents[/repr.attrib_name]: {num_docs}" f" [repr.attrib_name]docling[/repr.attrib_name]: {docling_version}"
) )
async def list_documents(self): async def list_documents(self):