Colton
05/08/2024, 5:26 PMMarvin
05/08/2024, 5:26 PMprefect.yaml
. These triggers can be configured to respond to different events, such as the successful completion of a different deployment. When specifying a trigger, you need to define the conditions that must be met for the trigger to activate and cause the linked deployment to run.
Below is an example snippet from a prefect.yaml
using deployment triggers:
yaml
deployments:
- name: dependent-deployment
entrypoint: path/to/dependent_flow.py:decorated_function
work_pool:
name: my-process-pool
triggers:
- enabled: true
match:
prefect.resource.id: id_of_successful_deployment
expect:
- "desired.success.event"
The match
attribute should contain identifiers that allow Prefect to link the trigger to the original event, like the successful completion of another deployment. The expect
list should contain the specific events you are interested in, such as successful flow run completion events.
Additionally, you can pass triggers to the Prefect CLI using the --trigger
argument during a prefect deploy
command. This argument accepts a JSON string or a path to a .yaml
or .json
file containing the trigger configuration:
shell
# Pass a trigger as a JSON string
prefect deploy -n dependent-deployment --trigger <TRIGGER_JSON_CONFIG>
For more guidance on automations and triggers in Prefect, you can check out the Automations documentation.
Please note you will need to adjust the trigger definitions according to your specific use case and the events you would like to monitor.Nate
05/08/2024, 5:31 PMmatch
on prefect.resource.name
instead of prefect.resource.id
just because I sometimes recreate my deployments, and so the id
would change