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.

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 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 reason_counts: Counter

How many runs failed in each way.

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