What is the Prefect 2.0 equivalent to triggers from Prefect 1.0?

Generally, is there an equivalent in Prefect 2.0 of Prefect 1.0 triggers?

In particular, here’s my use case: What is the prefect 2 equivalent to

from prefect.triggers import all_finished

@task(trigger=all_finished)
def always_run():
    print("Running regardless of upstream task's state")

from prefect 1?

This thread suggests that it’s using .submit() on the task that you want to always run regardless of upstream task failures? If so, that seems less flexible than prefect 1 triggers; but maybe I’m missing something?

1 Like

Triggers have been released in beta just yesterday :tada: check the docs here:

the triggers you mentioned though are no longer needed in Prefect 2 because you can configure all that in just Python, check out:

https://discourse.prefect.io/docs?tags=migration-guide%7Ctriggers

1 Like

why less flexible? can you share an example showing what you are trying to accomplish?

Sorry, instead of less flexible i should have said less clear/easy. It would be nice to be able to just pass a parameter to the @task decorator as in prefect 1

I don’t see automations/triggers available in the prefect python client. However, I do see automations are in the REST API. Are they coming to the python client?

I don’t see an example of having a task always run regardless of upstream tasks. Can you show me an example?

The trigger functionality is part of Automations, which is a Cloud-only feature, that’s why you won’t find it in the Python client. You can sign up for a free tier (no time limits) here:

https://app.prefect.cloud/

I wrote this example for you to show how you can execute that cleanup task even when something fails:

Thanks for that example! That’s really helpful

1 Like