-
Notifications
You must be signed in to change notification settings - Fork 674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SubWorkflow Error handling #5513
Comments
To handle sub-workflow errors gracefully in Flyte, you can use the Here is an example of how you can define a parent workflow with error handling for sub-workflows: from flytekit import task, workflow, WorkflowFailurePolicy
@task
def my_error_handler(error: Exception):
# Handle the error, e.g., log it or clean up resources
print(f"Error encountered: {error}")
@workflow(on_failure=my_error_handler)
def my_sub_wf():
# Sub-workflow logic
...
@workflow(failure_policy=WorkflowFailurePolicy.FAIL_AFTER_EXECUTABLE_NODES_COMPLETE)
def my_parent_wf() -> str:
n1 = my_sub_wf()
n2 = my_sub_wf()
n3 = my_sub_wf()
return n3.out1 In this example, Would you like more details on this or other potential solutions? Sources: This is an AI-generated response and your feedback is appreciated! Please leave a 👍 if this is helpful and 👎 if it is not. Mention @RunLLM to ask follow-up questions. See runllm.com for more! |
Here, the parent workflow will fail if any of the sub-workflows fails. What we need is to be able to decide on what happens, similar to what you can do with |
Flyte has support for Failure nodes, which lets workflows define special nodes to be executed in case the workflow fails. Unfortunately this doesn't cover your use case as failure nodes don't resume the execution after the failure, they only give you an opportunity to run a task. |
@eapolinario, is there any way this can get implemented? Or are there any suggested workarounds that we can proceed with? Without this feature, I guess the only way to have recoverable failures in sub-workflows is to wrap every task in try/catch blocks and essentially implement the error handling on our end? |
Have you tried @eager? |
@eapolinario what they want is success on failure, that is allow to catch the error and succeed. @kdubovikov can you write an example of how you want it - we can help till then. Also @eager is the best way to make things work with arbitrary code |
@kumare3 is this example by @nihar-pixis not sufficient in any way? What do you need in addition? |
Code example of the developer experience? |
@kumare3 below are some dev-exp examples
|
@kumare3 hi. Could we get any feedback on this suggestion? |
Motivation: Why do you think this is important?
We are creating an orchestration workflow that governs a dynamic number of model sub-workflows that are being developed by different team members. Those workflows can fail unexpectedly and we need to handle those failures gracefully in the orchestration workflow so that it still can complete successfully, as some of the sub-workflows are ok to fail, while others can be an irrecoverable failure.
Goal: What should the final outcome look like, ideally?
Something like try-catch block for the workflow-level error handling, or an on-failure decorator that can accept rich information about the workflow-level error trace
Describe alternatives you've considered
We have considered using explicit error handling in our code and logging errors in the DB, but it seems incorrect when using workflow engine, as it's the workflow's responsibility to handle and process sub-workflow or task-level exceptions that leaks into the application logic if we will implement it this way.
Propose: Link/Inline OR Additional context
No response
Are you sure this issue hasn't been raised already?
Have you read the Code of Conduct?
The text was updated successfully, but these errors were encountered: