Repository navigation
feat: say whether an automation's runs can start, in one status field - #2943
Open
BelhsanHmida wants to merge 9 commits into
Open
BelhsanHmida wants to merge 9 commits into
BelhsanHmida wants to merge 9 commits into
Conversation
Add a status to automations (ok, runs-refused with a reason and a message, or unknown until first checked), stored rather than worked out on every read, so that listing automations stays cheap. It is set when an automation is created, edited or copied, and after each run's dispatch: a run that queued its jobs marks it ok (unless it was planned before the latest edit), and a failed dispatch works it out anew. Refusals now carry a reason, and a missing plugin raises its own NotImplementedError subclass. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…lve changes Deactivating a user, changing their roles or deleting them (API and CLI) refreshes the automations that run as them, and deleting a sensor (API and CLI) refreshes the automations involving it, so that refused runs show before the next run fails, not after. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
The API gives a status with each automation, `flexmeasures show automations` gets a Status column (and the message in its details), and the Automations page marks an automation whose runs are refused, with the reason on hover. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
📖 13 files changed · 1 added · 12 modified
Preview · build overview · flexmeasures · built Dec. 1, 2026, 11:22 p.m. UTC |
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Refusing a run on demand, or an edit, because the user the automation runs as is missing or inactive now says run-user-inactive, rather than run-user-lacks-access, which stays for a run user whose access falls short. The Automations page offers to take over for both. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
The status said whether runs can start, so a schedule whose asset lost its price looked fine while every job failed. Runs that start, but whose jobs failed in the latest run of the current revision that ended, now make it runs-failing, with the reason jobs-failed and the error they failed on; the next run that works, or an edit starting a new revision, sets it back to ok. Refused runs still come first, and the Automations page marks failing runs too. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
An automation can look fine while every run of it is refused, for instance when the user it runs as was deactivated, or a sensor it reads from was deleted, or while its runs start but every job fails, for instance when its asset lost its price.
This PR gives each automation a status that says whether its runs can start, and whether they work. For example, deactivate a colleague through the API, and every automation that runs as them now lists as:
ok,runs-refusedorruns-failing(with areasonand amessage), orunknownfor existing automations until their next run or change. A new migration adds it.run-user-inactive,run-user-lacks-access,plugin-unavailableanddefinition-invalid(say, a deleted sensor), and new ones can be added later.runs-failingwith the reasonjobs-failedand the error, e.g. "Its latest run failed on ValueError: Missing consumption price for commodity 'electricity'." The next run that works, or an edit of the definition or recurrence, sets it back took. Refused runs come first.reason: run-user-inactive(wasrun-user-lacks-access, added in Feat: edit automation config #2779, unreleased), matching the status.ok(unless it was planned before the latest edit, or runs are failing), a run whose jobs ended setsokorruns-failing, and a failed dispatch works the status out anew, so a Redis outage does not count as a refusal.creating, editing or copying an automation, deactivating a user or changing their roles (API), deleting a user or organisation (CLI), and deleting a sensor (API and CLI).
statuswith each automation,flexmeasures show automationsgets a Status column (with the message in the details), and the Automations page marks such an automation runs refused or runs failing, with the reason on hover.documentation/changelog.rstLook & Feel
GET /api/v3_0/assets/(id)/automations:{"id": 6, "name": "Battery forecasts", "status": {"state": "ok", "since": "2026-12-01T08:00:00+00:00"}, ...} {"id": 7, "name": "Day-ahead report", "status": {"state": "runs-refused", "reason": "definition-invalid", "message": "Could not determine the sensors of automation 7: {'sensor': ['No sensor found with ID 12.']}", "since": "2026-12-01T09:00:00+00:00"}, ...}flexmeasures show automations:How to test
Or by hand: deactivate the user an automation runs as (on their user page), then open the asset's Automations page. The automation is marked runs refused, and hovering the badge says why. Reactivate the user, and the badge is gone. Or point a schedule's asset at a price sensor, delete that sensor, and run the schedule: it is marked runs failing, saying the price is missing.
Further Improvements
flexmeasures monitor automationscould report automations whose runs are refused.Related Items
Closes #2911
Follow-up to #2779 and discussion #2780
Sign-off