Skip to content
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

Merged
merged 2 commits into from May 13, 2024

Conversation

thy09
Copy link
Contributor

@thy09 thy09 commented May 9, 2024

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 and src/promptflow-core/promptflow/executor/flow_executor.py files to handle line execution timeouts. The Optional type has been imported and a timeout_seconds parameter has been added to the execute 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. A cancel_tasks method has also been added to cancel tasks and yield control to the event loop for cleanup. The LineExecutionTimeoutError exception is raised when a timeout occurs.

Changes to handle line execution timeouts:

All Promptflow Contribution checklist:

  • The pull request does not introduce [breaking changes].
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request to get dedicated review from promptflow team. Learn more: suggested workflow.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Copy link

github-actions bot commented May 9, 2024

promptflow SDK CLI Azure E2E Test Result heta/add-timeout-handling-for-async

  4 files    4 suites   4m 11s ⏱️
242 tests 205 ✅  37 💤 0 ❌
968 runs  820 ✅ 148 💤 0 ❌

Results for commit e6e8477.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented May 9, 2024

promptflow-core test result

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit e6e8477.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented May 9, 2024

SDK CLI Global Config Test Result heta/add-timeout-handling-for-async

6 tests   6 ✅  1m 14s ⏱️
1 suites  0 💤
1 files    0 ❌

Results for commit e6e8477.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented May 9, 2024

Executor Unit Test Result heta/add-timeout-handling-for-async

796 tests   796 ✅  3m 45s ⏱️
  1 suites    0 💤
  1 files      0 ❌

Results for commit e6e8477.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented May 9, 2024

Executor E2E Test Result heta/add-timeout-handling-for-async

243 tests   238 ✅  5m 34s ⏱️
  1 suites    5 💤
  1 files      0 ❌

Results for commit e6e8477.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented May 9, 2024

SDK CLI Test Result heta/add-timeout-handling-for-async

    4 files      4 suites   1h 3m 1s ⏱️
  715 tests   674 ✅  41 💤 0 ❌
2 860 runs  2 696 ✅ 164 💤 0 ❌

Results for commit e6e8477.

♻️ This comment has been updated with latest results.

@thy09 thy09 force-pushed the heta/add-timeout-handling-for-async branch from 309be82 to 3b78c1f Compare May 10, 2024 10:05
@thy09 thy09 merged commit 4489ca7 into main May 13, 2024
51 checks passed
@thy09 thy09 deleted the heta/add-timeout-handling-for-async branch May 13, 2024 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants