Update installer and runtime setup flow

This commit is contained in:
Jino Jose committed 2026-07-09 10:30:10 +05:30
1 parent 8603fb2bc2
commit 7540da04a8
5 files changed
+385 -54

No files matched your search

@@ -20,7 +20,7 @@ Usage (called by main.py):
--ollama-url http://localhost:11434
"""
import argparse, json, os, sqlite3, sys, uuid
import argparse, json, logging, os, sqlite3, sys, uuid
from datetime import datetime, timezone
from pathlib import Path
@@ -38,6 +38,27 @@ CHUNK_SIZE = 512 # tokens/chars per chunk
CHUNK_OVERLAP = 64 # overlap between consecutive chunks
BATCH_SIZE = 16 # how many chunks to embed + upsert at once
# ── Logging ───────────────────────────────────────────────────────────────────
# Ingest runs as a detached subprocess of the API, so failures used to be
# surfaced to the portal as a raw Python traceback stuffed into error_msg.
# Now the full traceback goes to a log file (server-side only) and the DB gets
# a short, human-readable message instead.
_LOG_FILE = Path(args.db_path).resolve().parent / "cezen-ingest.log"
logger = logging.getLogger("cezen.ingest")
if not logger.handlers:
_handler = logging.FileHandler(_LOG_FILE)
_handler.setFormatter(logging.Formatter("%(asctime)s [%(levelname)s] %(message)s"))
logger.addHandler(_handler)
logger.setLevel(logging.INFO)
def friendly_error(e: Exception, context: str) -> str:
"""Log the full exception + traceback server-side; return a short, actionable message for the UI."""
logger.error("doc_id=%s context=%s", args.doc_id, context, exc_info=True)
msg = str(e).strip() or e.__class__.__name__
if len(msg) > 200:
msg = msg[:200] + "..."
return f"{msg} (see server ingest log for full details, request context: {context})"
def utcnow():
return datetime.now(timezone.utc).isoformat()
@@ -256,8 +277,7 @@ def main():
processed += len(batch)
except Exception as e:
import traceback
set_status("failed", chunk_count=processed, error=f"{e}\n{traceback.format_exc()[:500]}")
set_status("failed", chunk_count=processed, error=friendly_error(e, "embed_and_upsert"))
sys.exit(1)
set_status("ready", chunk_count=total)
@@ -266,9 +286,8 @@ if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
set_status("failed", error="Interrupted")
set_status("failed", error="Ingest was interrupted before it could finish. Try uploading the document again.")
sys.exit(130)
except Exception as e:
import traceback
set_status("failed", error=f"{e}\n{traceback.format_exc()[:500]}")
set_status("failed", error=friendly_error(e, "main"))
sys.exit(1)