celestialflow 3.1.7__tar.gz → 3.1.8__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 (97) hide show
  1. {celestialflow-3.1.7 → celestialflow-3.1.8}/PKG-INFO +67 -41
  2. {celestialflow-3.1.7 → celestialflow-3.1.8}/README.md +66 -40
  3. {celestialflow-3.1.7 → celestialflow-3.1.8}/pyproject.toml +81 -81
  4. celestialflow-3.1.8/src/celestialflow/funnel/core_inlet.py +22 -0
  5. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/funnel/core_spout.py +8 -0
  6. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/graph/core_graph.py +405 -234
  7. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/graph/core_structure.py +75 -46
  8. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/graph/util_analysis.py +5 -0
  9. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/graph/util_serialize.py +53 -11
  10. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/observability/core_progress.py +31 -4
  11. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/observability/core_report.py +21 -3
  12. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/persistence/__init__.py +2 -2
  13. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/persistence/core_fail.py +27 -2
  14. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/persistence/core_log.py +108 -51
  15. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/persistence/core_success.py +7 -0
  16. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/persistence/util_jsonl.py +13 -4
  17. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/runtime/core_dispatch.py +64 -85
  18. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/runtime/core_envelope.py +9 -0
  19. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/runtime/core_metrics.py +20 -22
  20. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/runtime/core_queue.py +17 -67
  21. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/runtime/util_errors.py +48 -1
  22. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/runtime/util_estimators.py +11 -0
  23. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/runtime/util_factories.py +34 -10
  24. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/runtime/util_hash.py +3 -0
  25. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/runtime/util_types.py +40 -7
  26. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/stage/core_executor.py +105 -152
  27. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/stage/core_stage.py +80 -119
  28. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/stage/core_stages.py +111 -33
  29. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/utils/util_benchmark.py +17 -8
  30. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/utils/util_clone.py +29 -25
  31. celestialflow-3.1.8/src/celestialflow/utils/util_debug.py +16 -0
  32. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/utils/util_format.py +4 -0
  33. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/config.json +1 -1
  34. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/core_server.py +98 -16
  35. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/js/task_statuses.js +92 -92
  36. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/js/task_structure.js +130 -130
  37. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/js/task_summary.js +49 -49
  38. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/ts/task_errors.ts +34 -0
  39. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/ts/task_statuses.ts +6 -6
  40. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/ts/task_structure.ts +1 -1
  41. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/ts/task_summary.ts +59 -59
  42. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/templates/index.html +1 -1
  43. celestialflow-3.1.8/src/celestialflow/web/util_cal.py +9 -0
  44. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/util_config.py +13 -2
  45. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/util_error.py +16 -0
  46. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow.egg-info/PKG-INFO +67 -41
  47. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow.egg-info/SOURCES.txt +5 -2
  48. celestialflow-3.1.8/tests/test_envelope.py +45 -0
  49. celestialflow-3.1.8/tests/test_executor.py +222 -0
  50. celestialflow-3.1.8/tests/test_graph.py +418 -0
  51. celestialflow-3.1.8/tests/test_metrics.py +119 -0
  52. celestialflow-3.1.8/tests/test_queue.py +141 -0
  53. celestialflow-3.1.8/tests/test_stage.py +106 -0
  54. celestialflow-3.1.7/src/celestialflow/funnel/core_inlet.py +0 -12
  55. celestialflow-3.1.7/src/celestialflow/utils/util_debug.py +0 -10
  56. celestialflow-3.1.7/src/celestialflow/web/util_cal.py +0 -4
  57. celestialflow-3.1.7/tests/test_executor.py +0 -54
  58. celestialflow-3.1.7/tests/test_stages.py +0 -312
  59. celestialflow-3.1.7/tests/test_structure.py +0 -281
  60. {celestialflow-3.1.7 → celestialflow-3.1.8}/setup.cfg +0 -0
  61. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/__init__.py +0 -0
  62. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/funnel/__init__.py +0 -0
  63. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/graph/__init__.py +0 -0
  64. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/observability/__init__.py +0 -0
  65. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/persistence/util_constant.py +0 -0
  66. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/runtime/__init__.py +0 -0
  67. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/runtime/util_queue.py +0 -0
  68. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/stage/__init__.py +0 -0
  69. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/utils/__init__.py +0 -0
  70. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/utils/util_collections.py +0 -0
  71. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/css/_colors.css +0 -0
  72. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/css/base.css +0 -0
  73. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/css/dashboard.css +0 -0
  74. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/css/errors.css +0 -0
  75. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/css/inject.css +0 -0
  76. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/favicon.ico +0 -0
  77. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/js/main.js +0 -0
  78. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/js/task_analysis.js +0 -0
  79. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/js/task_config.js +0 -0
  80. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/js/task_errors.js +0 -0
  81. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/js/task_history.js +0 -0
  82. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/js/task_injection.js +0 -0
  83. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/js/task_topology.js +0 -0
  84. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/js/utils.js +0 -0
  85. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/js/web_config.js +0 -0
  86. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/ts/globals.d.ts +0 -0
  87. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/ts/main.ts +0 -0
  88. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/ts/task_analysis.ts +0 -0
  89. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/ts/task_history.ts +0 -0
  90. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/ts/task_injection.ts +0 -0
  91. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/ts/utils.ts +0 -0
  92. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow/web/static/ts/web_config.ts +0 -0
  93. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow.egg-info/dependency_links.txt +0 -0
  94. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow.egg-info/entry_points.txt +0 -0
  95. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow.egg-info/requires.txt +0 -0
  96. {celestialflow-3.1.7 → celestialflow-3.1.8}/src/celestialflow.egg-info/top_level.txt +0 -0
  97. {celestialflow-3.1.7 → celestialflow-3.1.8}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: celestialflow
3
- Version: 3.1.7
3
+ Version: 3.1.8
4
4
  Summary: A flexible GRAPH-based task orchestration framework.
5
5
  Author-email: Mr-xiaotian <mingxiaomingtian@gmail.com>
6
6
  License: MIT
@@ -43,6 +43,10 @@ Requires-Dist: celestialtree>=0.1.2
43
43
  <img src="https://img.shields.io/badge/Distributed-Worker%20Friendly-orange">
44
44
  </p>
45
45
 
46
+ <p align="center">
47
+ <a href="README.md">中文</a> | <a href="docs/en/README.md">English</a> | <a href="docs/ja/README.md">日本語</a>
48
+ </p>
49
+
46
50
  **CelestialFlow** 是一个轻量级但功能完全的任务流框架,适合需要 **复杂依赖关系**、**灵活执行模型**、**跨设备运行**与**实时可视化监控** 的中/大型 Python 任务系统。
47
51
 
48
52
  - 相比 Airflow/Dagster 更轻、更快开始
@@ -63,9 +67,10 @@ TaskStage 的任务执行模式只有两种:
63
67
  * **线性(serial)**
64
68
  * **多线程(thread)**
65
69
 
66
- 在图级别上,每个 Stage 支持两种上下文模式:
70
+ 在图级别上,每个 Stage 支持三种上下文模式:
67
71
 
68
72
  * **线性执行(serial layout)**:当前节点执行完毕再启动下一节点(下游节点可提前接收任务但不会立即执行)。
73
+ * **线程执行(thread layout)**:当前节点在主进程的独立线程中启动,适合 I/O 密集型任务和不可 pickle 的函数(如 lambda)。
69
74
  * **并行执行(process layout)**:当前节点启动后立刻前去启动下一节点。
70
75
 
71
76
  TaskGraph 能构建完整的 **有向图结构(Directed Graph)**,不仅支持传统的有向无环图(DAG),也能灵活表达 **树形(Tree)**、**环形(loop)** 乃至于 **完全图(Complete Graph)** 形式的任务依赖。
@@ -152,9 +157,12 @@ if __name__ == "__main__":
152
157
  stage2 = TaskStage(square, execution_mode="thread")
153
158
 
154
159
  # 构建任务图结构
155
- stage1.set_graph_context([stage2], stage_mode="process", stage_name="Adder")
156
- stage2.set_graph_context([], stage_mode="process", stage_name="Squarer")
157
- graph = TaskGraph([stage1])
160
+ stage1 = TaskStage(func=add, execution_mode="thread", unpack_task_args=True, stage_mode="process", name="Adder")
161
+ stage2 = TaskStage(func=square, execution_mode="thread", stage_mode="process", name="Squarer")
162
+
163
+ graph = TaskGraph()
164
+ graph.set_stages(root_stages=[stage1], stages=[stage2])
165
+ graph.connect([stage1], [stage2])
158
166
 
159
167
  # 初始化任务并启动
160
168
  graph.start_graph({stage1.get_tag(): [(1, 2), (3, 4), (5, 6)]})
@@ -162,29 +170,23 @@ if __name__ == "__main__":
162
170
 
163
171
  注意不要在.ipynb中运行。
164
172
 
165
- 👉 想查看完整Quick Start,请见[Quick Start](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/quick_start.md)
173
+ 👉 想查看完整Quick Start,请见[Quick Start](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/quick_start.md)
166
174
 
167
175
  ## 深入阅读(Further Reading)
168
176
 
169
- (以下文档完善中)
170
-
171
- 你可以继续运行更多的测试代码,这里记录了各个测试文件与其中的测试函数说明:
172
-
173
- [📄tests/README.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/tests/README.md)
174
-
175
177
  若你想了解框架的整体结构与核心组件,下面的参考文档会对你有帮助:
176
178
 
177
- - [stage/core_executor.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/stage/core_executor.md)
178
- - [stage/core_stage.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/stage/core_stage.md)
179
- - [graph/core_graph.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/graph/core_graph.md)
180
- - [observability/core_progress.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/observability/core_progress.md)
181
- - [runtime/core_metrics.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/core_metrics.md)
182
- - [runtime/core_queue.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/core_queue.md)
183
- - [stage/core_stages.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/stage/core_stages.md)
184
- - [observability/core_report.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/observability/core_report.md)
185
- - [graph/core_structure.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/graph/core_structure.md)
186
- - [web/core_server.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/web/core_server.md)
187
- - [other/go_worker.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/other/go_worker.md)
179
+ - [stage/core_executor.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/stage/core_executor.md)
180
+ - [stage/core_stage.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/stage/core_stage.md)
181
+ - [graph/core_graph.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/graph/core_graph.md)
182
+ - [observability/core_progress.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/observability/core_progress.md)
183
+ - [runtime/core_metrics.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/runtime/core_metrics.md)
184
+ - [runtime/core_queue.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/runtime/core_queue.md)
185
+ - [stage/core_stages.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/stage/core_stages.md)
186
+ - [observability/core_report.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/observability/core_report.md)
187
+ - [graph/core_structure.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/graph/core_structure.md)
188
+ - [web/core_server.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/web/core_server.md)
189
+ - [other/go_worker.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/other/go_worker.md)
188
190
 
189
191
  推荐阅读顺序:
190
192
 
@@ -217,19 +219,31 @@ flowchart TD
217
219
 
218
220
  以下三篇可以作为补充阅读:
219
221
 
220
- - [runtime/util_queue.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/util_queue.md)
221
- - [runtime/util_types.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/util_types.md)
222
- - [runtime/util_errors.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/util_errors.md)
223
- - [persistence/core_fail.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/persistence/core_fail.md)
224
- - [persistence/core_log.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/persistence/core_log.md)
222
+ - [runtime/util_queue.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/runtime/util_queue.md)
223
+ - [runtime/util_types.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/runtime/util_types.md)
224
+ - [runtime/util_errors.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/runtime/util_errors.md)
225
+ - [persistence/core_fail.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/persistence/core_fail.md)
226
+ - [persistence/core_log.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/persistence/core_log.md)
225
227
 
226
- 如果你更喜欢通过完整案例理解框架的运行方式,可以参考这篇从零开始构建 TaskGraph 的教程:
228
+ 如果你更喜欢通过完整案例理解框架的运行方式,可以参考这篇利用 TaskGraph 从零开始构建项目的教程:
227
229
 
228
- [📘案例教程](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/tutorial.md)
230
+ [📘案例教程](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/tutorial.md)
229
231
 
230
232
  如果你对3.0.7版本加入的ctree_client与其功能感兴趣, 可以看看这一篇:
231
233
 
232
- [📚CelestialTreeClient](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/other/ctree_client.md)
234
+ [📚CelestialTreeClient](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/other/ctree_client.md)
235
+
236
+ 你可以继续运行更多的演示代码,这里记录了各个演示文件与其中的演示函数说明:
237
+
238
+ [🎮demo/](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/demo/)
239
+
240
+ ​如果你想运行测试代码, 可以先查看如下文档内容:
241
+
242
+ [🧪tests/](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/tests/)
243
+
244
+ 如果你想查看bench内容, 这里的数据成为框架中部分设计的决策依据:
245
+
246
+ [⚡bench/](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/bench/)
233
247
 
234
248
  ## 环境要求(Requirements)
235
249
 
@@ -253,24 +267,36 @@ flowchart TD
253
267
  <p align="center">
254
268
  <img src="https://raw.githubusercontent.com/Mr-xiaotian/CelestialFlow/main/img/file_structure.svg" alt="FileStructure" />
255
269
  <br/>
256
- <em>celestial-flow 3.1.7</em>
270
+ <em>celestial-flow 3.1.8</em>
257
271
  </p>
258
272
 
259
273
  (该视图由我的另一个项目[CelestialVault](https://github.com/Mr-xiaotian/CelestialVault)中inst_file.FileTree.print_tree()生成。转换为图片则借助[Carbon](https://carbon.now.sh)。)
260
274
 
261
275
  ## 版本日志(Version Log)
262
- - 3.1.7
276
+ - 3.1.8
263
277
  - feat:
264
- - [Important] 删除executor中的"process"模式, 它跟新的retry机制实在难以匹配;
278
+ - [Important] 为stage_mode新增"thread"模式, 适合I/O密集型任务和不可pickle的函数;
279
+ - 在io密集任务的bench测试中, "thread-thread"相比最慢的"serial-serial"快8.7x, 并且优于之前最快的"process-thread";
280
+ - 新增docs/.../bench与docs/.../demo文档, 补充bench实测结果;
265
281
  - refactor:
266
- - [Important] 大幅重构retry机制, 现在不再让retry任务重进task_queue, 而是在worker中直接解决;
267
- - 模仿CelestialForge中grow的做法;
268
- - 大幅重构原本成功与失败结果的缓存机制, 并将原有get_success/error_dict改名为get_success/error_pairs, 以避免task无法作为键时会导致的问题;
269
- - fail数据从fail.jsonl中提取;
270
- - success数据从result_queue中直接获取, 为此添加了SuccessSpout作为集合端;
282
+ - [Important] 删除stage.set_stage_context, 改用graph.connect;
283
+ - 接口破坏性重构, 需要修改大量graph相关代码;
284
+ - [Important] name作为第一位参数在stage/executor中强制设定;
285
+ - 接口破坏性重构
286
+ - 优化async的executor_mode, 使其同时获取与消费任务, 而非集中消费;
287
+ - 为上版本retry机制的重构收尾;
271
288
  - fix:
272
- - 修复部分任务类型无法在log_spout中dump进jsonl文件的问题;
273
- - 修复在executor运行时, retry添加任务total数的问题, 虽然这样很帅;
289
+ - 修复find_unpickleable对bound method的误报;
290
+ - 修复stage重复检测错误;
291
+ - 修复retry任务无法被去重的问题;
292
+ - chore:
293
+ - 将demo/中所有test_函数名改为demo_函数名;
294
+ - 重组docs目录结构, 将reference改为src;
295
+ - docs中新增en/与ja/, 并将原有中文文档移至zh-CN/;
296
+
297
+ 更多过往日志可看:
298
+
299
+ [change_log.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/runtime/change_log.md )
274
300
 
275
301
  ## Star 历史趋势(Star History)
276
302
 
@@ -18,6 +18,10 @@
18
18
  <img src="https://img.shields.io/badge/Distributed-Worker%20Friendly-orange">
19
19
  </p>
20
20
 
21
+ <p align="center">
22
+ <a href="README.md">中文</a> | <a href="docs/en/README.md">English</a> | <a href="docs/ja/README.md">日本語</a>
23
+ </p>
24
+
21
25
  **CelestialFlow** 是一个轻量级但功能完全的任务流框架,适合需要 **复杂依赖关系**、**灵活执行模型**、**跨设备运行**与**实时可视化监控** 的中/大型 Python 任务系统。
22
26
 
23
27
  - 相比 Airflow/Dagster 更轻、更快开始
@@ -38,9 +42,10 @@ TaskStage 的任务执行模式只有两种:
38
42
  * **线性(serial)**
39
43
  * **多线程(thread)**
40
44
 
41
- 在图级别上,每个 Stage 支持两种上下文模式:
45
+ 在图级别上,每个 Stage 支持三种上下文模式:
42
46
 
43
47
  * **线性执行(serial layout)**:当前节点执行完毕再启动下一节点(下游节点可提前接收任务但不会立即执行)。
48
+ * **线程执行(thread layout)**:当前节点在主进程的独立线程中启动,适合 I/O 密集型任务和不可 pickle 的函数(如 lambda)。
44
49
  * **并行执行(process layout)**:当前节点启动后立刻前去启动下一节点。
45
50
 
46
51
  TaskGraph 能构建完整的 **有向图结构(Directed Graph)**,不仅支持传统的有向无环图(DAG),也能灵活表达 **树形(Tree)**、**环形(loop)** 乃至于 **完全图(Complete Graph)** 形式的任务依赖。
@@ -127,9 +132,12 @@ if __name__ == "__main__":
127
132
  stage2 = TaskStage(square, execution_mode="thread")
128
133
 
129
134
  # 构建任务图结构
130
- stage1.set_graph_context([stage2], stage_mode="process", stage_name="Adder")
131
- stage2.set_graph_context([], stage_mode="process", stage_name="Squarer")
132
- graph = TaskGraph([stage1])
135
+ stage1 = TaskStage(func=add, execution_mode="thread", unpack_task_args=True, stage_mode="process", name="Adder")
136
+ stage2 = TaskStage(func=square, execution_mode="thread", stage_mode="process", name="Squarer")
137
+
138
+ graph = TaskGraph()
139
+ graph.set_stages(root_stages=[stage1], stages=[stage2])
140
+ graph.connect([stage1], [stage2])
133
141
 
134
142
  # 初始化任务并启动
135
143
  graph.start_graph({stage1.get_tag(): [(1, 2), (3, 4), (5, 6)]})
@@ -137,29 +145,23 @@ if __name__ == "__main__":
137
145
 
138
146
  注意不要在.ipynb中运行。
139
147
 
140
- 👉 想查看完整Quick Start,请见[Quick Start](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/quick_start.md)
148
+ 👉 想查看完整Quick Start,请见[Quick Start](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/quick_start.md)
141
149
 
142
150
  ## 深入阅读(Further Reading)
143
151
 
144
- (以下文档完善中)
145
-
146
- 你可以继续运行更多的测试代码,这里记录了各个测试文件与其中的测试函数说明:
147
-
148
- [📄tests/README.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/tests/README.md)
149
-
150
152
  若你想了解框架的整体结构与核心组件,下面的参考文档会对你有帮助:
151
153
 
152
- - [stage/core_executor.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/stage/core_executor.md)
153
- - [stage/core_stage.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/stage/core_stage.md)
154
- - [graph/core_graph.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/graph/core_graph.md)
155
- - [observability/core_progress.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/observability/core_progress.md)
156
- - [runtime/core_metrics.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/core_metrics.md)
157
- - [runtime/core_queue.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/core_queue.md)
158
- - [stage/core_stages.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/stage/core_stages.md)
159
- - [observability/core_report.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/observability/core_report.md)
160
- - [graph/core_structure.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/graph/core_structure.md)
161
- - [web/core_server.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/web/core_server.md)
162
- - [other/go_worker.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/other/go_worker.md)
154
+ - [stage/core_executor.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/stage/core_executor.md)
155
+ - [stage/core_stage.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/stage/core_stage.md)
156
+ - [graph/core_graph.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/graph/core_graph.md)
157
+ - [observability/core_progress.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/observability/core_progress.md)
158
+ - [runtime/core_metrics.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/runtime/core_metrics.md)
159
+ - [runtime/core_queue.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/runtime/core_queue.md)
160
+ - [stage/core_stages.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/stage/core_stages.md)
161
+ - [observability/core_report.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/observability/core_report.md)
162
+ - [graph/core_structure.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/graph/core_structure.md)
163
+ - [web/core_server.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/web/core_server.md)
164
+ - [other/go_worker.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/other/go_worker.md)
163
165
 
164
166
  推荐阅读顺序:
165
167
 
@@ -192,19 +194,31 @@ flowchart TD
192
194
 
193
195
  以下三篇可以作为补充阅读:
194
196
 
195
- - [runtime/util_queue.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/util_queue.md)
196
- - [runtime/util_types.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/util_types.md)
197
- - [runtime/util_errors.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/util_errors.md)
198
- - [persistence/core_fail.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/persistence/core_fail.md)
199
- - [persistence/core_log.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/persistence/core_log.md)
197
+ - [runtime/util_queue.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/runtime/util_queue.md)
198
+ - [runtime/util_types.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/runtime/util_types.md)
199
+ - [runtime/util_errors.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/runtime/util_errors.md)
200
+ - [persistence/core_fail.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/persistence/core_fail.md)
201
+ - [persistence/core_log.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/persistence/core_log.md)
200
202
 
201
- 如果你更喜欢通过完整案例理解框架的运行方式,可以参考这篇从零开始构建 TaskGraph 的教程:
203
+ 如果你更喜欢通过完整案例理解框架的运行方式,可以参考这篇利用 TaskGraph 从零开始构建项目的教程:
202
204
 
203
- [📘案例教程](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/tutorial.md)
205
+ [📘案例教程](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/tutorial.md)
204
206
 
205
207
  如果你对3.0.7版本加入的ctree_client与其功能感兴趣, 可以看看这一篇:
206
208
 
207
- [📚CelestialTreeClient](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/other/ctree_client.md)
209
+ [📚CelestialTreeClient](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/other/ctree_client.md)
210
+
211
+ 你可以继续运行更多的演示代码,这里记录了各个演示文件与其中的演示函数说明:
212
+
213
+ [🎮demo/](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/demo/)
214
+
215
+ ​如果你想运行测试代码, 可以先查看如下文档内容:
216
+
217
+ [🧪tests/](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/tests/)
218
+
219
+ 如果你想查看bench内容, 这里的数据成为框架中部分设计的决策依据:
220
+
221
+ [⚡bench/](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/bench/)
208
222
 
209
223
  ## 环境要求(Requirements)
210
224
 
@@ -228,24 +242,36 @@ flowchart TD
228
242
  <p align="center">
229
243
  <img src="https://raw.githubusercontent.com/Mr-xiaotian/CelestialFlow/main/img/file_structure.svg" alt="FileStructure" />
230
244
  <br/>
231
- <em>celestial-flow 3.1.7</em>
245
+ <em>celestial-flow 3.1.8</em>
232
246
  </p>
233
247
 
234
248
  (该视图由我的另一个项目[CelestialVault](https://github.com/Mr-xiaotian/CelestialVault)中inst_file.FileTree.print_tree()生成。转换为图片则借助[Carbon](https://carbon.now.sh)。)
235
249
 
236
250
  ## 版本日志(Version Log)
237
- - 3.1.7
251
+ - 3.1.8
238
252
  - feat:
239
- - [Important] 删除executor中的"process"模式, 它跟新的retry机制实在难以匹配;
253
+ - [Important] 为stage_mode新增"thread"模式, 适合I/O密集型任务和不可pickle的函数;
254
+ - 在io密集任务的bench测试中, "thread-thread"相比最慢的"serial-serial"快8.7x, 并且优于之前最快的"process-thread";
255
+ - 新增docs/.../bench与docs/.../demo文档, 补充bench实测结果;
240
256
  - refactor:
241
- - [Important] 大幅重构retry机制, 现在不再让retry任务重进task_queue, 而是在worker中直接解决;
242
- - 模仿CelestialForge中grow的做法;
243
- - 大幅重构原本成功与失败结果的缓存机制, 并将原有get_success/error_dict改名为get_success/error_pairs, 以避免task无法作为键时会导致的问题;
244
- - fail数据从fail.jsonl中提取;
245
- - success数据从result_queue中直接获取, 为此添加了SuccessSpout作为集合端;
257
+ - [Important] 删除stage.set_stage_context, 改用graph.connect;
258
+ - 接口破坏性重构, 需要修改大量graph相关代码;
259
+ - [Important] name作为第一位参数在stage/executor中强制设定;
260
+ - 接口破坏性重构
261
+ - 优化async的executor_mode, 使其同时获取与消费任务, 而非集中消费;
262
+ - 为上版本retry机制的重构收尾;
246
263
  - fix:
247
- - 修复部分任务类型无法在log_spout中dump进jsonl文件的问题;
248
- - 修复在executor运行时, retry添加任务total数的问题, 虽然这样很帅;
264
+ - 修复find_unpickleable对bound method的误报;
265
+ - 修复stage重复检测错误;
266
+ - 修复retry任务无法被去重的问题;
267
+ - chore:
268
+ - 将demo/中所有test_函数名改为demo_函数名;
269
+ - 重组docs目录结构, 将reference改为src;
270
+ - docs中新增en/与ja/, 并将原有中文文档移至zh-CN/;
271
+
272
+ 更多过往日志可看:
273
+
274
+ [change_log.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/runtime/change_log.md )
249
275
 
250
276
  ## Star 历史趋势(Star History)
251
277
 
@@ -1,81 +1,81 @@
1
- [build-system]
2
- requires = ["setuptools>=61.0", "wheel"]
3
- build-backend = "setuptools.build_meta"
4
-
5
- [project]
6
- name = "celestialflow"
7
- version = "3.1.7"
8
- description = "A flexible GRAPH-based task orchestration framework."
9
- readme = "README.md"
10
- license = { text = "MIT" }
11
- authors = [{ name = "Mr-xiaotian", email = "mingxiaomingtian@gmail.com" }]
12
- keywords = ["workflow", "task", "graph", "async", "CelestialFlow"]
13
- requires-python = ">=3.10"
14
-
15
- dependencies = [
16
- "tqdm",
17
- "fastapi",
18
- "uvicorn",
19
- "requests",
20
- "networkx",
21
- "redis",
22
- "jinja2",
23
- "celestialtree>=0.1.2",
24
- ]
25
-
26
- classifiers = [
27
- "Programming Language :: Python :: 3",
28
- "License :: OSI Approved :: MIT License",
29
- "Operating System :: OS Independent",
30
- "Framework :: FastAPI",
31
- "Topic :: Software Development :: Libraries",
32
- ]
33
-
34
- [project.urls]
35
- "Homepage" = "https://github.com/Mr-xiaotian/CelestialFlow"
36
- "Bug Tracker" = "https://github.com/Mr-xiaotian/CelestialFlow/issues"
37
-
38
- [project.scripts]
39
- celestialflow-web = "celestialflow.web.core_server:main_entry"
40
-
41
- [tool.setuptools]
42
- license-files = []
43
-
44
- [tool.setuptools.package-data]
45
- celestialflow = [
46
- "web/templates/**/*.html",
47
- "web/static/**/*",
48
- "web/config.json"
49
- ]
50
-
51
- [tool.pytest.ini_options]
52
- addopts = "-s"
53
- log_cli = true
54
- log_cli_level = "INFO"
55
- log_cli_format = "%(asctime)s [%(levelname)s] %(message)s"
56
- log_cli_date_format = "%Y-%m-%d %H:%M:%S"
57
-
58
- filterwarnings = [
59
- "ignore::DeprecationWarning",
60
- "ignore::pytest.PytestDeprecationWarning",
61
- ]
62
-
63
- asyncio_default_fixture_loop_scope = "function"
64
-
65
- [dependency-groups]
66
- dev = [
67
- "build>=1.2.2.post1",
68
- "twine>=6.1.0",
69
- "pytest>=8.3.4",
70
- "pytest-asyncio>=0.25.3",
71
- "httpx>=0.28.1",
72
- "python-dotenv>=1.2.2",
73
- "dill",
74
- "mypy>=1.19.1",
75
- "ruff",
76
- ]
77
-
78
- [tool.mypy]
79
- python_version = "3.10"
80
- no_implicit_optional = false
81
- disable_error_code = ["import-untyped"]
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "celestialflow"
7
+ version = "3.1.8"
8
+ description = "A flexible GRAPH-based task orchestration framework."
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ authors = [{ name = "Mr-xiaotian", email = "mingxiaomingtian@gmail.com" }]
12
+ keywords = ["workflow", "task", "graph", "async", "CelestialFlow"]
13
+ requires-python = ">=3.10"
14
+
15
+ dependencies = [
16
+ "tqdm",
17
+ "fastapi",
18
+ "uvicorn",
19
+ "requests",
20
+ "networkx",
21
+ "redis",
22
+ "jinja2",
23
+ "celestialtree>=0.1.2",
24
+ ]
25
+
26
+ classifiers = [
27
+ "Programming Language :: Python :: 3",
28
+ "License :: OSI Approved :: MIT License",
29
+ "Operating System :: OS Independent",
30
+ "Framework :: FastAPI",
31
+ "Topic :: Software Development :: Libraries",
32
+ ]
33
+
34
+ [project.urls]
35
+ "Homepage" = "https://github.com/Mr-xiaotian/CelestialFlow"
36
+ "Bug Tracker" = "https://github.com/Mr-xiaotian/CelestialFlow/issues"
37
+
38
+ [project.scripts]
39
+ celestialflow-web = "celestialflow.web.core_server:main_entry"
40
+
41
+ [tool.setuptools]
42
+ license-files = []
43
+
44
+ [tool.setuptools.package-data]
45
+ celestialflow = [
46
+ "web/templates/**/*.html",
47
+ "web/static/**/*",
48
+ "web/config.json"
49
+ ]
50
+
51
+ [tool.pytest.ini_options]
52
+ addopts = "-s"
53
+ log_cli = true
54
+ log_cli_level = "INFO"
55
+ log_cli_format = "%(asctime)s [%(levelname)s] %(message)s"
56
+ log_cli_date_format = "%Y-%m-%d %H:%M:%S"
57
+
58
+ filterwarnings = [
59
+ "ignore::DeprecationWarning",
60
+ "ignore::pytest.PytestDeprecationWarning",
61
+ ]
62
+
63
+ asyncio_default_fixture_loop_scope = "function"
64
+
65
+ [dependency-groups]
66
+ dev = [
67
+ "build>=1.2.2.post1",
68
+ "twine>=6.1.0",
69
+ "pytest>=8.3.4",
70
+ "pytest-asyncio>=0.25.3",
71
+ "httpx>=0.28.1",
72
+ "python-dotenv>=1.2.2",
73
+ "dill",
74
+ "mypy>=1.19.1",
75
+ "ruff",
76
+ ]
77
+
78
+ [tool.mypy]
79
+ python_version = "3.10"
80
+ no_implicit_optional = false
81
+ disable_error_code = ["import-untyped"]
@@ -0,0 +1,22 @@
1
+ # funnel/core_inlet.py
2
+ from __future__ import annotations
3
+
4
+ from typing import Any
5
+
6
+
7
+ class BaseInlet:
8
+ """数据收集器基类,负责将记录通过队列发送到对应的监听器。"""
9
+
10
+ def __init__(self, queue: Any) -> None:
11
+ """初始化收集器
12
+
13
+ :param queue: 记录队列
14
+ """
15
+ self.queue: Any = queue
16
+
17
+ def _funnel(self, record: Any) -> None:
18
+ """将记录放入队列
19
+
20
+ :param record: 待发送的记录
21
+ """
22
+ self.queue.put(record)
@@ -11,7 +11,10 @@ from ..runtime.util_types import TERMINATION_SIGNAL, TerminationSignal
11
11
 
12
12
 
13
13
  class BaseSpout:
14
+ """数据监听器基类,在独立后台线程中消费队列记录。"""
15
+
14
16
  def __init__(self) -> None:
17
+ """初始化监听器及其内部队列和线程引用。"""
15
18
  self.queue: Any = MPQueue()
16
19
  self._thread: Thread | None = None
17
20
 
@@ -25,6 +28,7 @@ class BaseSpout:
25
28
  return None
26
29
 
27
30
  def start(self) -> None:
31
+ """启动后台监听线程(若未运行)。"""
28
32
  self._before_start()
29
33
  if self._thread is None or not self._thread.is_alive():
30
34
  self._thread = Thread(target=self._spout, daemon=True)
@@ -39,11 +43,15 @@ class BaseSpout:
39
43
  self._handle_record(record)
40
44
  except Empty:
41
45
  continue
46
+ except Exception: # ← 新增:防止线程崩溃
47
+ continue # 或记录到 stderr,至少不丢后续记录
42
48
 
43
49
  def get_queue(self) -> MPQueue:
50
+ """获取监听器的输入队列。"""
44
51
  return self.queue
45
52
 
46
53
  def stop(self) -> None:
54
+ """发送终止信号并等待后台线程结束。"""
47
55
  if self._thread is None:
48
56
  return
49
57