Gary
12/11/2024, 2:24 AMMarvin
12/11/2024, 2:25 AMraise_on_failure=False
), the main flow will continue executing remaining subflows.
4. ControlFlow and Custom Termination Conditions: ControlFlow, an agentic framework built on top of Prefect, allows for more complex control logic, including custom termination conditions and the use of the run_until
parameter for greater flexibility.
For deeper insights, check out the Prefect 3.x documentation on flow orchestration and retry behavior and explore the ControlFlow patterns for running tasks.
Remember, it’s always good to specify how resilient each part of your pipeline needs to be and how errors should be mitigated to ensure smooth flow execution.Nate
12/11/2024, 3:02 AMreturn_state=True
to return the state object that you can use to decide to raise the exception or notNate
12/11/2024, 3:04 AMNate
12/11/2024, 3:07 AMIn [1]: from prefect import flow
In [2]: @flow
...: def f():
...: raise ValueError("I failed!")
...:
In [3]: state = f(return_state=True)
21:06:23.143 | INFO | prefect.engine - Created flow run 'laughing-python' for flow 'f'
....
raise ValueError("I failed!")
ValueError: I failed!
21:06:23.208 | ERROR | Flow run 'laughing-python' - Finished in state Failed('Flow run encountered an exception: ValueError: I failed!')
In [4]: if state.is_completed():
...: print('not gonna happen')
...: elif state.is_failed():
...: print('its ok')
...:
its ok
Gary
12/15/2024, 2:47 PMNate
12/15/2024, 4:27 PM