-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: 工作流增加执行超时 #1476
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
feat: 工作流增加执行超时 #1476
Conversation
工作流超时功能的类图classDiagram
class WorkflowConfig {
+int max_execution_time
}
note for WorkflowConfig "新的配置类"
class Workflow {
+string name
+List~Block~ blocks
+List~Wire~ wires
+string id
+WorkflowConfig config
+__init__(name, blocks, wires, id, config)
}
note for Workflow "添加了 config 属性"
class WorkflowBuilder {
+string name
+string description
+List~Node~ nodes
+WorkflowConfig config
+build(container) Workflow
+set_config(config) WorkflowBuilder
+save_to_yaml(file_path, container)
+load_from_yaml(file_path, container) WorkflowBuilder
}
note for WorkflowBuilder "添加了 config 属性和相关方法"
class WorkflowExecutor {
+Workflow workflow
+run() Dict~str, Any~
-_execute_nodes(entry_blocks, executor, loop)
}
note for WorkflowExecutor "run() 方法已更新以处理超时"
class WorkflowDefinition {
+string name
+string description
+List~BlockInstance~ blocks
+List~Wire~ wires
+WorkflowConfig config
+Dict~str, Any~ metadata
}
note for WorkflowDefinition "添加了 config 属性 (API 模型)"
class WorkflowExecutionTimeoutException {
<<Exception>>
}
note for WorkflowExecutionTimeoutException "用于超时的新异常"
Workflow --o WorkflowConfig : has a
WorkflowBuilder --o WorkflowConfig : has a
WorkflowExecutor ..> Workflow : uses
WorkflowExecutor ..> WorkflowExecutionTimeoutException : raises
WorkflowDefinition --o WorkflowConfig : has a
文件级别更改
提示和命令与 Sourcery 互动
自定义您的体验访问您的 仪表板 以:
获取帮助Original review guide in EnglishReviewer's GuideThis pull request introduces a workflow execution timeout feature. It adds a Sequence diagram for WorkflowExecutor Timeout HandlingsequenceDiagram
participant WE as WorkflowExecutor
participant asyncio
participant Nodes as _execute_nodes
WE->>WE: run()
WE->>WE: Get max_timeout = workflow.config.max_execution_time
alt max_timeout > 0
WE->>asyncio: timeout(max_timeout)
activate asyncio
WE->>Nodes: _execute_nodes(...)
alt Execution exceeds timeout
asyncio-->>WE: raises TimeoutError
WE->>WE: Catch TimeoutError
WE-->>WE: raise WorkflowExecutionTimeoutException
else Execution completes within timeout
Nodes-->>WE: Return results
WE-->>asyncio: Execution finished
deactivate asyncio
end
else max_timeout <= 0
WE->>Nodes: _execute_nodes(...)
Nodes-->>WE: Return results
end
WE->>WE: Post WorkflowExecutionEnd event
WE->>WE: Return results or raise exception
Class diagram for Workflow Timeout FeatureclassDiagram
class WorkflowConfig {
+int max_execution_time
}
note for WorkflowConfig "New configuration class"
class Workflow {
+string name
+List~Block~ blocks
+List~Wire~ wires
+string id
+WorkflowConfig config
+__init__(name, blocks, wires, id, config)
}
note for Workflow "Added config attribute"
class WorkflowBuilder {
+string name
+string description
+List~Node~ nodes
+WorkflowConfig config
+build(container) Workflow
+set_config(config) WorkflowBuilder
+save_to_yaml(file_path, container)
+load_from_yaml(file_path, container) WorkflowBuilder
}
note for WorkflowBuilder "Added config attribute and related methods"
class WorkflowExecutor {
+Workflow workflow
+run() Dict~str, Any~
-_execute_nodes(entry_blocks, executor, loop)
}
note for WorkflowExecutor "run() method updated to handle timeout"
class WorkflowDefinition {
+string name
+string description
+List~BlockInstance~ blocks
+List~Wire~ wires
+WorkflowConfig config
+Dict~str, Any~ metadata
}
note for WorkflowDefinition "Added config attribute (API Model)"
class WorkflowExecutionTimeoutException {
<<Exception>>
}
note for WorkflowExecutionTimeoutException "New exception for timeout"
Workflow --o WorkflowConfig : has a
WorkflowBuilder --o WorkflowConfig : has a
WorkflowExecutor ..> Workflow : uses
WorkflowExecutor ..> WorkflowExecutionTimeoutException : raises
WorkflowDefinition --o WorkflowConfig : has a
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
MyPy 类型检查通过 ✅PR 修改的代码行通过了类型检查。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嘿 @lss233 - 我已经审查了你的更改,它们看起来很棒!
以下是我在审查期间查看的内容
- 🟡 一般问题:发现 1 个问题
- 🟢 安全性:一切看起来都很好
- 🟢 测试:一切看起来都很好
- 🟢 复杂性:一切看起来都很好
- 🟢 文档:一切看起来都很好
帮助我变得更有用!请点击每个评论上的 👍 或 👎,我将使用反馈来改进你的评论。
Original comment in English
Hey @lss233 - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
|
||
| if max_timeout > 0: | ||
| try: | ||
| async with asyncio.timeout(max_timeout): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
问题 (bug_risk): 审查执行块中 asyncio.timeout 的使用。
验证在 _execute_nodes 周围使用 asyncio.timeout 是否会将未完成的子任务留在不一致的状态,以及是否在超时时运行所需的清理。
Original comment in English
question (bug_risk): Review the use of asyncio.timeout in the execution block.
Verify that using asyncio.timeout around _execute_nodes doesn’t leave incomplete subtasks in an inconsistent state, and that required cleanup runs on timeout.
- Introduced WorkflowConfig to manage execution settings, including max execution time. - Updated Workflow and WorkflowBuilder to incorporate configuration management. - Enhanced WorkflowExecutor to handle execution timeouts and log errors appropriately. - Modified API routes to support configuration in workflow definitions and updates.
ef9e8fb to
20e5707
Compare
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## master #1476 +/- ##
==========================================
+ Coverage 65.84% 65.88% +0.03%
==========================================
Files 161 161
Lines 8148 8175 +27
==========================================
+ Hits 5365 5386 +21
- Misses 2783 2789 +6 ☔ View full report in Codecov by Sentry. |
好的,这是将拉取请求摘要翻译成中文的结果:
Sourcery 总结
添加工作流执行超时配置,以管理和限制工作流执行时间
新特性:
Bug 修复:
增强功能:
Original summary in English
Summary by Sourcery
Add workflow execution timeout configuration to manage and limit workflow execution time
New Features:
Bug Fixes:
Enhancements: