feat(pipeline): tests, docs, and ruff fixes (subtask 6/6)

- Add 29-test suite for all pipeline routes, data helpers, and query
  execution (test_pipeline.py); all 1333 tests pass
- Fix ruff UP041: asyncio.TimeoutError → TimeoutError in analytics.py
- Fix ruff UP036/F401: replace sys.version_info tomllib block with
  plain `import tomllib` (project requires Python 3.11+)
- Fix ruff F841: remove unused `cutoff` variable in pipeline_overview
- Update CHANGELOG.md with Pipeline Console entry
- Update PROJECT.md: add Pipeline Console to Admin Panel done list

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Deeman
2026-02-25 13:02:51 +01:00
parent 8f8f7f7acb
commit d637687795
5 changed files with 591 additions and 19 deletions

View File

@@ -25,8 +25,7 @@ import logging
import os
import re
import sqlite3
import sys
import time
import tomllib
from datetime import UTC, datetime, timedelta
from pathlib import Path
@@ -307,18 +306,7 @@ def _load_workflows() -> list[dict]:
if not _WORKFLOWS_TOML.exists():
return []
if sys.version_info >= (3, 11):
import tomllib
data = tomllib.loads(_WORKFLOWS_TOML.read_text())
else:
# Fallback for older Python (shouldn't happen — project requires 3.11+)
try:
import tomli as tomllib # type: ignore[no-redef]
data = tomllib.loads(_WORKFLOWS_TOML.read_text())
except ImportError:
return []
data = tomllib.loads(_WORKFLOWS_TOML.read_text())
workflows = []
for name, config in data.items():
@@ -422,9 +410,6 @@ async def pipeline_overview():
latest_by_name = {r["extractor"]: r for r in latest_runs}
# Enrich each workflow with its latest run data
cutoff = (datetime.now(UTC) - timedelta(hours=_STALE_THRESHOLD_HOURS)).strftime(
"%Y-%m-%dT%H:%M:%SZ"
)
workflow_rows = []
for wf in workflows:
run = latest_by_name.get(wf["name"])

View File

@@ -74,7 +74,7 @@ async def fetch_analytics(sql: str, params: list | None = None) -> list[dict[str
asyncio.to_thread(_run),
timeout=_QUERY_TIMEOUT_SECONDS,
)
except asyncio.TimeoutError:
except TimeoutError:
logger.error("DuckDB analytics query timed out after %ds: %.200s", _QUERY_TIMEOUT_SECONDS, sql)
return []
except Exception:
@@ -123,5 +123,5 @@ async def execute_user_query(
asyncio.to_thread(_run),
timeout=timeout_seconds,
)
except asyncio.TimeoutError:
except TimeoutError:
return [], [], f"Query timed out after {timeout_seconds}s.", 0.0