celestialflow 3.1.6__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 (101) hide show
  1. {celestialflow-3.1.6 → celestialflow-3.1.8}/PKG-INFO +74 -52
  2. {celestialflow-3.1.6 → celestialflow-3.1.8}/README.md +73 -51
  3. {celestialflow-3.1.6 → celestialflow-3.1.8}/pyproject.toml +2 -1
  4. celestialflow-3.1.8/src/celestialflow/funnel/__init__.py +8 -0
  5. celestialflow-3.1.8/src/celestialflow/funnel/core_inlet.py +22 -0
  6. celestialflow-3.1.6/src/celestialflow/persistence/core_base.py → celestialflow-3.1.8/src/celestialflow/funnel/core_spout.py +12 -12
  7. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/graph/core_graph.py +443 -274
  8. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/graph/core_structure.py +75 -46
  9. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/graph/util_analysis.py +5 -0
  10. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/graph/util_serialize.py +59 -17
  11. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/observability/__init__.py +3 -0
  12. {celestialflow-3.1.6/src/celestialflow/runtime → celestialflow-3.1.8/src/celestialflow/observability}/core_progress.py +34 -7
  13. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/observability/core_report.py +38 -20
  14. celestialflow-3.1.8/src/celestialflow/persistence/__init__.py +12 -0
  15. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/persistence/core_fail.py +43 -11
  16. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/persistence/core_log.py +125 -70
  17. celestialflow-3.1.8/src/celestialflow/persistence/core_success.py +42 -0
  18. celestialflow-3.1.8/src/celestialflow/persistence/util_jsonl.py +183 -0
  19. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/runtime/__init__.py +2 -5
  20. celestialflow-3.1.8/src/celestialflow/runtime/core_dispatch.py +226 -0
  21. celestialflow-3.1.8/src/celestialflow/runtime/core_envelope.py +56 -0
  22. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/runtime/core_metrics.py +31 -74
  23. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/runtime/core_queue.py +29 -77
  24. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/runtime/util_errors.py +49 -2
  25. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/runtime/util_estimators.py +11 -0
  26. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/runtime/util_factories.py +36 -12
  27. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/runtime/util_hash.py +3 -0
  28. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/runtime/util_types.py +40 -7
  29. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/stage/core_executor.py +212 -293
  30. celestialflow-3.1.8/src/celestialflow/stage/core_stage.py +220 -0
  31. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/stage/core_stages.py +126 -52
  32. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/utils/util_benchmark.py +18 -9
  33. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/utils/util_clone.py +29 -26
  34. celestialflow-3.1.8/src/celestialflow/utils/util_debug.py +16 -0
  35. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/utils/util_format.py +4 -0
  36. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/core_server.py +98 -16
  37. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/js/task_statuses.js +92 -92
  38. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/js/task_structure.js +130 -130
  39. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/js/task_summary.js +49 -49
  40. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/js/utils.js +268 -234
  41. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/ts/task_errors.ts +34 -0
  42. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/ts/task_statuses.ts +6 -6
  43. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/ts/task_structure.ts +1 -1
  44. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/ts/task_summary.ts +59 -59
  45. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/ts/utils.ts +56 -7
  46. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/templates/index.html +1 -1
  47. celestialflow-3.1.8/src/celestialflow/web/util_cal.py +9 -0
  48. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/util_config.py +13 -2
  49. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/util_error.py +16 -0
  50. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow.egg-info/PKG-INFO +74 -52
  51. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow.egg-info/SOURCES.txt +11 -5
  52. celestialflow-3.1.8/tests/test_envelope.py +45 -0
  53. celestialflow-3.1.8/tests/test_executor.py +222 -0
  54. celestialflow-3.1.8/tests/test_graph.py +418 -0
  55. celestialflow-3.1.8/tests/test_metrics.py +119 -0
  56. celestialflow-3.1.8/tests/test_queue.py +141 -0
  57. celestialflow-3.1.8/tests/test_stage.py +106 -0
  58. celestialflow-3.1.6/src/celestialflow/persistence/__init__.py +0 -13
  59. celestialflow-3.1.6/src/celestialflow/persistence/util_jsonl.py +0 -132
  60. celestialflow-3.1.6/src/celestialflow/runtime/core_envelope.py +0 -43
  61. celestialflow-3.1.6/src/celestialflow/runtime/core_runner.py +0 -293
  62. celestialflow-3.1.6/src/celestialflow/stage/core_stage.py +0 -259
  63. celestialflow-3.1.6/src/celestialflow/utils/util_debug.py +0 -10
  64. celestialflow-3.1.6/src/celestialflow/web/util_cal.py +0 -4
  65. celestialflow-3.1.6/tests/test_executor.py +0 -70
  66. celestialflow-3.1.6/tests/test_stages.py +0 -312
  67. celestialflow-3.1.6/tests/test_structure.py +0 -281
  68. {celestialflow-3.1.6 → celestialflow-3.1.8}/setup.cfg +0 -0
  69. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/__init__.py +0 -0
  70. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/graph/__init__.py +0 -0
  71. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/persistence/util_constant.py +0 -0
  72. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/runtime/util_queue.py +0 -0
  73. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/stage/__init__.py +0 -0
  74. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/utils/__init__.py +0 -0
  75. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/utils/util_collections.py +0 -0
  76. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/config.json +0 -0
  77. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/css/_colors.css +0 -0
  78. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/css/base.css +0 -0
  79. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/css/dashboard.css +0 -0
  80. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/css/errors.css +0 -0
  81. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/css/inject.css +0 -0
  82. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/favicon.ico +0 -0
  83. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/js/main.js +0 -0
  84. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/js/task_analysis.js +0 -0
  85. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/js/task_config.js +0 -0
  86. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/js/task_errors.js +0 -0
  87. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/js/task_history.js +0 -0
  88. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/js/task_injection.js +0 -0
  89. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/js/task_topology.js +0 -0
  90. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/js/web_config.js +0 -0
  91. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/ts/globals.d.ts +0 -0
  92. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/ts/main.ts +0 -0
  93. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/ts/task_analysis.ts +0 -0
  94. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/ts/task_history.ts +0 -0
  95. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/ts/task_injection.ts +0 -0
  96. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow/web/static/ts/web_config.ts +0 -0
  97. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow.egg-info/dependency_links.txt +0 -0
  98. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow.egg-info/entry_points.txt +0 -0
  99. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow.egg-info/requires.txt +0 -0
  100. {celestialflow-3.1.6 → celestialflow-3.1.8}/src/celestialflow.egg-info/top_level.txt +0 -0
  101. {celestialflow-3.1.6 → 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.6
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,16 +43,19 @@ 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 更轻、更快开始
49
53
  - 相比 multiprocessing/threading 更结构化,可直接表达 loop / complete graph 等复杂依赖模式
50
54
 
51
- 框架的基本单元为 **TaskExecutor**,可独立运行,并支持四种执行模式:
55
+ 框架的基本单元为 **TaskExecutor**,可独立运行,并支持三种执行模式:
52
56
 
53
57
  * **线性(serial)**
54
58
  * **多线程(thread)**
55
- * **多进程(process)**
56
59
  * **协程(async)**
57
60
 
58
61
  TaskExecutor 实现了对任务的结果缓存,任务去重,进度条显示,多执行模式比较等功能,单独使用也很好用。
@@ -64,9 +67,10 @@ TaskStage 的任务执行模式只有两种:
64
67
  * **线性(serial)**
65
68
  * **多线程(thread)**
66
69
 
67
- 在图级别上,每个 Stage 支持两种上下文模式:
70
+ 在图级别上,每个 Stage 支持三种上下文模式:
68
71
 
69
72
  * **线性执行(serial layout)**:当前节点执行完毕再启动下一节点(下游节点可提前接收任务但不会立即执行)。
73
+ * **线程执行(thread layout)**:当前节点在主进程的独立线程中启动,适合 I/O 密集型任务和不可 pickle 的函数(如 lambda)。
70
74
  * **并行执行(process layout)**:当前节点启动后立刻前去启动下一节点。
71
75
 
72
76
  TaskGraph 能构建完整的 **有向图结构(Directed Graph)**,不仅支持传统的有向无环图(DAG),也能灵活表达 **树形(Tree)**、**环形(loop)** 乃至于 **完全图(Complete Graph)** 形式的任务依赖。
@@ -133,7 +137,7 @@ flowchart LR
133
137
  uv pip install celestialflow
134
138
 
135
139
  # 不过也可以直接使用 `pip`
136
- uv pip install celestialflow
140
+ pip install celestialflow
137
141
  ```
138
142
 
139
143
  一个简单的可运行代码:
@@ -153,9 +157,12 @@ if __name__ == "__main__":
153
157
  stage2 = TaskStage(square, execution_mode="thread")
154
158
 
155
159
  # 构建任务图结构
156
- stage1.set_graph_context([stage2], stage_mode="process", stage_name="Adder")
157
- stage2.set_graph_context([], stage_mode="process", stage_name="Squarer")
158
- 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])
159
166
 
160
167
  # 初始化任务并启动
161
168
  graph.start_graph({stage1.get_tag(): [(1, 2), (3, 4), (5, 6)]})
@@ -163,29 +170,23 @@ if __name__ == "__main__":
163
170
 
164
171
  注意不要在.ipynb中运行。
165
172
 
166
- 👉 想查看完整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)
167
174
 
168
175
  ## 深入阅读(Further Reading)
169
176
 
170
- (以下文档完善中)
171
-
172
- 你可以继续运行更多的测试代码,这里记录了各个测试文件与其中的测试函数说明:
173
-
174
- [📄tests/README.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/tests/README.md)
175
-
176
177
  若你想了解框架的整体结构与核心组件,下面的参考文档会对你有帮助:
177
178
 
178
- - [stage/executor.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/stage/executor.md)
179
- - [stage/stage.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/stage/stage.md)
180
- - [graph/graph.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/graph/graph.md)
181
- - [runtime/progress.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/progress.md)
182
- - [runtime/metrics.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/metrics.md)
183
- - [runtime/queue.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/queue.md)
184
- - [stage/nodes.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/stage/nodes.md)
185
- - [observability/report.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/observability/report.md)
186
- - [graph/structure.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/graph/structure.md)
187
- - [web/server.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/web/server.md)
188
- - [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)
189
190
 
190
191
  推荐阅读顺序:
191
192
 
@@ -202,7 +203,7 @@ flowchart TD
202
203
  TM --> TME[TaskMetrics.md]
203
204
 
204
205
  TG --> TQ[TaskQueue.md]
205
- TG --> TN[TaskNodes.md]
206
+ TG --> TN[TaskStages.md]
206
207
  TG --> TR[TaskReport.md]
207
208
  TG --> TSR[TaskStructure.md]
208
209
 
@@ -218,23 +219,35 @@ flowchart TD
218
219
 
219
220
  以下三篇可以作为补充阅读:
220
221
 
221
- - [runtime/tools.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/tools.md)
222
- - [runtime/types.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/types.md)
223
- - [runtime/errors.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/errors.md)
224
- - [persistence/fail.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/persistence/fail.md)
225
- - [persistence/log.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/persistence/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)
226
227
 
227
- 如果你更喜欢通过完整案例理解框架的运行方式,可以参考这篇从零开始构建 TaskGraph 的教程:
228
+ 如果你更喜欢通过完整案例理解框架的运行方式,可以参考这篇利用 TaskGraph 从零开始构建项目的教程:
228
229
 
229
- [📘案例教程](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)
230
231
 
231
232
  如果你对3.0.7版本加入的ctree_client与其功能感兴趣, 可以看看这一篇:
232
233
 
233
- [📚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/)
234
247
 
235
248
  ## 环境要求(Requirements)
236
249
 
237
- **CelestialFlow** 基于 Python 3.8+,并依赖以下核心组件。
250
+ **CelestialFlow** 基于 Python 3.10+,并依赖以下核心组件。
238
251
  请确保你的环境能够正常安装这些依赖(`pip install celestialflow` 会自动安装)。
239
252
 
240
253
  | 依赖包 | 说明 |
@@ -254,27 +267,36 @@ flowchart TD
254
267
  <p align="center">
255
268
  <img src="https://raw.githubusercontent.com/Mr-xiaotian/CelestialFlow/main/img/file_structure.svg" alt="FileStructure" />
256
269
  <br/>
257
- <em>celestial-flow 3.1.6</em>
270
+ <em>celestial-flow 3.1.8</em>
258
271
  </p>
259
272
 
260
273
  (该视图由我的另一个项目[CelestialVault](https://github.com/Mr-xiaotian/CelestialVault)中inst_file.FileTree.print_tree()生成。转换为图片则借助[Carbon](https://carbon.now.sh)。)
261
274
 
262
275
  ## 版本日志(Version Log)
263
- - 3.1.6
264
- - feat
265
- - 前端现在只储存一页的error数据, 有效减少了运行大规模任务时前端内存飙升的问题;
266
- - 优化任务数显示, 大于1*10^7时显示科学计数法, 否则显示英式计数;
267
- - 优化小屏模式下表格的显示: 改为用卡片式显示;
268
- - 在error表格中加入index项;
269
- - 大幅调整任务颜色分配, 现在重复任务使用黄色系, 等待任务使用灰色系;
270
- - 将节点卡片中的已消耗时间颜色拟合为下方进度条颜色;
271
- - refactor
272
- - 用mypy整理了一遍类型标注;
273
- - 删除与整合部分css代码;
274
- - 将字体等适合rem单位的地方全部从px替换为rem, 并且都部分size进行统一;
275
- - fix
276
- - 修复总体剩余时间在特殊情况下显示0的问题(这玩意真麻烦);
277
- - 修复部分小屏下的显示问题, 但折线图不显示的问题不太好解决;
276
+ - 3.1.8
277
+ - feat:
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实测结果;
281
+ - refactor:
282
+ - [Important] 删除stage.set_stage_context, 改用graph.connect;
283
+ - 接口破坏性重构, 需要修改大量graph相关代码;
284
+ - [Important] name作为第一位参数在stage/executor中强制设定;
285
+ - 接口破坏性重构
286
+ - 优化async的executor_mode, 使其同时获取与消费任务, 而非集中消费;
287
+ - 为上版本retry机制的重构收尾;
288
+ - fix:
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 )
278
300
 
279
301
  ## Star 历史趋势(Star History)
280
302
 
@@ -18,16 +18,19 @@
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 更轻、更快开始
24
28
  - 相比 multiprocessing/threading 更结构化,可直接表达 loop / complete graph 等复杂依赖模式
25
29
 
26
- 框架的基本单元为 **TaskExecutor**,可独立运行,并支持四种执行模式:
30
+ 框架的基本单元为 **TaskExecutor**,可独立运行,并支持三种执行模式:
27
31
 
28
32
  * **线性(serial)**
29
33
  * **多线程(thread)**
30
- * **多进程(process)**
31
34
  * **协程(async)**
32
35
 
33
36
  TaskExecutor 实现了对任务的结果缓存,任务去重,进度条显示,多执行模式比较等功能,单独使用也很好用。
@@ -39,9 +42,10 @@ TaskStage 的任务执行模式只有两种:
39
42
  * **线性(serial)**
40
43
  * **多线程(thread)**
41
44
 
42
- 在图级别上,每个 Stage 支持两种上下文模式:
45
+ 在图级别上,每个 Stage 支持三种上下文模式:
43
46
 
44
47
  * **线性执行(serial layout)**:当前节点执行完毕再启动下一节点(下游节点可提前接收任务但不会立即执行)。
48
+ * **线程执行(thread layout)**:当前节点在主进程的独立线程中启动,适合 I/O 密集型任务和不可 pickle 的函数(如 lambda)。
45
49
  * **并行执行(process layout)**:当前节点启动后立刻前去启动下一节点。
46
50
 
47
51
  TaskGraph 能构建完整的 **有向图结构(Directed Graph)**,不仅支持传统的有向无环图(DAG),也能灵活表达 **树形(Tree)**、**环形(loop)** 乃至于 **完全图(Complete Graph)** 形式的任务依赖。
@@ -108,7 +112,7 @@ flowchart LR
108
112
  uv pip install celestialflow
109
113
 
110
114
  # 不过也可以直接使用 `pip`
111
- uv pip install celestialflow
115
+ pip install celestialflow
112
116
  ```
113
117
 
114
118
  一个简单的可运行代码:
@@ -128,9 +132,12 @@ if __name__ == "__main__":
128
132
  stage2 = TaskStage(square, execution_mode="thread")
129
133
 
130
134
  # 构建任务图结构
131
- stage1.set_graph_context([stage2], stage_mode="process", stage_name="Adder")
132
- stage2.set_graph_context([], stage_mode="process", stage_name="Squarer")
133
- 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])
134
141
 
135
142
  # 初始化任务并启动
136
143
  graph.start_graph({stage1.get_tag(): [(1, 2), (3, 4), (5, 6)]})
@@ -138,29 +145,23 @@ if __name__ == "__main__":
138
145
 
139
146
  注意不要在.ipynb中运行。
140
147
 
141
- 👉 想查看完整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)
142
149
 
143
150
  ## 深入阅读(Further Reading)
144
151
 
145
- (以下文档完善中)
146
-
147
- 你可以继续运行更多的测试代码,这里记录了各个测试文件与其中的测试函数说明:
148
-
149
- [📄tests/README.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/tests/README.md)
150
-
151
152
  若你想了解框架的整体结构与核心组件,下面的参考文档会对你有帮助:
152
153
 
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)
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)
164
165
 
165
166
  推荐阅读顺序:
166
167
 
@@ -177,7 +178,7 @@ flowchart TD
177
178
  TM --> TME[TaskMetrics.md]
178
179
 
179
180
  TG --> TQ[TaskQueue.md]
180
- TG --> TN[TaskNodes.md]
181
+ TG --> TN[TaskStages.md]
181
182
  TG --> TR[TaskReport.md]
182
183
  TG --> TSR[TaskStructure.md]
183
184
 
@@ -193,23 +194,35 @@ flowchart TD
193
194
 
194
195
  以下三篇可以作为补充阅读:
195
196
 
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)
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)
201
202
 
202
- 如果你更喜欢通过完整案例理解框架的运行方式,可以参考这篇从零开始构建 TaskGraph 的教程:
203
+ 如果你更喜欢通过完整案例理解框架的运行方式,可以参考这篇利用 TaskGraph 从零开始构建项目的教程:
203
204
 
204
- [📘案例教程](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)
205
206
 
206
207
  如果你对3.0.7版本加入的ctree_client与其功能感兴趣, 可以看看这一篇:
207
208
 
208
- [📚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/)
209
222
 
210
223
  ## 环境要求(Requirements)
211
224
 
212
- **CelestialFlow** 基于 Python 3.8+,并依赖以下核心组件。
225
+ **CelestialFlow** 基于 Python 3.10+,并依赖以下核心组件。
213
226
  请确保你的环境能够正常安装这些依赖(`pip install celestialflow` 会自动安装)。
214
227
 
215
228
  | 依赖包 | 说明 |
@@ -229,27 +242,36 @@ flowchart TD
229
242
  <p align="center">
230
243
  <img src="https://raw.githubusercontent.com/Mr-xiaotian/CelestialFlow/main/img/file_structure.svg" alt="FileStructure" />
231
244
  <br/>
232
- <em>celestial-flow 3.1.6</em>
245
+ <em>celestial-flow 3.1.8</em>
233
246
  </p>
234
247
 
235
248
  (该视图由我的另一个项目[CelestialVault](https://github.com/Mr-xiaotian/CelestialVault)中inst_file.FileTree.print_tree()生成。转换为图片则借助[Carbon](https://carbon.now.sh)。)
236
249
 
237
250
  ## 版本日志(Version Log)
238
- - 3.1.6
239
- - feat
240
- - 前端现在只储存一页的error数据, 有效减少了运行大规模任务时前端内存飙升的问题;
241
- - 优化任务数显示, 大于1*10^7时显示科学计数法, 否则显示英式计数;
242
- - 优化小屏模式下表格的显示: 改为用卡片式显示;
243
- - 在error表格中加入index项;
244
- - 大幅调整任务颜色分配, 现在重复任务使用黄色系, 等待任务使用灰色系;
245
- - 将节点卡片中的已消耗时间颜色拟合为下方进度条颜色;
246
- - refactor
247
- - 用mypy整理了一遍类型标注;
248
- - 删除与整合部分css代码;
249
- - 将字体等适合rem单位的地方全部从px替换为rem, 并且都部分size进行统一;
250
- - fix
251
- - 修复总体剩余时间在特殊情况下显示0的问题(这玩意真麻烦);
252
- - 修复部分小屏下的显示问题, 但折线图不显示的问题不太好解决;
251
+ - 3.1.8
252
+ - feat:
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实测结果;
256
+ - refactor:
257
+ - [Important] 删除stage.set_stage_context, 改用graph.connect;
258
+ - 接口破坏性重构, 需要修改大量graph相关代码;
259
+ - [Important] name作为第一位参数在stage/executor中强制设定;
260
+ - 接口破坏性重构
261
+ - 优化async的executor_mode, 使其同时获取与消费任务, 而非集中消费;
262
+ - 为上版本retry机制的重构收尾;
263
+ - fix:
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 )
253
275
 
254
276
  ## Star 历史趋势(Star History)
255
277
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "celestialflow"
7
- version = "3.1.6"
7
+ version = "3.1.8"
8
8
  description = "A flexible GRAPH-based task orchestration framework."
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
@@ -72,6 +72,7 @@ dev = [
72
72
  "python-dotenv>=1.2.2",
73
73
  "dill",
74
74
  "mypy>=1.19.1",
75
+ "ruff",
75
76
  ]
76
77
 
77
78
  [tool.mypy]
@@ -0,0 +1,8 @@
1
+ # funnel/__init__.py
2
+ from .core_spout import BaseSpout
3
+ from .core_inlet import BaseInlet
4
+
5
+ __all__ = [
6
+ "BaseSpout",
7
+ "BaseInlet",
8
+ ]
@@ -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)
@@ -1,4 +1,4 @@
1
- # persistence/core_base.py
1
+ # funnel/core_spout.py
2
2
  from __future__ import annotations
3
3
 
4
4
  from multiprocessing import Queue as MPQueue
@@ -10,8 +10,11 @@ from ..runtime.util_queue import cleanup_mpqueue
10
10
  from ..runtime.util_types import TERMINATION_SIGNAL, TerminationSignal
11
11
 
12
12
 
13
- class BaseListener:
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,12 +28,13 @@ class BaseListener:
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
- self._thread = Thread(target=self._listen, daemon=True)
34
+ self._thread = Thread(target=self._spout, daemon=True)
31
35
  self._thread.start()
32
36
 
33
- def _listen(self) -> None:
37
+ def _spout(self) -> None:
34
38
  while True:
35
39
  try:
36
40
  record = self.queue.get(timeout=0.5)
@@ -39,11 +43,15 @@ class BaseListener:
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
 
@@ -52,11 +60,3 @@ class BaseListener:
52
60
  self._thread = None
53
61
  cleanup_mpqueue(self.queue)
54
62
  self._after_stop()
55
-
56
-
57
- class BaseSinker:
58
- def __init__(self, queue: Any) -> None:
59
- self.queue: Any = queue
60
-
61
- def _sink(self, record: Any) -> None:
62
- self.queue.put(record)