Initial commit: Nat20 Notes — TTRPG session transcription & summarization

This commit is contained in:
KansaiGaijin
2026-07-06 23:45:54 +12:00
commit 0f9e9d4c5c
49 changed files with 2926 additions and 0 deletions

41
backend/app/jobs.py Normal file
View File

@@ -0,0 +1,41 @@
"""
Minimal background job runner.
"""
import traceback
from concurrent.futures import ThreadPoolExecutor
from . import database as db
from .errors import PipelineError
from .logging_config import get_logger
log = get_logger(__name__)
_executor = ThreadPoolExecutor(max_workers=2) # transcription is GPU-bound anyway; no benefit to more workers
def submit(job_id: str, fn, *args, **kwargs):
def _run():
log.info("Job %s starting", job_id)
db.update_job(job_id, status="running", progress="Starting...")
try:
def progress_cb(msg):
log.info("Job %s: %s", job_id, msg)
db.update_job(job_id, progress=msg)
fn(*args, progress_cb=progress_cb, **kwargs)
db.update_job(job_id, status="done", progress="Complete")
log.info("Job %s complete", job_id)
except PipelineError as e:
log.error("Job %s failed at stage '%s': %s", job_id, e.stage, e.message)
db.update_job(
job_id, status="error",
error=e.message, error_stage=e.stage,
error_detail=traceback.format_exc(),
)
except Exception as e:
log.exception("Job %s failed with unexpected error", job_id)
db.update_job(
job_id, status="error",
error=f"Unexpected error: {e}", error_stage="unknown",
error_detail=traceback.format_exc(),
)
_executor.submit(_run)