feat(fish_api): SQLite 快照投递、日志与 watch 空闲告警

- 新增 SQLite:measure/health 快照、delivery_cursor 单消费者 pop;clear/start_fresh 可清空库
- biomass GET 仅返回约定 data 字段,X-Fish-Biomass-New 表示是否有新快照;poller 读响应头
- loguru 桥接 uvicorn,子进程 stdout 流式输出;format_json_pretty 与算法摘要日志
- measure/action watch 无新任务时限流 WARNING;watch_idle 共用逻辑
- 依赖 loguru;新增 db、logging_config、subprocess_run、watch_idle、启动脚本

FishMeasure: 更新 fish_video_weight_evaluation 与 predict_weigth_from_svo2;移除未用 refbox/segmentation 脚本
Made-with: Cursor
This commit is contained in:
zaiun xu
2026-04-09 11:54:30 +08:00
parent db181d4f84
commit 5e1b2117c1
29 changed files with 1464 additions and 1714 deletions

View File

@@ -5,6 +5,7 @@ from pathlib import Path
from fastapi import APIRouter, BackgroundTasks, Depends, HTTPException, Request, Response
from app.db import save_health_snapshot, save_measure_snapshot
from app.deps import require_ingest_auth
from app.services import action as action_svc
from app.services import measure as measure_svc
@@ -27,14 +28,18 @@ async def _measure_job_serial(svo_path: Path, settings: Settings) -> None:
snap = await asyncio.to_thread(
measure_svc.run_full_measure, svo_path, settings
)
app_state.last_measure = snap
save_measure_snapshot(settings, snap, source_path=str(svo_path.resolve()))
app_state.measure_status = "idle"
except Exception as e:
app_state.last_measure = MeasureSnapshot(
result=[],
video_left="",
video_right="",
error=str(e),
save_measure_snapshot(
settings,
MeasureSnapshot(
result=[],
video_left="",
video_right="",
error=str(e),
),
source_path=str(svo_path.resolve()),
)
app_state.measure_status = "error"
@@ -46,13 +51,17 @@ async def _action_job_serial(mp4_path: Path, settings: Settings) -> None:
snap = await asyncio.to_thread(
action_svc.run_full_action, mp4_path, settings
)
app_state.last_health = snap
save_health_snapshot(settings, snap, source_path=str(mp4_path.resolve()))
app_state.action_status = "idle"
except Exception as e:
app_state.last_health = HealthSnapshot(
behavior_result="",
health_result="",
error=str(e),
save_health_snapshot(
settings,
HealthSnapshot(
behavior_result="",
health_result="",
error=str(e),
),
source_path=str(mp4_path.resolve()),
)
app_state.action_status = "error"