<#3125 Bug when calling wf in eager task with thre...
# flyte-github
c
#3125 Bug when calling wf in eager task with thread Pull request opened by wild-endeavor Why are the changes needed? Unable to run subworkflows, as part of eager workflows, via to_thread. This PR only fixes the ability to run subworkflows on the backend. Local execution still needs additional fixes. What changes were proposed in this pull request? • A return was missing from the call handler, leading to local runs of subworkflows locally run by eager to run multiple things. • The compile step has been taken out of the workflow call handler. • In local testing found that the behavior of the reconcile function in the worker doesn't handle the re-run case where the execution is already found. The reconcile function now will always just sync the execution, and then handle state management appropriately. • Additional terminal states are mapped to failed in the update object. • asserts were hard to debug - these have been changed to explicit assertion errors. The issues encountered while debugging this... • Local execute in my test case (not included) was only succeeding maybe 1 out of every 6-7 times. • The compile step that was moved into the conditional was causing failures all the time. My running theory for this is because the context manager is not thread safe. Need to investigate further how to_thread's contextvar copy works. Context copying is needed because we need to accurately represent the state upon entering the thread, but removing the context frames seems to be polluting each other's context. How was this patch tested? Tested locally and on Union internal clusters. Setup process Screenshots Check all the applicable boxes • I updated the documentation accordingly. • All new and existing tests passed. • All commits are signed-off. Related PRs Docs link Summary by Bito This PR enhances subworkflow execution in eager workflows via to_thread by implementing improved error handling, state management, and thread safety. Key changes include fixing missing return statements in async calls, improving error messages for worker queue assertions, and enhancing context manager thread safety. The implementation removes unused abort metadata and includes documentation improvements along with comprehensive test additions for workflow execution phases. Unit tests added: True Estimated effort to review (1-5, lower is better): 2 flyteorg/flytekit