Files
FishServer/fish_api/app/state.py

43 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from __future__ import annotations
import asyncio
from dataclasses import dataclass, field
from datetime import datetime
from typing import List, Optional
@dataclass
class MeasureSnapshot:
result: List[dict]
video_left: str
video_right: str
updated_at: Optional[datetime] = None
error: Optional[str] = None
raw_prediction_path: Optional[str] = None
pred: Optional[float] = None # 最终预测的体重值
star: bool = False # 置信度标记True 表示计算可信
#: 与 FishMeasure ``test_dgcnn_weight_estimator.py`` 终端输出一致的体重推算过程文本
calculation_log: Optional[str] = None
@dataclass
class HealthSnapshot:
behavior_result: str
health_result: str
updated_at: Optional[datetime] = None
error: Optional[str] = None
raw_class_en: str = ""
@dataclass
class AppState:
measure_lock: asyncio.Lock = field(default_factory=asyncio.Lock)
action_lock: asyncio.Lock = field(default_factory=asyncio.Lock)
# job status for optional polling业务结果见 SQLite
measure_status: str = "idle"
action_status: str = "idle"
app_state = AppState()