phase 1
This commit is contained in:
41
detect/events.py
Normal file
41
detect/events.py
Normal file
@@ -0,0 +1,41 @@
|
||||
"""
|
||||
Detection pipeline event helpers.
|
||||
|
||||
Non-generated runtime code for pushing SSE events.
|
||||
The event payload types are in sse_contract.py (generated by modelgen).
|
||||
"""
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from core.events import push_event
|
||||
|
||||
DETECT_EVENTS_PREFIX = "detect_events"
|
||||
|
||||
# SSE event type names
|
||||
EVENT_GRAPH_UPDATE = "graph_update"
|
||||
EVENT_STATS_UPDATE = "stats_update"
|
||||
EVENT_FRAME_UPDATE = "frame_update"
|
||||
EVENT_DETECTION = "detection"
|
||||
EVENT_LOG = "log"
|
||||
EVENT_JOB_COMPLETE = "job_complete"
|
||||
|
||||
ALL_EVENT_TYPES = [
|
||||
EVENT_GRAPH_UPDATE,
|
||||
EVENT_STATS_UPDATE,
|
||||
EVENT_FRAME_UPDATE,
|
||||
EVENT_DETECTION,
|
||||
EVENT_LOG,
|
||||
EVENT_JOB_COMPLETE,
|
||||
]
|
||||
|
||||
TERMINAL_EVENTS = [EVENT_JOB_COMPLETE]
|
||||
|
||||
|
||||
def push_detect_event(job_id: str, event_type: str, data: BaseModel) -> None:
|
||||
"""Push a typed detection event to Redis."""
|
||||
push_event(
|
||||
job_id=job_id,
|
||||
event_type=event_type,
|
||||
data=data.model_dump(mode="json"),
|
||||
prefix=DETECT_EVENTS_PREFIX,
|
||||
)
|
||||
Reference in New Issue
Block a user