December 14, 2022, 6:20pm
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
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?
Triggers have been released in beta just yesterday
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:
why less flexible? can you share an example showing what you are trying to accomplish?
December 14, 2022, 7:23pm
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
December 14, 2022, 7:27pm
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?
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:
I wrote this example for you to show how you can execute that cleanup task even when something fails:
The easiest way to accomplish that is to leverage the allow_failure utility.
Here is a simple flow example that demonstrates how you can use it:
from prefect import task, flow, get_run_logger, allow_failure
def transform_data(x: int, y: int = 2) -> int:
if random.random() > 0.5:
raise ValueError("Non-deterministic error has occured.")
return (x + 42) * y
December 15, 2022, 12:23am
Thanks for that example! That’s really helpful