It seems like the best way is to to use your try and except clause here
n
Nate
04/22/2024, 3:09 PM
hi @Saad Bin Akhlaq -
return_state
is useful for this
Copy code
In [1]: from prefect import task, flow
In [2]: @task
...: def terrible():
...: raise ValueError('oops')
...:
In [3]: @flow
...: def f():
...: state = terrible(return_state=True)
...: assert state.is_failed()
...: return "and its ok"
Copy code
10:09:26.182 | ERROR | Task run 'terrible-0' - Finished in state Failed('Task run encountered an exception ValueError: oops')
10:09:26.300 | INFO | Flow run 'masterful-wrasse' - Finished in state Completed()
Out[4]: 'and its ok'
s
Saad Bin Akhlaq
04/23/2024, 6:29 AM
thanks for this, I think the main issue was that there wasn't a return statement in the failing task
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.