Remove defensive app() try/except, let errors propagate if they occur

This commit is contained in:
Yiorgis Gozadinos 2026-01-15 10:17:26 +02:00
parent affffc1013
commit 345807e699
No known key found for this signature in database
2 changed files with 157 additions and 181 deletions

View file

@ -78,12 +78,8 @@ class HaikuRAGApp:
return
# Connect without going through Store to avoid upgrades/validation writes
try:
db = lancedb.connect(self.db_path)
table_names = set(db.table_names())
except Exception as e:
self.console.print(f"[red]Failed to open database: {e}[/red]")
return
versions = get_package_versions()
@ -418,7 +414,6 @@ class HaikuRAGApp:
read_only=self.read_only,
before=self.before,
) as self.client:
try:
citations = []
if deep:
graph = build_research_graph(config=self.config)
@ -460,8 +455,6 @@ class HaikuRAGApp:
if cite and citations:
for renderable in format_citations_rich(citations):
self.console.print(renderable)
except Exception as e:
self.console.print(f"[red]Error: {e}[/red]")
async def research(self, question: str, filter: str | None = None):
"""Run research via the pydantic-graph pipeline.
@ -476,7 +469,6 @@ class HaikuRAGApp:
read_only=self.read_only,
before=self.before,
) as client:
try:
self.console.print("[bold cyan]Starting research[/bold cyan]")
self.console.print(f"[bold blue]Question:[/bold blue] {question}")
self.console.print()
@ -545,9 +537,6 @@ class HaikuRAGApp:
self.console.print("[bold cyan]Sources:[/bold cyan]")
self.console.print(report.sources_summary)
except Exception as e:
self.console.print(f"[red]Error during research: {e}[/red]")
async def rebuild(self, mode: RebuildMode = RebuildMode.FULL):
async with HaikuRAG(
db_path=self.db_path,
@ -556,14 +545,11 @@ class HaikuRAGApp:
read_only=self.read_only,
before=self.before,
) as client:
try:
documents = await client.list_documents()
total_docs = len(documents)
if total_docs == 0:
self.console.print(
"[yellow]No documents found in database.[/yellow]"
)
self.console.print("[yellow]No documents found in database.[/yellow]")
return
mode_desc = {
@ -583,12 +569,9 @@ class HaikuRAGApp:
self.console.print(
"[bold green]Database rebuild completed successfully.[/bold green]"
)
except Exception as e:
self.console.print(f"[red]Error rebuilding database: {e}[/red]")
async def vacuum(self):
"""Run database maintenance: optimize and cleanup table history."""
try:
async with HaikuRAG(
db_path=self.db_path,
config=self.config,
@ -597,15 +580,10 @@ class HaikuRAGApp:
before=self.before,
) as client:
await client.vacuum()
self.console.print(
"[bold green]Vacuum completed successfully.[/bold green]"
)
except Exception as e:
self.console.print(f"[red]Error during vacuum: {e}[/red]")
self.console.print("[bold green]Vacuum completed successfully.[/bold green]")
async def create_index(self):
"""Create vector index on the chunks table."""
try:
async with HaikuRAG(
db_path=self.db_path,
config=self.config,
@ -637,8 +615,6 @@ class HaikuRAGApp:
self.console.print(
"[bold green]Vector index created successfully.[/bold green]"
)
except Exception as e:
self.console.print(f"[red]Error creating index: {e}[/red]")
async def download_models(self):
"""Download Docling, HuggingFace tokenizer, and Ollama models per config."""

View file

@ -16,7 +16,7 @@ def run_chat(
"""
try:
from haiku.rag.chat.app import ChatApp
except ImportError as e:
except ImportError as e: # pragma: no cover
raise ImportError(
"textual is not installed. Please install it with `pip install 'haiku.rag-slim[tui]'` or use the full haiku.rag package."
) from e