31 lines
1.7 KiB
Python
31 lines
1.7 KiB
Python
import logging
|
|
from common.db.run import select_run, update_run_status
|
|
from models.status import AnalysisStatus
|
|
from services.collect import collect_all
|
|
from services.market import run_market_analysis
|
|
from services.analysis import run_report_task, run_plan_task
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
async def run_pipeline(analysis_run_id: str) -> None:
|
|
logger.info("[pipeline] start run=%s", analysis_run_id)
|
|
|
|
# ── 1. Collect ──────────────────────────────────────────────────────────
|
|
run = await select_run(analysis_run_id)
|
|
await collect_all(analysis_run_id, hospital_id=run["hospital_id"])
|
|
|
|
# ── 2. Market ────────────────────────────────────────────────────────────
|
|
await update_run_status(analysis_run_id, AnalysisStatus.ANALYZING)
|
|
await run_market_analysis(analysis_run_id)
|
|
|
|
# ── 3. Report ────────────────────────────────────────────────────────────
|
|
await run_report_task(analysis_run_id)
|
|
|
|
# ── 4. Plan ──────────────────────────────────────────────────────────────
|
|
await update_run_status(analysis_run_id, AnalysisStatus.PLANNING)
|
|
await run_plan_task(analysis_run_id)
|
|
|
|
await update_run_status(analysis_run_id, AnalysisStatus.COMPLETED)
|
|
logger.info("[pipeline] done run=%s", analysis_run_id)
|