celestialflow 3.1.1__tar.gz → 3.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. {celestialflow-3.1.1 → celestialflow-3.1.2}/PKG-INFO +43 -14
  2. {celestialflow-3.1.1 → celestialflow-3.1.2}/README.md +42 -13
  3. {celestialflow-3.1.1 → celestialflow-3.1.2}/pyproject.toml +8 -3
  4. {celestialflow-3.1.1 → celestialflow-3.1.2}/src/celestialflow/__init__.py +11 -10
  5. celestialflow-3.1.2/src/celestialflow/graph/__init__.py +20 -0
  6. celestialflow-3.1.2/src/celestialflow/graph/analysis.py +50 -0
  7. celestialflow-3.1.1/src/celestialflow/task_graph.py → celestialflow-3.1.2/src/celestialflow/graph/graph.py +76 -127
  8. celestialflow-3.1.2/src/celestialflow/graph/serialize.py +103 -0
  9. celestialflow-3.1.1/src/celestialflow/task_structure.py → celestialflow-3.1.2/src/celestialflow/graph/structure.py +3 -2
  10. celestialflow-3.1.2/src/celestialflow/observability/__init__.py +7 -0
  11. celestialflow-3.1.1/src/celestialflow/task_report.py → celestialflow-3.1.2/src/celestialflow/observability/report.py +24 -27
  12. celestialflow-3.1.2/src/celestialflow/persistence/__init__.py +10 -0
  13. celestialflow-3.1.2/src/celestialflow/persistence/constant.py +11 -0
  14. celestialflow-3.1.2/src/celestialflow/persistence/fail.py +117 -0
  15. celestialflow-3.1.2/src/celestialflow/persistence/jsonl.py +179 -0
  16. celestialflow-3.1.1/src/celestialflow/task_logger.py → celestialflow-3.1.2/src/celestialflow/persistence/log.py +18 -20
  17. celestialflow-3.1.2/src/celestialflow/runtime/__init__.py +11 -0
  18. celestialflow-3.1.1/src/celestialflow/task_errors.py → celestialflow-3.1.2/src/celestialflow/runtime/errors.py +20 -0
  19. celestialflow-3.1.2/src/celestialflow/runtime/estimators.py +128 -0
  20. celestialflow-3.1.2/src/celestialflow/runtime/factories.py +62 -0
  21. celestialflow-3.1.2/src/celestialflow/runtime/hash.py +35 -0
  22. celestialflow-3.1.2/src/celestialflow/runtime/metrics.py +158 -0
  23. celestialflow-3.1.1/src/celestialflow/task_progress.py → celestialflow-3.1.2/src/celestialflow/runtime/progress.py +1 -0
  24. celestialflow-3.1.1/src/celestialflow/task_queue.py → celestialflow-3.1.2/src/celestialflow/runtime/queue.py +74 -96
  25. celestialflow-3.1.2/src/celestialflow/runtime/tools.py +13 -0
  26. celestialflow-3.1.1/src/celestialflow/task_types.py → celestialflow-3.1.2/src/celestialflow/runtime/types.py +3 -8
  27. celestialflow-3.1.2/src/celestialflow/stage/__init__.py +20 -0
  28. celestialflow-3.1.1/src/celestialflow/task_executor.py → celestialflow-3.1.2/src/celestialflow/stage/executor.py +230 -269
  29. celestialflow-3.1.1/src/celestialflow/task_nodes.py → celestialflow-3.1.2/src/celestialflow/stage/nodes.py +15 -10
  30. celestialflow-3.1.1/src/celestialflow/task_stage.py → celestialflow-3.1.2/src/celestialflow/stage/stage.py +21 -25
  31. celestialflow-3.1.2/src/celestialflow/utils/__init__.py +1 -0
  32. celestialflow-3.1.2/src/celestialflow/utils/collections.py +17 -0
  33. celestialflow-3.1.2/src/celestialflow/utils/debug.py +10 -0
  34. celestialflow-3.1.2/src/celestialflow/utils/format.py +195 -0
  35. celestialflow-3.1.1/src/celestialflow/task_web.py → celestialflow-3.1.2/src/celestialflow/web/server.py +2 -1
  36. {celestialflow-3.1.1 → celestialflow-3.1.2}/src/celestialflow.egg-info/PKG-INFO +43 -14
  37. celestialflow-3.1.2/src/celestialflow.egg-info/SOURCES.txt +44 -0
  38. celestialflow-3.1.2/src/celestialflow.egg-info/entry_points.txt +2 -0
  39. celestialflow-3.1.1/src/celestialflow/static/css/base.css +0 -330
  40. celestialflow-3.1.1/src/celestialflow/static/css/dashboard.css +0 -365
  41. celestialflow-3.1.1/src/celestialflow/static/css/errors.css +0 -279
  42. celestialflow-3.1.1/src/celestialflow/static/css/inject.css +0 -668
  43. celestialflow-3.1.1/src/celestialflow/static/favicon.ico +0 -0
  44. celestialflow-3.1.1/src/celestialflow/static/js/main.js +0 -143
  45. celestialflow-3.1.1/src/celestialflow/static/js/task_errors.js +0 -147
  46. celestialflow-3.1.1/src/celestialflow/static/js/task_injection.js +0 -296
  47. celestialflow-3.1.1/src/celestialflow/static/js/task_statuses.js +0 -234
  48. celestialflow-3.1.1/src/celestialflow/static/js/task_structure.js +0 -150
  49. celestialflow-3.1.1/src/celestialflow/static/js/task_summary.js +0 -36
  50. celestialflow-3.1.1/src/celestialflow/static/js/task_topology.js +0 -54
  51. celestialflow-3.1.1/src/celestialflow/static/js/utils.js +0 -97
  52. celestialflow-3.1.1/src/celestialflow/task_tools.py +0 -747
  53. celestialflow-3.1.1/src/celestialflow/templates/index.html +0 -384
  54. celestialflow-3.1.1/src/celestialflow.egg-info/SOURCES.txt +0 -40
  55. celestialflow-3.1.1/src/celestialflow.egg-info/entry_points.txt +0 -2
  56. {celestialflow-3.1.1 → celestialflow-3.1.2}/setup.cfg +0 -0
  57. {celestialflow-3.1.1 → celestialflow-3.1.2}/src/celestialflow.egg-info/dependency_links.txt +0 -0
  58. {celestialflow-3.1.1 → celestialflow-3.1.2}/src/celestialflow.egg-info/requires.txt +0 -0
  59. {celestialflow-3.1.1 → celestialflow-3.1.2}/src/celestialflow.egg-info/top_level.txt +0 -0
  60. {celestialflow-3.1.1 → celestialflow-3.1.2}/tests/test_executor.py +0 -0
  61. {celestialflow-3.1.1 → celestialflow-3.1.2}/tests/test_graph.py +0 -0
  62. {celestialflow-3.1.1 → celestialflow-3.1.2}/tests/test_nodes.py +0 -0
  63. {celestialflow-3.1.1 → celestialflow-3.1.2}/tests/test_structure.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: celestialflow
3
- Version: 3.1.1
3
+ Version: 3.1.2
4
4
  Summary: A flexible GRAPH-based task orchestration framework.
5
5
  Author-email: Mr-xiaotian <mingxiaomingtian@gmail.com>
6
6
  License: MIT
@@ -12,7 +12,7 @@ Classifier: License :: OSI Approved :: MIT License
12
12
  Classifier: Operating System :: OS Independent
13
13
  Classifier: Framework :: FastAPI
14
14
  Classifier: Topic :: Software Development :: Libraries
15
- Requires-Python: >=3.8
15
+ Requires-Python: >=3.10
16
16
  Description-Content-Type: text/markdown
17
17
  Requires-Dist: tqdm
18
18
  Requires-Dist: loguru
@@ -176,19 +176,31 @@ if __name__ == "__main__":
176
176
 
177
177
  若你想了解框架的整体结构与核心组件,下面的参考文档会对你有帮助:
178
178
 
179
- - [🔧TaskExecutor概念](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_executor.md)
180
- - [🔧TaskStage概念](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_stage.md)
181
- - [🌐TaskGraph概念](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_graph.md)
182
- - [📚Go Worker概念](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/go_worker.md)
179
+ - [stage/executor.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/stage/executor.md)
180
+ - [stage/stage.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/stage/stage.md)
181
+ - [graph/graph.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/graph/graph.md)
182
+ - [runtime/progress.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/progress.md)
183
+ - [runtime/metrics.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/metrics.md)
184
+ - [runtime/queue.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/queue.md)
185
+ - [stage/nodes.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/stage/nodes.md)
186
+ - [observability/report.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/observability/report.md)
187
+ - [graph/structure.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/graph/structure.md)
188
+ - [web/server.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/web/server.md)
189
+ - [other/go_worker.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/other/go_worker.md)
183
190
 
184
191
  推荐阅读顺序:
185
192
 
186
193
  ```mermaid
187
194
  flowchart TD
188
- classDef whiteNode fill:#ffffff,stroke:#000000,color:#000000;
195
+ classDef core fill:#e6efff,stroke:#3b82f6,color:#1e3a8a;
196
+ classDef runtime fill:#e9f8ef,stroke:#22c55e,color:#14532d;
197
+ classDef structure fill:#fff6e6,stroke:#f59e0b,color:#78350f;
198
+ classDef execution fill:#f3e8ff,stroke:#a855f7,color:#581c87;
199
+ classDef web fill:#ffeaea,stroke:#ef4444,color:#7f1d1d;
189
200
 
190
201
  TM[TaskExecutor.md] --> TS[TaskStage.md] --> TG[TaskGraph.md]
191
202
  TM --> TP[TaskProgress.md]
203
+ TM --> TME[TaskMetrics.md]
192
204
 
193
205
  TG --> TQ[TaskQueue.md]
194
206
  TG --> TN[TaskNodes.md]
@@ -198,15 +210,20 @@ flowchart TD
198
210
  TR --> TW[TaskWeb.md]
199
211
  TN --> GW[Go Worker.md]
200
212
 
201
- class TM,TG,TP,TQ,TN,TR,TS,TW,GW,TSR whiteNode;
213
+ class TM,TS,TG core;
214
+ class TP,TME runtime;
215
+ class TSR structure;
216
+ class TQ,TN,GW execution;
217
+ class TR,TW web;
202
218
  ```
203
219
 
204
220
  以下三篇可以作为补充阅读:
205
221
 
206
- - [TaskTools](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_tools.md)
207
- - [TaskTypes](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_types.md)
208
- - [TaskLogging](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_logging.md)
209
- - [TaskErrors](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_errors.md)
222
+ - [runtime/tools.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/tools.md)
223
+ - [runtime/types.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/types.md)
224
+ - [runtime/errors.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/errors.md)
225
+ - [persistence/fail.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/persistence/fail.md)
226
+ - [persistence/log.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/persistence/log.md)
210
227
 
211
228
  如果你更喜欢通过完整案例理解框架的运行方式,可以参考这篇从零开始构建 TaskGraph 的教程:
212
229
 
@@ -214,7 +231,7 @@ flowchart TD
214
231
 
215
232
  如果你对3.0.7版本加入的ctree_client与其功能感兴趣, 可以看看这一篇:
216
233
 
217
- [📚CelestialTreeClient](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/ctree_client.md)
234
+ [📚CelestialTreeClient](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/other/ctree_client.md)
218
235
 
219
236
  ## 环境要求(Requirements)
220
237
 
@@ -270,7 +287,7 @@ flowchart TD
270
287
  - 在前端中添加error_id的显示, 为之后显示provenance_tree做准备;
271
288
  - 增加大量warning与error, 用于提醒不规范设置;
272
289
  - 优化前后端中错误数据的传输方式, 在大量错误数据时减少内存消耗;
273
- - 优化TaskLogger中log队列的准入机制;
290
+ - 优化LogSinker中log队列的准入机制;
274
291
  - 修改部分Bug;
275
292
  - 3.1.0:
276
293
  - 新增:
@@ -290,6 +307,18 @@ flowchart TD
290
307
  - 修复:
291
308
  - 修复节点剩余时间在小于1s时显示0的问题(这很影响判断);
292
309
  - 在task_graph中使用"staged"模式时会报错的问题;
310
+ - 3.1.2:
311
+ - feat:
312
+ - [Important] 模仿已有Logger逻辑, 建立新的组合结构FailListener和FailSinker, 将原有绑定于TaskReporter的fail持久化在线程中实现;
313
+ - 借此让TaskExecutor也可以进行fail持久化, 文件为fallback/{date_str}/{executor_errors}({time_str}).jsonl";
314
+ - 重构整体项目结构, 现在更加清晰;
315
+ - 补全docs/reference中全部文档, 并令其符合项目重构后结构
316
+ - 引入uv进行环境管理;
317
+ - 将executor中技术逻辑分离为runtime/metrics.py;
318
+ - 整合TaskQueue中重复逻辑;
319
+ - fix
320
+ - 修复前端renderNodeList中参数设置错误;
321
+ - 修复其他微小bug;
293
322
 
294
323
  ## Star 历史趋势(Star History)
295
324
 
@@ -150,19 +150,31 @@ if __name__ == "__main__":
150
150
 
151
151
  若你想了解框架的整体结构与核心组件,下面的参考文档会对你有帮助:
152
152
 
153
- - [🔧TaskExecutor概念](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_executor.md)
154
- - [🔧TaskStage概念](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_stage.md)
155
- - [🌐TaskGraph概念](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_graph.md)
156
- - [📚Go Worker概念](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/go_worker.md)
153
+ - [stage/executor.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/stage/executor.md)
154
+ - [stage/stage.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/stage/stage.md)
155
+ - [graph/graph.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/graph/graph.md)
156
+ - [runtime/progress.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/progress.md)
157
+ - [runtime/metrics.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/metrics.md)
158
+ - [runtime/queue.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/queue.md)
159
+ - [stage/nodes.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/stage/nodes.md)
160
+ - [observability/report.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/observability/report.md)
161
+ - [graph/structure.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/graph/structure.md)
162
+ - [web/server.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/web/server.md)
163
+ - [other/go_worker.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/other/go_worker.md)
157
164
 
158
165
  推荐阅读顺序:
159
166
 
160
167
  ```mermaid
161
168
  flowchart TD
162
- classDef whiteNode fill:#ffffff,stroke:#000000,color:#000000;
169
+ classDef core fill:#e6efff,stroke:#3b82f6,color:#1e3a8a;
170
+ classDef runtime fill:#e9f8ef,stroke:#22c55e,color:#14532d;
171
+ classDef structure fill:#fff6e6,stroke:#f59e0b,color:#78350f;
172
+ classDef execution fill:#f3e8ff,stroke:#a855f7,color:#581c87;
173
+ classDef web fill:#ffeaea,stroke:#ef4444,color:#7f1d1d;
163
174
 
164
175
  TM[TaskExecutor.md] --> TS[TaskStage.md] --> TG[TaskGraph.md]
165
176
  TM --> TP[TaskProgress.md]
177
+ TM --> TME[TaskMetrics.md]
166
178
 
167
179
  TG --> TQ[TaskQueue.md]
168
180
  TG --> TN[TaskNodes.md]
@@ -172,15 +184,20 @@ flowchart TD
172
184
  TR --> TW[TaskWeb.md]
173
185
  TN --> GW[Go Worker.md]
174
186
 
175
- class TM,TG,TP,TQ,TN,TR,TS,TW,GW,TSR whiteNode;
187
+ class TM,TS,TG core;
188
+ class TP,TME runtime;
189
+ class TSR structure;
190
+ class TQ,TN,GW execution;
191
+ class TR,TW web;
176
192
  ```
177
193
 
178
194
  以下三篇可以作为补充阅读:
179
195
 
180
- - [TaskTools](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_tools.md)
181
- - [TaskTypes](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_types.md)
182
- - [TaskLogging](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_logging.md)
183
- - [TaskErrors](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_errors.md)
196
+ - [runtime/tools.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/tools.md)
197
+ - [runtime/types.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/types.md)
198
+ - [runtime/errors.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/errors.md)
199
+ - [persistence/fail.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/persistence/fail.md)
200
+ - [persistence/log.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/persistence/log.md)
184
201
 
185
202
  如果你更喜欢通过完整案例理解框架的运行方式,可以参考这篇从零开始构建 TaskGraph 的教程:
186
203
 
@@ -188,7 +205,7 @@ flowchart TD
188
205
 
189
206
  如果你对3.0.7版本加入的ctree_client与其功能感兴趣, 可以看看这一篇:
190
207
 
191
- [📚CelestialTreeClient](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/ctree_client.md)
208
+ [📚CelestialTreeClient](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/other/ctree_client.md)
192
209
 
193
210
  ## 环境要求(Requirements)
194
211
 
@@ -244,7 +261,7 @@ flowchart TD
244
261
  - 在前端中添加error_id的显示, 为之后显示provenance_tree做准备;
245
262
  - 增加大量warning与error, 用于提醒不规范设置;
246
263
  - 优化前后端中错误数据的传输方式, 在大量错误数据时减少内存消耗;
247
- - 优化TaskLogger中log队列的准入机制;
264
+ - 优化LogSinker中log队列的准入机制;
248
265
  - 修改部分Bug;
249
266
  - 3.1.0:
250
267
  - 新增:
@@ -264,6 +281,18 @@ flowchart TD
264
281
  - 修复:
265
282
  - 修复节点剩余时间在小于1s时显示0的问题(这很影响判断);
266
283
  - 在task_graph中使用"staged"模式时会报错的问题;
284
+ - 3.1.2:
285
+ - feat:
286
+ - [Important] 模仿已有Logger逻辑, 建立新的组合结构FailListener和FailSinker, 将原有绑定于TaskReporter的fail持久化在线程中实现;
287
+ - 借此让TaskExecutor也可以进行fail持久化, 文件为fallback/{date_str}/{executor_errors}({time_str}).jsonl";
288
+ - 重构整体项目结构, 现在更加清晰;
289
+ - 补全docs/reference中全部文档, 并令其符合项目重构后结构
290
+ - 引入uv进行环境管理;
291
+ - 将executor中技术逻辑分离为runtime/metrics.py;
292
+ - 整合TaskQueue中重复逻辑;
293
+ - fix
294
+ - 修复前端renderNodeList中参数设置错误;
295
+ - 修复其他微小bug;
267
296
 
268
297
  ## Star 历史趋势(Star History)
269
298
 
@@ -277,4 +306,4 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
277
306
  ## 作者(Author)
278
307
  Author: Mr-xiaotian
279
308
  Email: mingxiaomingtian@gmail.com
280
- Project Link: [https://github.com/Mr-xiaotian/CelestialFlow](https://github.com/Mr-xiaotian/CelestialFlow)
309
+ Project Link: [https://github.com/Mr-xiaotian/CelestialFlow](https://github.com/Mr-xiaotian/CelestialFlow)
@@ -4,13 +4,13 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "celestialflow"
7
- version = "3.1.1"
7
+ version = "3.1.2"
8
8
  description = "A flexible GRAPH-based task orchestration framework."
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
11
11
  authors = [{ name = "Mr-xiaotian", email = "mingxiaomingtian@gmail.com" }]
12
12
  keywords = ["workflow", "task", "graph", "async", "CelestialFlow"]
13
- requires-python = ">=3.8"
13
+ requires-python = ">=3.10"
14
14
 
15
15
  dependencies = [
16
16
  "tqdm",
@@ -37,7 +37,7 @@ classifiers = [
37
37
  "Bug Tracker" = "https://github.com/Mr-xiaotian/CelestialFlow/issues"
38
38
 
39
39
  [project.scripts]
40
- celestialflow-web = "celestialflow.task_web:main_entry"
40
+ celestialflow-web = "celestialflow.web.server:main_entry"
41
41
 
42
42
  [tool.setuptools]
43
43
  license-files = []
@@ -63,4 +63,9 @@ asyncio_default_fixture_loop_scope = "function"
63
63
  dev = [
64
64
  "build>=1.2.2.post1",
65
65
  "twine>=6.1.0",
66
+ "pytest>=8.3.4",
67
+ "pytest-asyncio>=0.25.3",
68
+ "httpx>=0.28.1",
69
+ "python-dotenv>=1.2.2",
70
+ "black>=26.1.0",
66
71
  ]
@@ -1,14 +1,15 @@
1
- from .task_graph import TaskGraph
2
- from .task_executor import TaskExecutor
3
- from .task_stage import TaskStage
4
- from .task_nodes import (
1
+ # __init__.py
2
+ from .stage import (
3
+ TaskExecutor,
4
+ TaskStage,
5
5
  TaskSplitter,
6
6
  TaskRedisSink,
7
7
  TaskRedisSource,
8
8
  TaskRedisAck,
9
9
  TaskRouter,
10
10
  )
11
- from .task_structure import (
11
+ from .graph import (
12
+ TaskGraph,
12
13
  TaskChain,
13
14
  TaskLoop,
14
15
  TaskCross,
@@ -16,15 +17,15 @@ from .task_structure import (
16
17
  TaskWheel,
17
18
  TaskGrid,
18
19
  )
19
- from .task_types import TerminationSignal
20
- from .task_tools import (
20
+ from .runtime.types import TerminationSignal
21
+ from .runtime.hash import make_hashable
22
+ from .utils.format import format_table
23
+ from .persistence.jsonl import (
21
24
  load_jsonl_logs,
22
25
  load_task_by_stage,
23
26
  load_task_by_error,
24
- make_hashable,
25
- format_table,
26
27
  )
27
- from .task_web import TaskWebServer
28
+ from .web.server import TaskWebServer
28
29
 
29
30
  __all__ = [
30
31
  "TaskGraph",
@@ -0,0 +1,20 @@
1
+ # graph/__init__.py
2
+ from .graph import TaskGraph
3
+ from .structure import (
4
+ TaskChain,
5
+ TaskLoop,
6
+ TaskCross,
7
+ TaskComplete,
8
+ TaskWheel,
9
+ TaskGrid,
10
+ )
11
+
12
+ __all__ = [
13
+ "TaskGraph",
14
+ "TaskChain",
15
+ "TaskLoop",
16
+ "TaskCross",
17
+ "TaskComplete",
18
+ "TaskWheel",
19
+ "TaskGrid",
20
+ ]
@@ -0,0 +1,50 @@
1
+ # graph/analysis.py
2
+ import networkx as nx
3
+ from networkx import is_directed_acyclic_graph
4
+ from typing import Dict, Any, List
5
+
6
+
7
+ # ======== (图论分析) ========
8
+ def format_networkx_graph(structure_graph: List[Dict[str, Any]]) -> nx.DiGraph:
9
+ """
10
+ 将结构图(由 build_structure_graph 生成)转换为 networkx 有向图(DiGraph)
11
+
12
+ :param structure_graph: JSON 格式的任务结构图,List[Dict]
13
+ :return: 构建好的 networkx.DiGraph
14
+ """
15
+ G = nx.DiGraph()
16
+
17
+ def add_node_and_edges(node: Dict[str, Any]):
18
+ node_id = f'{node["stage_name"]}[{node["func_name"]}]'
19
+ G.add_node(node_id, **{"mode": node.get("stage_mode")})
20
+
21
+ for child in node.get("next_stages", []):
22
+ child_id = f'{child["stage_name"]}[{child["func_name"]}]'
23
+ G.add_edge(node_id, child_id)
24
+ # 递归添加子节点
25
+ add_node_and_edges(child)
26
+
27
+ for root in structure_graph:
28
+ add_node_and_edges(root)
29
+
30
+ return G
31
+
32
+
33
+ def compute_node_levels(G: nx.DiGraph) -> Dict[str, int]:
34
+ """
35
+ 计算 DAG 中每个节点的层级(最早执行阶段)
36
+ 前提:图必须是有向无环图(DAG)
37
+
38
+ :param G: networkx 有向图(DiGraph)
39
+ :return: dict[node] = level (int)
40
+ """
41
+ if not nx.is_directed_acyclic_graph(G):
42
+ raise ValueError("该图不是 DAG,无法进行层级划分")
43
+
44
+ level = {node: 0 for node in G.nodes} # 初始层级为 0
45
+
46
+ for node in nx.topological_sort(G): # 按拓扑顺序遍历
47
+ for succ in G.successors(node):
48
+ level[succ] = max(level[succ], level[node] + 1)
49
+
50
+ return level