kin: auto-commit after pipeline

This commit is contained in:
Gros Frumos 2026-03-17 15:59:43 +02:00
parent 396f5193d3
commit 18160de45e
9 changed files with 449 additions and 0 deletions

View file

@ -496,6 +496,7 @@ def update_pipeline(
total_cost_usd: float | None = None,
total_tokens: int | None = None,
total_duration_seconds: int | None = None,
pid: int | None = None,
) -> dict:
"""Update pipeline status and stats."""
fields: dict[str, Any] = {}
@ -509,6 +510,8 @@ def update_pipeline(
fields["total_tokens"] = total_tokens
if total_duration_seconds is not None:
fields["total_duration_seconds"] = total_duration_seconds
if pid is not None:
fields["pid"] = pid
if fields:
sets = ", ".join(f"{k} = ?" for k in fields)
vals = list(fields.values()) + [id]
@ -520,6 +523,14 @@ def update_pipeline(
return _row_to_dict(row)
def get_running_pipelines_with_pid(conn: sqlite3.Connection) -> list[dict]:
"""Return all running pipelines that have a known PID (used by watchdog)."""
rows = conn.execute(
"SELECT id, task_id, pid FROM pipelines WHERE status = 'running' AND pid IS NOT NULL"
).fetchall()
return _rows_to_list(rows)
# ---------------------------------------------------------------------------
# Support
# ---------------------------------------------------------------------------