Repository navigation
Open
Description
FlexMeasures#2706 (open, not yet milestoned) lets an automation wait for the automations whose results it uses, and adds endpoints to run or inspect a whole chain.
Once it is merged, the client should cover it, building on the automation methods of #230.
This was left out of scope in #228.
Server changes (API v3.0-35, per #2706's API changelog)
POST /assets/<id>/automationsandPATCH /assets/<id>/automations/<automation-id>acceptdepends-on, a list like[{"automation": 7, "allow-failure": false}]. Responses report it, each upstream automation the caller may read coming with itsname,assetandasset-name.GET /assets/<id>/automations/<automation-id>reportswaited-for-by.POST /assets/<id>/automations/<automation-id>/triggeracceptswith-dependents=true, orwith-ascendants=truewith an optionalleave-outlist of automation IDs (not both).
With dependents, the response addsdependent-runs.
With ascendants, it has nojob, butruns(each withautomation,runanddispatch-state) andleft-out.- New
GET /assets/<id>/automations/<automation-id>/run-plan?direction=ascendants|dependents, which lists the steps a chain run would take, without running anything. - New
GET /assets/automations?scope=public|all, which lists automations across assets (500 at most).
Plan
-
add_automation(..., depends_on=None): senddepends-ononly when given. Accept the API's list of dicts as is, so new keys need no client release. -
update_automation(asset_id, automation_id, depends_on=[...])already works, as keyword arguments are passed on in kebab-case (Add automation methods #230). Document it, with an example, and add a test. -
trigger_automation(..., with_dependents=False, with_ascendants=False, leave_out=None): send the query parameters only when set, and refuse both flags together before sending anything.
Its check that the response has ajobmust not apply with ascendants, where the response has none. -
trigger_and_await_automation: with ascendants or dependents there is no single job to wait for, so either refuse those flags here, or wait for the runs some other way. To be decided. #2706 tracks runs, not jobs, so this may need a way to look up a run's state. -
get_automation_run_plan(asset_id, automation_id, direction)→ thestepslist. -
get_automations_in_scope(scope="all")(name to be decided) forGET /assets/automations. - Version gating: as in Add automation methods #230, on a 404, say which server version is needed. Use the FlexMeasures release that ships #2706, once it is known. For the new trigger parameters and
depends-onthere is no 404, so check the version withserver_version_at_leastbefore sending them, and raiseInsufficientServerVersionErroron an older server, rather than letting it reject an unknown field. - Tests with
aioresponses, and an end-to-end run against a local server on #2706's branch, covering a two-automation chain triggered with ascendants and with dependents. - Docs: a "Chaining automations" section in
docs/automations.rst, plus a changelog entry.
Also: a naming mismatch to fix along the way
In add_automation, the automation_type argument becomes the API's type.
In update_automation, the same name passed as a keyword is sent as automation-type, which the server refuses as an unknown field.
That is harmless while the type cannot be changed, but confusing.
Either map automation_type to type in update_automation, too, or say in its docstring that keyword names are the API's field names in snake_case.
Metadata
Metadata
Assignees
Labels
No labels
Activity