<@ULVA73B9P> how do i configure a deployment to ru...
# ask-marvin
c
@Marvin how do i configure a deployment to run every time after a separate deployment successfully completes?
m
To configure a deployment to run every time after a separate deployment successfully completes, you will need to use Prefect's deployment triggers, specifically designed for creating automations linked to specific deployments that are executed based on the presence or absence of events. Here's how you can do it: You need to define triggers in the deployment configuration block within your
prefect.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:
Copy code
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:
Copy code
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.
n
plus1 except I might want to
match
on
prefect.resource.name
instead of
prefect.resource.id
just because I sometimes recreate my deployments, and so the
id
would change