fix video label
This commit is contained in:
@@ -6,10 +6,15 @@ from typing import Dict, Set
|
||||
|
||||
from loguru import logger
|
||||
|
||||
from app.db import add_watch_processed, load_watch_processed, save_health_snapshot
|
||||
from app.db import (
|
||||
add_watch_processed,
|
||||
health_snapshot_deliverable,
|
||||
load_watch_processed,
|
||||
save_health_snapshot,
|
||||
)
|
||||
from app.services import action as action_svc
|
||||
from app.settings import Settings
|
||||
from app.state import HealthSnapshot, app_state
|
||||
from app.state import app_state
|
||||
from app.watch_idle import IdleWatchWarnState, idle_warn_interval_sec, maybe_warn_idle_watch
|
||||
|
||||
_ACTION_IDLE_WARN_INTERVAL_SEC = idle_warn_interval_sec(
|
||||
@@ -52,7 +57,13 @@ async def _run_inference_and_state(
|
||||
app_state.action_status = "running"
|
||||
try:
|
||||
snap = await asyncio.to_thread(action_svc.run_full_action, mp4, settings)
|
||||
save_health_snapshot(settings, snap, source_path=key)
|
||||
if health_snapshot_deliverable(snap):
|
||||
save_health_snapshot(settings, snap, source_path=key)
|
||||
else:
|
||||
logger.warning(
|
||||
"[action-watch] no deliverable health snapshot for {}, skip SQLite",
|
||||
mp4.name,
|
||||
)
|
||||
app_state.action_status = "idle"
|
||||
processed.add(key)
|
||||
if settings.action_watch_use_state_file:
|
||||
@@ -60,18 +71,11 @@ async def _run_inference_and_state(
|
||||
pred = (snap.raw_class_en or "").strip()
|
||||
logger.info("[action-watch] done: {} -> {}", mp4.name, pred)
|
||||
except Exception as e:
|
||||
save_health_snapshot(
|
||||
settings,
|
||||
HealthSnapshot(
|
||||
behavior_result="",
|
||||
health_result="",
|
||||
error=str(e),
|
||||
),
|
||||
source_path=key,
|
||||
)
|
||||
app_state.action_status = "error"
|
||||
logger.exception("[action-watch] error on {}: {}", mp4, e)
|
||||
raise
|
||||
app_state.action_status = "idle"
|
||||
processed.add(key)
|
||||
if settings.action_watch_use_state_file:
|
||||
add_watch_processed(settings, key, "action")
|
||||
|
||||
|
||||
async def watch_tick(
|
||||
@@ -106,12 +110,9 @@ async def watch_tick(
|
||||
stability[key] = (size, cnt + 1)
|
||||
_, cnt = stability[key]
|
||||
if cnt >= settings.action_watch_stable_polls:
|
||||
try:
|
||||
await _run_inference_and_state(mp4, settings, processed, state_file)
|
||||
stability.pop(key, None)
|
||||
did = True
|
||||
except Exception:
|
||||
stability[key] = (size, 1)
|
||||
await _run_inference_and_state(mp4, settings, processed, state_file)
|
||||
stability.pop(key, None)
|
||||
did = True
|
||||
for k in list(stability.keys()):
|
||||
if k not in seen_keys:
|
||||
del stability[k]
|
||||
|
||||
Reference in New Issue
Block a user