Alexis Chicoine
08/23/2023, 3:41 PMtriggers:
- enabled: true
match:
prefect.resource.id: my.external.resource
expect:
- external.resource.pinged
parameters:
param_1: "{{ event }}"
When applied, this will create a linked automation that responds to events from an external resource, and passes that event into the parameters of the executed flow run.Marvin
08/23/2023, 3:41 PMpython
from prefect import Flow
from prefect.engine.state import State
from prefect.triggers import all_successful
def your_flow_function():
# Your flow logic here
flow = Flow('Your Flow', your_flow_function)
# Define your trigger
def your_trigger_fn(flow_states: dict) -> bool:
# Your trigger logic here
# For example, return True if all flow states are successful
return all(state.is_successful() for state in flow_states.values())
flow.trigger_fn = your_trigger_fn
In this example, your_trigger_fn
is a function that takes a dictionary of flow states and returns a boolean. This function is used as the trigger for the flow. When the trigger function returns True
, the flow will run.
Remember, this is just a basic example. The actual implementation will depend on your specific use case and the events you want to respond to.
And remember, automations are like a box of chocolates. You never know what you're going to get...except it's usually an error message.Nate
08/23/2023, 3:42 PM