Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
6c7798a
data/services/automations: record how schedule, report and plugin run…
BelhsanHmida Oct 7, 2026
196ccc1
data/tests: cover how schedule, report and plugin runs end
BelhsanHmida Oct 7, 2026
da14723
docs: every automation run records how its jobs ended
BelhsanHmida Oct 7, 2026
2441424
changelog: append PR #2670 to the durable automation runs entry
BelhsanHmida Oct 7, 2026
21fc37d
Merge origin/main into feat/automation-run-outcomes
BelhsanHmida Oct 12, 2026
5f37108
docs/api: run-stats records execution state for every automation type
BelhsanHmida Oct 12, 2026
627c635
Merge origin/main into feat/automation-run-outcomes
BelhsanHmida Oct 14, 2026
c9086ee
data: let an automation's runs wait for the runs of other automations
BelhsanHmida Oct 14, 2026
57686c2
data/services: copy an automation's dependencies along with an asset …
BelhsanHmida Oct 14, 2026
06dd24d
api/v3_0: name an automation's dependencies with depends-on
BelhsanHmida Oct 14, 2026
a6b40b0
cli: --depends-on and --allow-failure-of for add and edit automation
BelhsanHmida Oct 14, 2026
2dd6974
ui: pick the automations an automation waits for on the automations page
BelhsanHmida Oct 14, 2026
0e9eb68
tests: automation dependencies in the runner, API, CLI and asset copies
BelhsanHmida Oct 14, 2026
a29b235
docs: how an automation waits for other automations
BelhsanHmida Oct 14, 2026
7d93627
changelog: automation dependencies
BelhsanHmida Oct 14, 2026
8166388
Merge origin/main into feat/2586-automation-dependencies
BelhsanHmida Oct 30, 2026
31632d7
data/migrations: put automation dependencies after main's merge migra…
BelhsanHmida Oct 30, 2026
2677b4f
Let an automation wait for automations on another schedule
BelhsanHmida Oct 30, 2026
a20b557
Run an automation on demand along with the automations waiting for it
BelhsanHmida Oct 30, 2026
d54531e
ui: draw the chain an automation is part of in its details
BelhsanHmida Oct 30, 2026
c3ca00b
ui: pick the automations to wait for from a list of tick boxes
BelhsanHmida Nov 4, 2026
40bd49c
Merge origin/main into feat/2586-automation-dependencies
BelhsanHmida Nov 5, 2026
53b6c81
ui: let a chain of automations link to them and explain itself on hover
BelhsanHmida Nov 5, 2026
da67f41
Have the runner find out how a job ended that could not report it
BelhsanHmida Nov 5, 2026
4eda540
docs: say that a recurrence can change while automations depend on it
BelhsanHmida Nov 5, 2026
da0e122
Name an upstream automation that is not listed alongside the one wait…
BelhsanHmida Nov 5, 2026
15b789d
Run an automation along with what it waits for
BelhsanHmida Nov 5, 2026
19ba035
ui: show what a chain comes down to before running it
BelhsanHmida Nov 5, 2026
eafcc26
ui: show a validation error as a sentence rather than as JSON
BelhsanHmida Nov 5, 2026
30e8108
Warn about what waits for an automation before deleting it
BelhsanHmida Nov 5, 2026
48f4ffe
ui: choose which automations the Waits for lists and chains go by
BelhsanHmida Nov 5, 2026
8a98737
ui: let a chain drawing show all automations in scope
BelhsanHmida Nov 5, 2026
2b04714
ui: say so when the Waits for list is empty
BelhsanHmida Nov 5, 2026
9efca23
ui: do not say that a run queued 0 jobs while its chain goes on
BelhsanHmida Nov 5, 2026
edd04af
Give the actual reason for not copying a schedule automation
BelhsanHmida Nov 5, 2026
30ecb51
Answer an unreadable automation like one that does not exist
BelhsanHmida Nov 5, 2026
196f5c4
Merge main into feat/2586-automation-dependencies
BelhsanHmida Nov 15, 2026
adbe42f
Name chain runs upstream and downstream, and list what is excluded
BelhsanHmida Nov 15, 2026
9262fb7
Exclude a downstream automation the user may not run, rather than ref…
BelhsanHmida Nov 15, 2026
1803aca
Page through automations across assets, rather than cutting them off …
BelhsanHmida Nov 15, 2026
bcccc3b
Report waited-for-by only when asked for with include=waited-for-by
BelhsanHmida Nov 15, 2026
bdf5188
Go ahead after an upstream reset, and wait for the run an upstream ca…
BelhsanHmida Nov 15, 2026
e75a9af
Release a run on demand of an inactive automation, and cancel waiting…
BelhsanHmida Nov 15, 2026
a98331b
Say in a sentence what became of each upstream run a run waits for
BelhsanHmida Nov 15, 2026
5b5b888
Label the chain runs Run up to here and Run from here
BelhsanHmida Nov 15, 2026
640fc43
Say when each excluded automation last succeeded, and warn when it ne…
BelhsanHmida Nov 15, 2026
0cc05c1
Print what run-automations reconciled and released, not "No automatio…
BelhsanHmida Nov 15, 2026
20adbb9
Name the scopes to wait for by what they hold
BelhsanHmida Nov 15, 2026
3def80f
Say under a mixed allow-failure box what it stands for
BelhsanHmida Nov 15, 2026
fac46a8
Show what an automation waits for, and what waits for it, apart from …
BelhsanHmida Nov 15, 2026
e394c87
End a run on demand whose dispatch was abandoned, and what waits for it
BelhsanHmida Nov 15, 2026
aa97b29
Keep a job's recorded success when it fails afterwards, while releasi…
BelhsanHmida Nov 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions documentation/api/change_log.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ API change log
v3.0-35 | November xx, 2026
""""""""""""""""""""""""""""

**Automations**

- Renamed ``schedule-revision`` to ``revision`` in automation responses and in each run listed under ``run-stats``. The field counts the resets of an automation's recurrence, not anything about schedules; it was released under the old name in v3.0-34 (FlexMeasures v1.1.0), and is read-only, so only clients reading it need to switch.
- ``POST /api/v3_0/assets/<id>/automations`` and ``PATCH /api/v3_0/assets/<id>/automations/<automation-id>`` accept ``depends-on``, a list like ``[{"automation": 7, "allow-failure": false}]``, to have an automation's runs wait for the latest runs of other automations due at or before their own scheduled time, and automation responses report it, each upstream automation the caller may read coming with its ``name``, ``asset`` and ``asset-name``.
- ``POST /api/v3_0/assets/<id>/automations/<automation-id>/trigger`` accepts ``with-upstream=true``, to first run the active automations this one waits for, or ``with-downstream=true``, to also run the active automations that wait for this one, in chain order, and ``exclude`` to exclude some of them; the response lists the runs under ``runs`` and the automations that do not run under ``excluded``, each with the reason.
- Added ``GET /api/v3_0/assets/<id>/automations/<automation-id>/run-plan?include=upstream|downstream``, to see what running an automation along with what is upstream or downstream of it comes down to.
- Added ``GET /api/v3_0/assets/automations``, to list the automations on public assets (``scope=public``) or every automation the caller may read (``scope=all``), all at once, or one page at a time with ``page`` and ``per-page``.
- ``GET /api/v3_0/assets/<id>/automations/<automation-id>?include=waited-for-by`` reports ``waited-for-by``, the automations that wait for this one.

v3.0-34 | November 05, 2026
""""""""""""""""""""""""""""
Expand Down
1 change: 1 addition & 0 deletions documentation/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ v1.2.0 | December xx, 2026

New features
-------------
* An automation can wait for the automations whose results it uses: each of its runs waits for their latest runs due at or before its own scheduled time, also on another schedule, and is skipped if one of them failed, from the CLI (``--depends-on``), the API (``depends-on``) and the *Automations* page, and a chain can be re-run on demand from an automation (``--with-downstream``) or up to it (``--with-upstream``), which the *Automations* page also draws [see `PR #2706 <https://www.github.com/FlexMeasures/flexmeasures/pull/2706>`_]

Infrastructure / Support
-------------------------
Expand Down
9 changes: 9 additions & 0 deletions documentation/cli/change_log.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
FlexMeasures CLI Changelog
**************************

since v1.2.0 | December XX, 2026
=================================

**Automations**

* Add ``--depends-on`` and ``--allow-failure-of`` to ``flexmeasures add automation`` and ``flexmeasures edit automation`` (plus ``--no-dependencies`` on edit), to have an automation's runs wait for the latest runs of other automations due at or before their own scheduled time.
* Add ``--with-downstream`` to ``flexmeasures jobs run-automation``, to also run the automations that wait for it, each once the runs it waits for ended, for instance to re-run a chain after a backfill.
* Add ``--with-upstream`` to ``flexmeasures jobs run-automation``, to first run the automations it waits for, and ``--exclude`` to exclude one of them, along with what can only be reached through it.

since v1.1.0 | November 05, 2026
=================================

Expand Down
79 changes: 78 additions & 1 deletion documentation/features/automations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,81 @@ It runs every night at 1 AM, an hour after midnight, so that the day's last read

.. _running_automations:

.. _automation_dependencies:

Waiting for other automations
-----------------------------

Some automations use what another automation produces.
For example, a report that computes flows from a stock is only correct once another report has snapped the raw meter readings of that stock to a regular grid.
Rather than staggering their cron strings and hoping the first one finishes in time, let the second automation wait for the first:

.. code-block:: bash

flexmeasures add automation --asset 3 --name "Flows" --cron "*/5 * * * *" --timezone UTC \
--type reporting --reporter PandasReporter --config flows-config.yml --parameters flows-parameters.yml \
--depends-on 7

Each run of the waiting automation then waits for the latest run of automation 7 that is due at or before its own scheduled time.
It queues its jobs as soon as that run has ended successfully, and is *skipped* if it failed, so that it never computes on input that was never produced.
A skipped run says which upstream run it was skipped for, and anything waiting for a skipped run is skipped, too.
A job that gets killed cannot report how it ended, so the runner looks that up in Redis on each tick: its run counts as failed, rather than leaving what waits for it waiting forever.
To have a run go ahead even when the run it waits for failed, also pass ``--allow-failure-of 7``.

An automation can wait for several others (repeat ``--depends-on``), and these can be on any asset you can read.
They may recur on another schedule, as each run waits for the latest upstream run due at or before its own scheduled time, by the upstream automation's own cron string and timezone.
For instance, an hourly forecast that waits for meter data pulled every 15 minutes runs at 10:00 once the pull due at 10:00 ended.
The other way around, a forecast every 15 minutes that waits for an hourly pull runs at 10:15, 10:30 and 10:45 on the pull due at 10:00, so a failure of that one pull has all three of them skipped.
A dependency that would have an automation end up waiting for itself is refused.

Some cases where the upstream run does not happen:

- If the upstream automation missed that time while the runner was down, its missed runs were coalesced into the run it caught up with, so the waiting run waits for that one instead.
- If the upstream automation was never going to run at that time, because it is inactive, did not exist yet, or its recurrence was reset since (by reactivating it, or by giving it another cron string or timezone), the waiting run goes ahead without it. Its run record says so.
- If the upstream automation moved past that time without any run, the waiting run is skipped (unless failure is allowed for).

Deactivating an automation cancels its scheduled runs that are still waiting, rather than having them go ahead late once it is reactivated, and what waits for them goes ahead without them.

The API takes the same as ``depends-on``, a list like ``[{"automation": 7, "allow-failure": false}]``, and on the asset's *Automations* page the creation and edit forms let you pick the automations to wait for.
By default, you pick among those listed on the page, which are those on this asset and, if you include them, on the assets below it, and you can switch to this asset only, to public assets, or to every automation you can see.
The chain in an automation's details follows the same choice, and can show all of these automations rather than only those linked to this one.
Deleting an automation others wait for warns you first, as they then run without it.

When assets are copied along with their automations, a copy waits for the copy of the automation its original waited for, if that was copied too, and for the original one otherwise.

Runs always flow downstream, from the automations that are waited for to those that wait for them.
To re-run a whole chain, for instance once the data at its start was backfilled, run its first automation along with what is downstream of it:

.. code-block:: bash

flexmeasures jobs run-automation --automation 7 --with-downstream

Automation 7 runs right away, and each active automation that waits for it, directly or through others, gets a run that waits for the runs started along with it,
and is skipped if one of those failed, just like scheduled runs.
These runs on demand do not affect the automations' recurrence, and the runner does not retry them if their jobs failed to queue, as whoever started them is told.

To bring one automation up to date instead, run what is upstream of it first, and stop at this automation:

.. code-block:: bash

flexmeasures jobs run-automation --automation 9 --with-upstream

The automations it waits for, directly or through others, run first, and each run waits for the runs started along with it, as above.
What waits for automation 9 does not run.

Either way, the included automations run in chain order.
With several branches, all of them run, unless you exclude one with ``--exclude``.
An automation that does not run, because you excluded it, because it is inactive, or because you may not run it, such as one on a public asset, is excluded along with what can only be reached through it.
It still runs on its own schedule, just not because of this request, and what waits for it goes by the results it already has.
The API does the same with ``POST /api/v3_0/assets/<id>/automations/<automation-id>/trigger?with-upstream=true`` (or ``with-downstream=true``) and ``exclude``,
and ``GET /api/v3_0/assets/<id>/automations/<automation-id>/run-plan?include=upstream`` (or ``include=downstream``) tells what that would come down to.
On the *Automations* page, *Run up to here* and *Run from here* show this before anything runs.

The details of an automation on the *Automations* page draw the chain it is part of, among the automations listed there:
what it waits for on the left, what waits for it on the right, and a dashed arrow where the waiting automation runs even when the one it waits for failed.
Hovering over an automation there tells its type, asset and recurrence, hovering over an arrow tells what a failure does, and clicking an automation opens its details, on the page of its own asset.
An automation that is not listed there, but that you may read, is named and can be clicked as well.

Running automations
-------------------

Expand Down Expand Up @@ -280,7 +355,8 @@ a report run its reporting job, and a plugin run the job its plugin queued.
A run which queued no jobs, such as a report run with nothing new to report on, has succeeded.
A job which a schedule queues to fall back on a simpler scheduler is not one of the run's jobs, so a run whose schedule fell back has failed, with the error that made it fall back.

A run tracks two things separately: how far its *dispatch* got (``pending``, ``claimed``, ``partially_queued``, ``queued`` or ``failed``), and how its *execution* by the workers ended (``pending``, ``running``, ``succeeded``, ``failed`` or ``canceled``).
A run tracks two things separately: how far its *dispatch* got (``pending``, ``claimed``, ``waiting``, ``partially_queued``, ``queued`` or ``failed``), and how its *execution* by the workers ended (``pending``, ``running``, ``succeeded``, ``failed``, ``canceled`` or ``skipped``).
A run is ``waiting`` while the runs it depends on have not ended yet, and ``skipped`` if one of them failed (see :ref:`automation_dependencies`).
Each attempt to dispatch a run is recorded too, with the runner which made it, what it queued, and why it failed if it did.
This is what an operator needs to tell a run which failed before queueing anything, one which queued half its work, and one which queued everything but then failed while computing, apart from each other.

Expand Down Expand Up @@ -309,6 +385,7 @@ That menu also lets you edit, copy, deactivate (or activate) and delete the auto
The automation runs with the parameters it was created with, and the jobs it queues are recorded as its jobs, just like the jobs of a recurring run.
An on-demand run does not affect the automation's recurrence: its cursor (see :ref:`automation_cursor`) stays where it was, so the next recurring run still happens as scheduled, and a run missed while the runner was down is still caught up.
Inactive automations can be run this way, too, which is how you can try one out before activating it.
An on-demand run does not wait for the automations this one depends on, as it is meant to run now.

Unlike a recurring run, an on-demand run is not protected against being started twice: asking for two runs in a row queues two runs.

Expand Down
Loading
Loading