From 1c9c0f56f1b69a770f58f5ce4026b0ce1391f4b2 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Mon, 5 Jan 2026 12:33:44 -0600 Subject: [PATCH] types and dispatcher changes for jobs --- frigate/comms/dispatcher.py | 17 +++++++++++++++++ frigate/const.py | 1 + frigate/types.py | 9 +++++++++ 3 files changed, 27 insertions(+) diff --git a/frigate/comms/dispatcher.py b/frigate/comms/dispatcher.py index 6e45ac175..68749b102 100644 --- a/frigate/comms/dispatcher.py +++ b/frigate/comms/dispatcher.py @@ -28,6 +28,7 @@ from frigate.const import ( UPDATE_CAMERA_ACTIVITY, UPDATE_EMBEDDINGS_REINDEX_PROGRESS, UPDATE_EVENT_DESCRIPTION, + UPDATE_JOB_STATE, UPDATE_MODEL_STATE, UPDATE_REVIEW_DESCRIPTION, UPSERT_REVIEW_SEGMENT, @@ -60,6 +61,7 @@ class Dispatcher: self.camera_activity = CameraActivityManager(config, self.publish) self.audio_activity = AudioActivityManager(config, self.publish) self.model_state: dict[str, ModelStatusTypesEnum] = {} + self.job_state: dict[str, dict[str, Any]] = {} # {job_type: job_data} self.embeddings_reindex: dict[str, Any] = {} self.birdseye_layout: dict[str, Any] = {} self.audio_transcription_state: str = "idle" @@ -180,6 +182,19 @@ class Dispatcher: def handle_model_state() -> None: self.publish("model_state", json.dumps(self.model_state.copy())) + def handle_update_job_state() -> None: + if payload and isinstance(payload, dict): + job_type = payload.get("job_type") + if job_type: + self.job_state[job_type] = payload + self.publish( + "job_state", + json.dumps(self.job_state), + ) + + def handle_job_state() -> None: + self.publish("job_state", json.dumps(self.job_state.copy())) + def handle_update_audio_transcription_state() -> None: if payload: self.audio_transcription_state = payload @@ -277,6 +292,7 @@ class Dispatcher: UPDATE_EVENT_DESCRIPTION: handle_update_event_description, UPDATE_REVIEW_DESCRIPTION: handle_update_review_description, UPDATE_MODEL_STATE: handle_update_model_state, + UPDATE_JOB_STATE: handle_update_job_state, UPDATE_EMBEDDINGS_REINDEX_PROGRESS: handle_update_embeddings_reindex_progress, UPDATE_BIRDSEYE_LAYOUT: handle_update_birdseye_layout, UPDATE_AUDIO_TRANSCRIPTION_STATE: handle_update_audio_transcription_state, @@ -284,6 +300,7 @@ class Dispatcher: "restart": handle_restart, "embeddingsReindexProgress": handle_embeddings_reindex_progress, "modelState": handle_model_state, + "jobState": handle_job_state, "audioTranscriptionState": handle_audio_transcription_state, "birdseyeLayout": handle_birdseye_layout, "onConnect": handle_on_connect, diff --git a/frigate/const.py b/frigate/const.py index 11e89886f..ac8144c2c 100644 --- a/frigate/const.py +++ b/frigate/const.py @@ -119,6 +119,7 @@ UPDATE_REVIEW_DESCRIPTION = "update_review_description" UPDATE_MODEL_STATE = "update_model_state" UPDATE_EMBEDDINGS_REINDEX_PROGRESS = "handle_embeddings_reindex_progress" UPDATE_BIRDSEYE_LAYOUT = "update_birdseye_layout" +UPDATE_JOB_STATE = "update_job_state" NOTIFICATION_TEST = "notification_test" # IO Nice Values diff --git a/frigate/types.py b/frigate/types.py index 6c5135616..77bb50845 100644 --- a/frigate/types.py +++ b/frigate/types.py @@ -26,6 +26,15 @@ class ModelStatusTypesEnum(str, Enum): failed = "failed" +class JobStatusTypesEnum(str, Enum): + pending = "pending" + queued = "queued" + running = "running" + success = "success" + failed = "failed" + cancelled = "cancelled" + + class TrackedObjectUpdateTypesEnum(str, Enum): description = "description" face = "face"