This message was deleted.
s
This message was deleted.
m
thought for 115.9 seconds
Yes — for downstream deployment parameters, you can template values from the upstream flow run that triggered the automation. But the syntax is not
{{{ event.flow-run.name }}}
. Use Jinja against the objects Prefect injects into the automation template context, especially: -
flow_run
-
flow
-
deployment
-
event
So for your example, use:
Copy code
jinja2
{{ flow_run.name }}
not:
Copy code
jinja2
{{ event.flow-run.name }}
Example
Copy code
python
from datetime import timedelta
from prefect.automations import Automation, EventTrigger, Posture, RunDeployment

automation = Automation(
    name="trigger downstream with upstream params",
    trigger=EventTrigger(
        expect={"prefect.flow-run.Completed"},
        posture=Posture.Reactive,
        threshold=1,
        within=timedelta(0),
    ),
    actions=[
        RunDeployment(
            source="selected",
            deployment_id="<downstream-deployment-id>",
            parameters={
                "upstream_run_name": {
                    "__prefect_kind": "jinja",
                    "template": "{{ flow_run.name }}",
                },
                "upstream_run_id": {
                    "__prefect_kind": "jinja",
                    "template": "{{ flow_run.id | string }}",
                },
                "original_param": {
                    "__prefect_kind": "jinja",
                    "template": "{{ flow_run.parameters['my_param'] }}",
                },
            },
        )
    ],
)

automation.create()
A few useful notes: -
flow_run.parameters[...]
lets you pass upstream flow parameters through -
flow_run.state.name
/
flow_run.state.type
are also available -
flow.name
gives the upstream flow name -
event
is available too, but it’s the raw event object, not a nested
event.flow-run.*
structure Important limitation: this templating support applies to
parameters
for
RunDeployment
. It does not apply the same way to
job_variables
. Helpful docs: - Automations concepts - Access parameters in templates If you want, I can also show: - how to do this in the UI automation editor, or - how to pass the entire upstream flow run metadata as a single downstream parameter.