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
[Executor] Add timeout task to async scheduler to achieve timeout feature. #3176
Conversation
promptflow SDK CLI Azure E2E Test Result heta/add-timeout-handling-for-async 4 files 4 suites 4m 11s ⏱️ Results for commit e6e8477. ♻️ This comment has been updated with latest results. |
promptflow-core test result0 tests 0 ✅ 0s ⏱️ Results for commit e6e8477. ♻️ This comment has been updated with latest results. |
SDK CLI Global Config Test Result heta/add-timeout-handling-for-async6 tests 6 ✅ 1m 14s ⏱️ Results for commit e6e8477. ♻️ This comment has been updated with latest results. |
Executor Unit Test Result heta/add-timeout-handling-for-async796 tests 796 ✅ 3m 45s ⏱️ Results for commit e6e8477. ♻️ This comment has been updated with latest results. |
Executor E2E Test Result heta/add-timeout-handling-for-async243 tests 238 ✅ 5m 34s ⏱️ Results for commit e6e8477. ♻️ This comment has been updated with latest results. |
SDK CLI Test Result heta/add-timeout-handling-for-async 4 files 4 suites 1h 3m 1s ⏱️ Results for commit e6e8477. ♻️ This comment has been updated with latest results. |
309be82
to
3b78c1f
Compare
Description
Improve the timeout handling of async scheduler.
Before:
The async nodes would be keep running until the process is killed.
After:
The async function would got an asyncio.CanceledError, then the line raises LineExecutionTimeoutError.
This pull request introduces changes in the
src/promptflow-core/promptflow/executor/_async_nodes_scheduler.py
andsrc/promptflow-core/promptflow/executor/flow_executor.py
files to handle line execution timeouts. TheOptional
type has been imported and atimeout_seconds
parameter has been added to theexecute
and_execute_with_thread_pool
methods. A timeout mechanism has been implemented in_execute_with_thread_pool
to cancel tasks that exceed the specified timeout. Acancel_tasks
method has also been added to cancel tasks and yield control to the event loop for cleanup. TheLineExecutionTimeoutError
exception is raised when a timeout occurs.Changes to handle line execution timeouts:
src/promptflow-core/promptflow/executor/_async_nodes_scheduler.py
: ImportedOptional
type and addedtimeout_seconds
parameter toexecute
and_execute_with_thread_pool
methods. Implemented timeout mechanism in_execute_with_thread_pool
and addedcancel_tasks
method to cancel tasks and yield control to the event loop for cleanup. RaisedLineExecutionTimeoutError
when timeout occurs. [1] [2] [3] [4] [5] [6]src/promptflow-core/promptflow/executor/flow_executor.py
: Passedself._line_timeout_sec
astimeout_seconds
toscheduler.execute
method.All Promptflow Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines