Alberto de Santos
10/17/2020, 2:02 PMAlberto de Santos
10/17/2020, 8:08 PMmap
done in Prefect, is triggers/signals something I can use so that, regardless they fail or not, I can handle them properly, so that the task ends SUCCESSFULY?map
nicholas
import prefect
from prefect import Flow, task
@task
def return_list():
return [1, 2, 3, 4]
@task
def parse_value(val):
if val % 2 != 0:
raise ValueError("Value is not even!")
return val
@task(trigger=prefect.triggers.any_failed)
def catch_error(val):
print(f"Do something with this value error: {val}")
with Flow("Raise error on Odd") as flow:
my_list = return_list()
def_list = parse_value.map(my_list)
catch_error.map(def_list)
flow.run()
catch_error
will run twice with the value of the error