https://prefect.io logo
Title
s

sjammula

05/15/2023, 3:24 PM
@prefect Would like to know in prefect2
signals
is changed to which supported format?I need to raise exceptions failed states.Please do provide the needful info
1
r

Rob Freedy

05/15/2023, 7:53 PM
Hey @sjammula!! You can raise a manual state in Prefect2 (see docs here)
s

sjammula

05/16/2023, 1:56 PM
@Rob Freedy we are looking at task level not at flowcode level,can you share some insights
r

Rob Freedy

05/16/2023, 1:59 PM
you can return a manual state or an exception from the task level as well (see here)
s

sjammula

05/16/2023, 5:11 PM
@Rob Freedy Thanks for sharing the info I'm trying to raise exception in my task level with the following lines of code in my else block but I want to know if any prefect inbuilt exceptions can be handled using any library or methods
sys.tracebacklimit = 0
raise Exception("Job run didn't succeed, status = {}".format(status))
@Rob Freedy any update
r

Rob Freedy

05/16/2023, 7:43 PM
What kind of Exception are you looking to throw? You should be able to
raise Exception()
like you are doing in the code block from anywhere in the task. Could you try returning a future that fails on raising of an exception?
always_fails_task.submit().result(raise_on_failure=False)
s

sjammula

05/16/2023, 8:30 PM
sure @Rob Freedy will try and let you know.
👍 1
I'm trying to write if else conditions which directly returns true false statements in task level function so that I can call the function directly in the flow code