Repository navigation
Feat: automation cross org skip notice - #2940
Closed
BelhsanHmida wants to merge 66 commits into
Closed
BelhsanHmida wants to merge 66 commits into
BelhsanHmida wants to merge 66 commits into
Conversation
…s end Context: - Only forecast runs followed their jobs, so schedule, report and plugin runs stayed at execution state 'pending' whatever became of their jobs. Change: - record_automation_run_jobs records the jobs such a run queued, then takes the outcome of any job that already finished or failed from Redis; a run with no jobs has succeeded. - The record_outcome_on_automation_run decorator records a job's start, success or failure on its run, found through the job's RQ ID, and wraps make_schedule, the sequential wrap-up job, run_report_job and execute_automation_job. - Plugin jobs carry automation_run_id in their trigger. - A schedule that fell back counts as a failed run, as the fallback job is not one of the run's recorded jobs. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Context: - Schedule, report and plugin runs now record how their jobs ended. Change: - Schedule runs, single and sequential, succeed once their jobs did and fail with the job's error; a job queued outside a run is not recorded. - A plugin run records its job's outcome, also when the job finished before the run recorded it. - Report run tests check the run's outcome: succeeded, nothing to do, and refused. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Context: - Schedule, report and plugin runs now record how their jobs ended, as forecast runs did. Change: - Say which jobs each type of run records, that a run without jobs has succeeded, and that a schedule which fell back counts as failed. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Context: - main moved 11 commits on, including #2689, which saves what a data generator returns through generator_results and renames the unchecked-sensor errors to GeneratorWritesUncheckedSensor. Change: - Keep the record_outcome_on_automation_run imports next to main's new ones in data/automations.py and services/reporting.py. - Keep the decorator on make_schedule where main dropped ScheduleWritesUncheckedSensor. - The report refusal test expects GeneratorWritesUncheckedSensor as the run's error type. - The failed schedule test breaks the save through save_generator_results, which make_schedule now calls instead of save_to_db. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Context: - The v3.0-33 entry on run-stats said only forecast runs record their execution state, which PR #2670 makes untrue. Change: - Say execution state and job records are kept for every type of automation. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Context: - main moved 4 commits on, and #2647 changed the rq.job import in test_automations_fresh_db.py. Change: - Keep main's `from rq.job import Job, JobStatus` and this branch's `from sqlalchemy import select`. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Context: - Issue #2586: an automation consuming another's results could only be ordered by staggering cron strings Change: - New automation_dependency table, and 'waiting' and 'skipped' run states - A run waits for the upstream runs scheduled for the same time, and is dispatched once they ended, or skipped if one failed (unless failure is allowed) - Waiting runs are released when the upstream run ends, and by the runner's tick as a backstop - Dependencies are validated: same schedule, no cycles, readable upstream automations Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…copy Context: - Issue #2586 asks what a copy does with a dependency Change: - A copy waits for the copied upstream automation where that was copied too, and for the original one otherwise Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Context: - Issue #2586 Change: - depends-on on creating, updating and reading automations, and upstream-runs on run stats - PATCH checks the user may read the upstream automations, and refuses a schedule that breaks a dependency Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Context: - Issue #2586 Change: - add/edit automation take --depends-on and --allow-failure-of, edit also --no-dependencies - show automation lists dependencies, run-automations reports waiting and skipped runs Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Context: - Issue #2586 Change: - A 'Waits for' picker on the create and edit forms, copying the picked automation's schedule into the create form - The details panel lists the dependencies Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Context: - Issue #2586 Change: - Runner tests with a real worker: wait then release, skip, allow-failure, cascade, missed release, passed-over and inactive upstreams - Validation, API permission and schedule checks, CLI options, and copied dependencies Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Context: - Issue #2586 Change: - New section on dependencies, the waiting and skipped run states, and that a run on demand does not wait Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Context: - PR #2706 Change: - Entry in 'Automations, in detail' and in the CLI changelog Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Resolve conflicts with the squash-merged #2670 and with #2657: take main's naming of schedule jobs and its job-failure path, keep the release of waiting runs where a run ends, and use AUTOMATION_RUN_RETRIED_TYPES, which now includes scheduling. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…tion bf22b21d0990 Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
A run now waits for each upstream automation's latest run due at or before its own scheduled time, by the upstream automation's own cron string and timezone, so for instance an hourly forecast can wait for meter data pulled every 15 minutes. The same-schedule check on creation and edit is dropped, and so is the UI copying the upstream schedule into the form. The run record names the time the upstream run was due at (due-at). Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
flexmeasures jobs run-automation --with-dependents, the trigger endpoint's with-dependents query parameter and the Automations page's Run with dependents start a run of the automation now, and a run for each active automation that waits for it, directly or through others, which waits for the runs started along with it, and is skipped if one of those failed. This is how a chain is re-run, for instance after backfilling the data at its start. A run records whether it was due by schedule or asked for on demand (trigger), so that on-demand runs can share a minute with scheduled runs, and a scheduled run only ever waits for scheduled upstream runs. The runner does not retry on-demand runs, as whoever started them is told when they fail. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
The details panel on the Automations page draws the automations listed there that this one waits for, on the left, and those that wait for it, on the right, directly or through others, with a dashed arrow where the waiting automation runs even when the one it waits for failed. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
The Waits for field in the creation and edit forms was a multiple select, which took Ctrl-clicks to pick several automations and cut long names off. Each automation is now a row with a tick box, naming its asset and recurrence, and dragging the corner of the list enlarges it. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
v1.1.0 shipped without this feature, so its changelog entries move to new sections after it. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Clicking an automation in a chain opens its details on the page of its own asset. Hovering over an automation tells its type, asset and recurrence, and hovering over an arrow what a failure does. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
A killed job never recorded its outcome, which left its run unfinished, and everything waiting for that run waiting forever. On each tick, the runner now looks up the unfinished jobs in Redis, and records what became of them. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
The PATCH description said it could not, which was never the case. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…ing for it The chain, the details and the edit form only had its ID, so they could not link to it. Automation responses now give its name and asset to whoever may read it. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Run with ascendants brings one automation up to date: what it waits for runs first, and what waits for it does not run. What may not be run is left out and reported, and a new run-plan endpoint tells what a run would come down to. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Run with ascendants joins the actions, and both ways of running a chain now show the IDs that run, in order, first. Branches above an automation can be left out there, and what will not run says why. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Refusing a dependency that would close a loop showed the raw response in the edit form. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
It then runs without it, which was easy to miss, so the page and the CLI name those automations first. They can be on other assets, so an automation's details now report waited-for-by. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
… runs on deactivation Running an inactive automation with what is upstream of it ran its upstream automations, but left its own run waiting for ever, as neither the release nor the runner looked at waiting runs of inactive automations. A run on demand is now released whether its automation is active or not. Deactivating an automation cancels its scheduled runs that are still waiting, which would otherwise go ahead late on reactivation, and what waits for them goes ahead without them, as for an inactive automation. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Each upstream run a run waits for gets a summary, such as "Solar forecast (automation 3, run 4) failed." or "... was not due yet at 2026-08-05 13:00 UTC, as it was created after that.", in the times of the upstream automation's own clock. The skip reason and the waiting message are made of these, rather than bare IDs and states, and the skip reason names only the runs it was skipped for. The Automations page shows the summaries of the latest run. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Their tooltips say the automation chain runs up to, or from, this automation, as do the titles of the plans they show first. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…ver did The run plan's excluded automations come with the steps that wait for them, and with when they last succeeded, as those steps go by the results they produced then. The plan shown before a chain runs says so per excluded automation, rather than "The rest goes by the latest results of those that won't run", and warns where one never succeeded, as what waits for it will likely fail, without keeping the chain from running. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…ns due" A tick that failed a killed job's run, and skipped or set off the runs waiting for it, printed "No automations due", so an operator watching the cron log saw nothing. The runner's tick now reports each run it ended for a job that ended without saying so, and each run that released as a result, in that order, with the run's own message, and "No automations due" only when nothing happened. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
"Automations on this page" and "Automations on this asset only" become "This asset and the assets below it" and "This asset only", and without the automations of the assets below it listed, which makes the two the same, only "This asset only" is offered. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Where the automations it waits for differ, the box's mixed state looked unticked, so a line under it names each of them with yes or no, and says that ticking or unticking sets all of them. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…its sensors flexmeasures show automations --id said "Depends on" for automations right next to "Reads from" for sensors, which read alike. It now says "Waits for", with each one's recurrence and timezone, as those decide which of their runs are waited for, adds "Waited for by", and heads the sensor lists "Sensors it reads" and "Sensors it writes". Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
A run on demand left claimed, such as by an API process that went down between recording a chain of runs and queueing the first, was never retried, as only scheduled runs are, and never counted as given up, so its chain waited for ever. The runner now fails such a run once the claim on it expires, which skips what waits for it, and reports it. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…ng what waits for its run A job releases the runs waiting for its run once it recorded its outcome, which counts against its own timeout. Running out of time there had the queue's exception handler fail the job after all, and with it the run, so that what still waited for it was skipped. A recorded success now stands, and a runner releases what the job did not get to on its next tick. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Resolved conflicts with automation monitoring (#2671, #2702, #2703) and the security release: an automation takes both depends-on and monitored, in the API, the CLI and the page, and PATCH checks monitoring rights and the minimum cron interval before updating the dependencies. Main's ?automation=<id> link and the chain drawing's link opened an automation in two functions of the same name; they are now one, which says when the automation is not listed here. The API changelog entries moved to a new v3.0-37 section, as v3.0-35 and v3.0-36 are released. The dependencies migration now follows main's merge revision 5c0f3e7a9b21. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Brings in #2896, which fixes the docs build that the security release broke. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…dispatches A waiting run has no dispatch end time and no claim, as a run whose dispatch failed for good, so the monitor reported it, and then never reported it again once it really failed. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…dy are Without a run, the run plan did not know it had succeeded, and warned that what waits for it would likely fail. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…ve out what may not be read A step lists the automations it waits for that do not run, too. What does not run along with an automation that does not run is listed, with the reason, rather than dropped without a word. An automation the user may not read is left out of the plan and of a chain run's response, so another organisation's automation ID is not given away. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…-on does Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…es not run Now that a step also lists what it waits for that does not run, only what was left out on purpose counts towards a branch to tick. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Messages said run(s), job(s) and automation(s); they now say one run or two runs. The confirmation of a run stayed on the page until it was reloaded; a toast suits it better. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Resolved conflicts with critical automations (#2856): an automation takes depends-on and critical together, in the API, the CLI and the page. When a run ends, the critical-failure hooks are told first, and then the runs waiting for it are released. A dispatch counts as given up by the same rule that releases those runs (see _dispatch_was_given_up), so a run on demand, which is never dispatched again, reaches the hooks, too. The dependencies migration now follows d4a17c6b3e92. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…ailure hooks at once Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…s run Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…n a public asset, failed The failed run is reported to its own organisation, or only to the host for a public asset, so the organisation of the run waiting for it never hears why that run did not happen. Only the first skipped run of each organisation along a chain is returned, with the runs of its organisation skipped because of it. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…he monitoring digests Each skipped run says which run it was skipped for, with that run's error if the reader may see that automation, and lists the runs of its organisation skipped after it. The host digest lists them too, and they count as reported once it is sent, as failed runs do. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Documentation build overview
45 files changed ·
|
10 tasks done
Contributor
Author
|
Replaced by a PR with only the three commits of this change on top of main, as this one listed the commits of #2706 from before its squash merge. |
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
When a run is skipped because the run it waits for failed in another organisation, or on a public asset, nobody in the skipped run's organisation hears about it: the failure is reported to the other organisation, or only to the host.
This PR reports such a skip in
flexmeasures monitor automations. For example, a battery schedule waits for a price check on a public asset, and the price check fails: the battery's organisation now gets the battery schedule as skipped in its digest, with the battery report that waits for it listed underneath.--notify-users) of the skipped run's organisationA chain that crosses into a third organisation is reported to each organisation separately, each digest listing only its own runs
alerted_at) once that digest is sent, as with failed runsdocumentation/changelog.rstLook & Feel
A user digest in the price check example (subject: "Skipped runs of 1 automation"):
How to test
Or by hand: make a public automation that fails, have an automation of your organisation wait for it, let both run, then run
flexmeasures monitor automations --notify-users. Your organisation's account admins get the skipped run, and a second monitor run sends nothing.Further Improvements
Related Items
Closes #2914
Follow-up to #2706, which it is based on
Sign-off