jpuris
02/28/2023, 6:39 PMif not is_success:
logger.error(error_msg)
return Failed(message="I've failed because ...!")
19:31:34.931 | ERROR | Flow run 'sociable-mantis' - Traceback (most recent call last):
... actually relevant stack trace from "error_msg" ...
19:31:35.161 | ERROR | Flow run 'sociable-mantis' - Finished in state Failed('I've failed because ...!')
Traceback (most recent call last):
<... a massive stack trace on raising a failure from prefect :(>
raise await get_state_exception(state)
prefect.exceptions.FailedRun: I've failed because ...!
The last stack trace is really unnecessary. I'd only want to output information that the flow has ended in failure state 😞Nate
02/28/2023, 6:55 PMreturn_state=True
when calling your flow that returns Failed
In [8]: @flow
...: def testing():
...: return Failed(message="i dont want a stack trace")
...:
In [9]: testing(return_state=True)
10:54:21.538 | INFO | prefect.engine - Created flow run 'pristine-cuttlefish' for flow 'testing'
10:54:23.156 | ERROR | Flow run 'pristine-cuttlefish' - Finished in state Failed('i dont want a stack trace')
Out[9]: Failed(message='i dont want a stack trace', type=FAILED, result=LiteralResult(type='literal', artifact_type='result', artifact_description='Literal: `None`', value=None))
jpuris
02/28/2023, 6:57 PMjpuris
02/28/2023, 7:08 PM