OzWrapper.OzAnomaly.scheduler

Schedule tracking for the anomaly detector.

Persists the last-run timestamp per device so the detector doesn’t re-fire on every loop tick, and so a reboot doesn’t reset the schedule clock. The backing store is injected — in production it’s the Redis client OzCache already holds (one new key per device, anomaly:last_run:{deviceId}).

The store contract is the redis-py shape: get(key) returning the stored value (str / bytes / None) and set(key, value) accepting a string value. redis.Redis satisfies it directly; tests can use a tiny wrapper around a dict (a plain dict does not fit because Python dicts expose __setitem__ but no .set() method).

Failures in the store layer are non-fatal — every call degrades to “treat as if the detector has never run” so the worst case is one extra run, not a silent skip. If mark_run fails persistently, the detector will run on every tick until the store recovers — that’s intentional, we prefer over-running to silently skipping a window.

Attributes

Classes

Scheduler

Tracks last-run timestamp per device for the anomaly detector.

Module Contents

OzWrapper.OzAnomaly.scheduler.logger