prefect icon indicating copy to clipboard operation
prefect copied to clipboard

Document which template context variables are available for automation actions

Open chrisguidry opened this issue 1 year ago • 1 comments

Our current documentation for Jinja templating in automation actions only mentions the dynamic context variables (like flow_run, work_pool, etc), but these variables are shortcuts to pull objects from the API and can be problematic due to the timing gaps between the original event and when the action runs (like if the flow run has changed states since the automation was triggered, etc).

https://docs-3.prefect.io/3.0rc/react/understand-events/automations-triggers#templating-with-jinja

We should start with the standard variables:

{
    "automation": triggered_action.automation,
    "event": triggered_action.triggering_event,
    "labels": LabelDiver(triggered_action.triggering_labels),
    "firing": triggered_action.firing,
    "firings": triggered_action.all_firings(),
    "events": triggered_action.all_events(),
}

And discuss them in detail, and then we can talk about the shortcuts like flow_run and the tradeoffs of using them.

chrisguidry avatar Jun 14 '24 15:06 chrisguidry

Documenting the jinja filters available as part of this would also be quite useful!

rcash avatar May 30 '25 16:05 rcash