flexmeasures.data.services.automation_monitoring
Find the automation runs that failed, so that monitoring can report them.
Functions
- flexmeasures.data.services.automation_monitoring.get_unalerted_failed_automation_runs(stuck_after: timedelta, now: datetime | None = None) list[FailedAutomationRun]
Return the automation runs that failed and were not reported yet, oldest first.
A run failed when its execution failed, when its execution has been running for longer than
stuck_after, or when its dispatch failed and will not be attempted again. This holds for every automation type, although only the types that record their execution can fail on it. Runs of an automation that opted out of monitoring are left out, and stay unreported until it opts back in.- Parameters:
stuck_after – How long a run may execute before it counts as stuck.
now – The moment to judge by, which defaults to the server’s current time.
- flexmeasures.data.services.automation_monitoring.group_failed_runs_by_automation(failed_runs: list[FailedAutomationRun]) list[AutomationFailures]
Collapse failed runs per automation, keeping the order in which the automations first appear.
Classes
- class flexmeasures.data.services.automation_monitoring.AutomationFailures(automation: Automation, failed_runs: list[FailedAutomationRun] = <factory>)
The failed runs of one automation, collapsed into what a digest says about them.
- __init__(automation: Automation, failed_runs: list[FailedAutomationRun] = <factory>) None
- property first_run: AutomationRun
The failed run that was due first.
- property last_error: str | None
The error of the most recent failed run that recorded one, if any did.
- property last_run: AutomationRun
The failed run that was due most recently.
- property runs_failed_while_unmonitored: list[AutomationRun]
The failed runs that were due before monitoring was last switched back on.
Had the automation been monitored then, an earlier digest would have reported them.
- class flexmeasures.data.services.automation_monitoring.FailedAutomationRun(run: AutomationRun, reason: str)
An automation run that failed, with the way it failed.
- __init__(run: AutomationRun, reason: str) None