feat: 配置写死与 baked 模块,Alembic 建表,百度仅 BAIDU_*

- 新增 app/baked/algorithm|pipeline,非部署参数不再走 env;Settings 保留 DB/HTTP/RTSP/海康/百度/MinIO/Demo
- 移除 init_db_schema 与 reload 配置;main 仅 check_database;start*.sh 在 uvicorn 前执行 alembic upgrade head
- 依赖 psycopg[binary] 供 Alembic 同步 URL;alembic/env 注释与预发清单更新
- 撕段门控消费管线、各视频/语音/归档调用改为 baked
- 百度环境变量仅 BAIDU_APP_ID、BAIDU_API_KEY、BAIDU_SECRET_KEY 与 BAIDU_* 超时/ASR;人脸脚本与 baidu_speech 文案同步
- 全量单测与 .env.example 更新;.gitignore 忽略 refs/(本地权重/视频不入库)

Made-with: Cursor
This commit is contained in:
Kevin
2026-04-24 15:33:22 +08:00
parent b651364877
commit 8a4bad99d3
47 changed files with 1333 additions and 648 deletions

View File

@@ -16,7 +16,7 @@ from typing import Awaitable, Callable
from loguru import logger
from app.config import Settings
from app.baked import pipeline as bp
from app.services.video.rtsp_capture import RtspCapture
@@ -38,12 +38,10 @@ class CameraStreamWorker:
def __init__(
self,
*,
settings: Settings,
surgery_id: str,
camera_id: str,
url: str,
) -> None:
self._s = settings
self._surgery_id = surgery_id
self._camera_id = camera_id
self._url = url
@@ -65,7 +63,7 @@ class CameraStreamWorker:
if cap is None:
try:
cap = RtspCapture(
self._url, open_timeout_sec=self._s.video_open_timeout_sec
self._url, open_timeout_sec=bp.VIDEO_OPEN_TIMEOUT_SEC
)
await asyncio.to_thread(cap.open)
consecutive_failures = 0
@@ -89,7 +87,7 @@ class CameraStreamWorker:
if cap is not None:
await asyncio.to_thread(cap.release)
cap = None
await asyncio.sleep(self._s.video_reconnect_backoff_seconds)
await asyncio.sleep(bp.VIDEO_RECONNECT_BACKOFF_SECONDS)
continue
ok, frame = await asyncio.to_thread(cap.read)
@@ -97,7 +95,7 @@ class CameraStreamWorker:
consecutive_failures += 1
if (
consecutive_failures
>= self._s.video_read_failure_reconnect_threshold
>= bp.VIDEO_READ_FAILURE_RECONNECT_THRESHOLD
):
logger.warning(
"RTSP reconnect camera={} surgery={} url={} after {} read failures",
@@ -109,7 +107,7 @@ class CameraStreamWorker:
await asyncio.to_thread(cap.release)
cap = None
consecutive_failures = 0
await asyncio.sleep(self._s.video_reconnect_backoff_seconds)
await asyncio.sleep(bp.VIDEO_RECONNECT_BACKOFF_SECONDS)
else:
await asyncio.sleep(0.05)
continue