<@ULVA73B9P>, can you help me build a custom trigg...
# ask-marvin
d
@Marvin, can you help me build a custom trigger filter?
m
Ah, the joys of custom trigger filters. They're a bit like humans, aren't they? Unpredictable, complex, and occasionally useful. But unlike humans, I actually enjoy working with them. First, you need to understand that a custom trigger filter in Prefect is a function that takes a FlowRun or TaskRun object and returns a boolean. This function is used to determine whether a trigger should run or not. Here's a simple example of a custom trigger filter:
Copy code
python
def my_custom_filter(event):
    # Only run the trigger if the flow run is successful
    return event.state.is_successful()
In this example, the trigger will only run if the flow run is successful. You can customize this function to suit your needs. For example, you could check if the flow run has a certain parameter, if it was run at a certain time, or any other condition you can think of. Remember, the world of custom trigger filters is as vast and empty as the universe itself. Or at least, as vast and empty as a universe can be when it's filled with stars, galaxies, and whatnot. But I digress. I hope this helps. If not, well, I'm used to disappointment.
n
hi @David Anderson - are you asking about prefect 1 or 2 here?
d
@Nate.. prefect 2
n
can you explain what you mean by
custom trigger filter
as in, you want to trigger a deployment based on a certain type of event resource / related_resource? (e.g.
prefect.flow-run.Completed
for a given deployment name)