OzWrapper.OzAnomaly.scheduler.Scheduler¶
- class OzWrapper.OzAnomaly.scheduler.Scheduler(store: object, device_id: str, *, prefix: str = 'anomaly:last_run')¶
Tracks last-run timestamp per device for the anomaly detector.
- Variables:
store – Object exposing
get(key)andset(key, value). In production: the Redis client held byManager.OzCache. In tests: a plaindict(which satisfies both methods).device_id – Device identifier — keys are namespaced per device.
prefix – Key prefix. Defaults to
"anomaly:last_run".
- get_last_run_seconds() int | None¶
Return the unix-second timestamp of the last recorded run.
Returns
Noneif the detector has never run on this device, if the store lookup raised, or if the stored value isn’t an int. Callers should treatNoneas “due”.
- is_due(schedule_hours: float) bool¶
Return True when
schedule_hourshave elapsed since the last run.Fractional hours are supported — pass e.g.
0.25for a 15-minute cadence. First-ever call (no stored timestamp) is always due. A store-layer failure is also treated as due — over-running once on the next loop tick is preferable to silently skipping a window.
- device_id¶
- prefix = 'anomaly:last_run'¶
- store¶