celestialflow 3.1.7__tar.gz → 3.1.9__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.
- {celestialflow-3.1.7 → celestialflow-3.1.9}/PKG-INFO +68 -51
- {celestialflow-3.1.7 → celestialflow-3.1.9}/README.md +67 -50
- {celestialflow-3.1.7 → celestialflow-3.1.9}/pyproject.toml +81 -81
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/__init__.py +5 -1
- celestialflow-3.1.9/src/celestialflow/funnel/core_inlet.py +22 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/funnel/core_spout.py +8 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/graph/core_graph.py +406 -235
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/graph/core_structure.py +75 -46
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/graph/util_analysis.py +5 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/graph/util_serialize.py +53 -11
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/observability/__init__.py +4 -2
- celestialflow-3.1.9/src/celestialflow/observability/core_observer.py +26 -0
- celestialflow-3.1.9/src/celestialflow/observability/core_progress.py +30 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/observability/core_report.py +54 -29
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/persistence/__init__.py +2 -2
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/persistence/core_fail.py +27 -2
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/persistence/core_log.py +116 -66
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/persistence/core_success.py +7 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/persistence/util_jsonl.py +13 -4
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/runtime/core_dispatch.py +70 -88
- celestialflow-3.1.9/src/celestialflow/runtime/core_envelope.py +58 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/runtime/core_metrics.py +21 -34
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/runtime/core_queue.py +25 -70
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/runtime/util_errors.py +48 -1
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/runtime/util_estimators.py +11 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/runtime/util_factories.py +34 -10
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/runtime/util_hash.py +3 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/runtime/util_types.py +40 -7
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/stage/core_executor.py +150 -187
- celestialflow-3.1.9/src/celestialflow/stage/core_stage.py +210 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/stage/core_stages.py +117 -37
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/utils/util_benchmark.py +17 -8
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/utils/util_clone.py +27 -27
- celestialflow-3.1.9/src/celestialflow/utils/util_debug.py +16 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/utils/util_format.py +4 -0
- celestialflow-3.1.9/src/celestialflow/web/__init__.py +6 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/config.json +1 -1
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/core_server.py +110 -16
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/js/task_errors.js +34 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/js/task_statuses.js +3 -3
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/js/task_structure.js +1 -1
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/js/task_summary.js +3 -3
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/js/utils.js +269 -268
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/ts/task_errors.ts +34 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/ts/task_statuses.ts +6 -6
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/ts/task_structure.ts +1 -1
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/ts/task_summary.ts +59 -59
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/ts/utils.ts +3 -2
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/templates/index.html +1 -1
- celestialflow-3.1.9/src/celestialflow/web/util_cal.py +9 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/util_config.py +13 -2
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/util_error.py +16 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow.egg-info/PKG-INFO +68 -51
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow.egg-info/SOURCES.txt +7 -2
- celestialflow-3.1.9/tests/test_envelope.py +51 -0
- celestialflow-3.1.9/tests/test_executor.py +382 -0
- celestialflow-3.1.9/tests/test_graph.py +579 -0
- celestialflow-3.1.9/tests/test_metrics.py +119 -0
- celestialflow-3.1.9/tests/test_queue.py +149 -0
- celestialflow-3.1.9/tests/test_stage.py +120 -0
- celestialflow-3.1.7/src/celestialflow/funnel/core_inlet.py +0 -12
- celestialflow-3.1.7/src/celestialflow/observability/core_progress.py +0 -66
- celestialflow-3.1.7/src/celestialflow/runtime/core_envelope.py +0 -47
- celestialflow-3.1.7/src/celestialflow/stage/core_stage.py +0 -259
- celestialflow-3.1.7/src/celestialflow/utils/util_debug.py +0 -10
- celestialflow-3.1.7/src/celestialflow/web/util_cal.py +0 -4
- celestialflow-3.1.7/tests/test_executor.py +0 -54
- celestialflow-3.1.7/tests/test_stages.py +0 -312
- celestialflow-3.1.7/tests/test_structure.py +0 -281
- {celestialflow-3.1.7 → celestialflow-3.1.9}/setup.cfg +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/funnel/__init__.py +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/graph/__init__.py +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/persistence/util_constant.py +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/runtime/__init__.py +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/runtime/util_queue.py +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/stage/__init__.py +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/utils/__init__.py +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/utils/util_collections.py +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/css/_colors.css +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/css/base.css +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/css/dashboard.css +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/css/errors.css +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/css/inject.css +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/favicon.ico +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/js/main.js +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/js/task_analysis.js +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/js/task_config.js +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/js/task_history.js +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/js/task_injection.js +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/js/task_topology.js +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/js/web_config.js +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/ts/globals.d.ts +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/ts/main.ts +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/ts/task_analysis.ts +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/ts/task_history.ts +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/ts/task_injection.ts +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow/web/static/ts/web_config.ts +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow.egg-info/dependency_links.txt +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow.egg-info/entry_points.txt +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow.egg-info/requires.txt +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/src/celestialflow.egg-info/top_level.txt +0 -0
- {celestialflow-3.1.7 → celestialflow-3.1.9}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: celestialflow
|
|
3
|
-
Version: 3.1.
|
|
3
|
+
Version: 3.1.9
|
|
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 更轻、更快开始
|
|
@@ -58,14 +62,12 @@ TaskExecutor 实现了对任务的结果缓存,任务去重,进度条显示
|
|
|
58
62
|
|
|
59
63
|
但除去直接使用 TaskExecutor,更重要的是使用其子类**TaskStage**。TaskStage 可以互相连接,形成具有上游与下游依赖关系的任务图(**TaskGraph**)。下游 stage 会自动接收上游执行完成的结果作为输入,从而形成明确的数据流。
|
|
60
64
|
|
|
61
|
-
TaskStage
|
|
62
|
-
|
|
63
|
-
* **线性(serial)**
|
|
64
|
-
* **多线程(thread)**
|
|
65
|
+
TaskStage 的任务执行模式同样包含三种,与TaskExecutor中一致。
|
|
65
66
|
|
|
66
|
-
在图级别上,每个 Stage
|
|
67
|
+
在图级别上,每个 Stage 支持三种上下文模式:
|
|
67
68
|
|
|
68
69
|
* **线性执行(serial layout)**:当前节点执行完毕再启动下一节点(下游节点可提前接收任务但不会立即执行)。
|
|
70
|
+
* **线程执行(thread layout)**:当前节点在主进程的独立线程中启动,适合 I/O 密集型任务和不可 pickle 的函数(如 lambda)。
|
|
69
71
|
* **并行执行(process layout)**:当前节点启动后立刻前去启动下一节点。
|
|
70
72
|
|
|
71
73
|
TaskGraph 能构建完整的 **有向图结构(Directed Graph)**,不仅支持传统的有向无环图(DAG),也能灵活表达 **树形(Tree)**、**环形(loop)** 乃至于 **完全图(Complete Graph)** 形式的任务依赖。
|
|
@@ -148,13 +150,13 @@ def square(x):
|
|
|
148
150
|
|
|
149
151
|
if __name__ == "__main__":
|
|
150
152
|
# 定义两个任务节点
|
|
151
|
-
stage1 = TaskStage(add, execution_mode="thread", unpack_task_args=True)
|
|
152
|
-
stage2 = TaskStage(square, execution_mode="thread")
|
|
153
|
+
stage1 = TaskStage(name="Adder", func=add, execution_mode="thread", unpack_task_args=True, stage_mode="process")
|
|
154
|
+
stage2 = TaskStage(name="Squarer"func=square, execution_mode="thread", stage_mode="process")
|
|
153
155
|
|
|
154
156
|
# 构建任务图结构
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
graph
|
|
157
|
+
graph = TaskGraph()
|
|
158
|
+
graph.set_stages(root_stages=[stage1], stages=[stage2])
|
|
159
|
+
graph.connect([stage1], [stage2])
|
|
158
160
|
|
|
159
161
|
# 初始化任务并启动
|
|
160
162
|
graph.start_graph({stage1.get_tag(): [(1, 2), (3, 4), (5, 6)]})
|
|
@@ -162,29 +164,23 @@ if __name__ == "__main__":
|
|
|
162
164
|
|
|
163
165
|
注意不要在.ipynb中运行。
|
|
164
166
|
|
|
165
|
-
👉 想查看完整Quick Start,请见[Quick Start](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/quick_start.md)
|
|
167
|
+
👉 想查看完整Quick Start,请见[Quick Start](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/quick_start.md)
|
|
166
168
|
|
|
167
169
|
## 深入阅读(Further Reading)
|
|
168
170
|
|
|
169
|
-
(以下文档完善中)
|
|
170
|
-
|
|
171
|
-
你可以继续运行更多的测试代码,这里记录了各个测试文件与其中的测试函数说明:
|
|
172
|
-
|
|
173
|
-
[📄tests/README.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/tests/README.md)
|
|
174
|
-
|
|
175
171
|
若你想了解框架的整体结构与核心组件,下面的参考文档会对你有帮助:
|
|
176
172
|
|
|
177
|
-
- [stage/core_executor.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
178
|
-
- [stage/core_stage.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
179
|
-
- [graph/core_graph.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
180
|
-
- [observability/core_progress.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
181
|
-
- [runtime/core_metrics.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
182
|
-
- [runtime/core_queue.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
183
|
-
- [stage/core_stages.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
184
|
-
- [observability/core_report.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
185
|
-
- [graph/core_structure.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
186
|
-
- [web/core_server.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
187
|
-
- [other/go_worker.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
173
|
+
- [stage/core_executor.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/stage/core_executor.md)
|
|
174
|
+
- [stage/core_stage.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/stage/core_stage.md)
|
|
175
|
+
- [graph/core_graph.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/graph/core_graph.md)
|
|
176
|
+
- [observability/core_progress.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/observability/core_progress.md)
|
|
177
|
+
- [runtime/core_metrics.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/runtime/core_metrics.md)
|
|
178
|
+
- [runtime/core_queue.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/runtime/core_queue.md)
|
|
179
|
+
- [stage/core_stages.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/stage/core_stages.md)
|
|
180
|
+
- [observability/core_report.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/observability/core_report.md)
|
|
181
|
+
- [graph/core_structure.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/graph/core_structure.md)
|
|
182
|
+
- [web/core_server.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/web/core_server.md)
|
|
183
|
+
- [other/go_worker.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/other/go_worker.md)
|
|
188
184
|
|
|
189
185
|
推荐阅读顺序:
|
|
190
186
|
|
|
@@ -217,19 +213,31 @@ flowchart TD
|
|
|
217
213
|
|
|
218
214
|
以下三篇可以作为补充阅读:
|
|
219
215
|
|
|
220
|
-
- [runtime/util_queue.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
221
|
-
- [runtime/util_types.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
222
|
-
- [runtime/util_errors.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
223
|
-
- [persistence/core_fail.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
224
|
-
- [persistence/core_log.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
216
|
+
- [runtime/util_queue.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/runtime/util_queue.md)
|
|
217
|
+
- [runtime/util_types.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/runtime/util_types.md)
|
|
218
|
+
- [runtime/util_errors.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/runtime/util_errors.md)
|
|
219
|
+
- [persistence/core_fail.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/persistence/core_fail.md)
|
|
220
|
+
- [persistence/core_log.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/persistence/core_log.md)
|
|
225
221
|
|
|
226
|
-
|
|
222
|
+
如果你更喜欢通过完整案例理解框架的运行方式,可以参考这篇利用 TaskGraph 从零开始构建项目的教程:
|
|
227
223
|
|
|
228
|
-
[📘案例教程](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/tutorial.md)
|
|
224
|
+
[📘案例教程](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/tutorial.md)
|
|
229
225
|
|
|
230
226
|
如果你对3.0.7版本加入的ctree_client与其功能感兴趣, 可以看看这一篇:
|
|
231
227
|
|
|
232
|
-
[📚CelestialTreeClient](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
228
|
+
[📚CelestialTreeClient](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/other/ctree_client.md)
|
|
229
|
+
|
|
230
|
+
你可以继续运行更多的演示代码,这里记录了各个演示文件与其中的演示函数说明:
|
|
231
|
+
|
|
232
|
+
[🎮demo/](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/demo/)
|
|
233
|
+
|
|
234
|
+
如果你想运行测试代码, 可以先查看如下文档内容:
|
|
235
|
+
|
|
236
|
+
[🧪tests/](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/tests/)
|
|
237
|
+
|
|
238
|
+
如果你想查看bench内容, 这里的数据成为框架中部分设计的决策依据:
|
|
239
|
+
|
|
240
|
+
[⚡bench/](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/bench/)
|
|
233
241
|
|
|
234
242
|
## 环境要求(Requirements)
|
|
235
243
|
|
|
@@ -239,12 +247,12 @@ flowchart TD
|
|
|
239
247
|
| 依赖包 | 说明 |
|
|
240
248
|
| ----------------- | ---- |
|
|
241
249
|
| **Python ≥ 3.10** | 运行环境,建议使用 3.10 及以上版本 |
|
|
242
|
-
| **tqdm** | 控制台进度条显示,用于任务执行可视化 |
|
|
243
250
|
| **fastapi** | Web 服务接口框架(用于任务可视化与远程控制) |
|
|
244
251
|
| **uvicorn** | FastAPI 的高性能 ASGI 服务器 |
|
|
245
252
|
| **requests** | HTTP 客户端库,用于任务状态上报与远程调用 |
|
|
246
253
|
| **networkx** | 任务图(TaskGraph)结构与依赖分析 |
|
|
247
254
|
| **jinja2** | FastAPI 模板引擎,用于 Web 可视化界面渲染 |
|
|
255
|
+
| **tqdm** | 可选组件,进度条显示,用于任务执行可视化 |
|
|
248
256
|
| **redis** | 可选组件,用于分布式任务通信(`TaskRedis*` 系列模块) |
|
|
249
257
|
| **celestialtree** | 可选组件,用于任务状态上报与远程调用(`ctree_client`) |
|
|
250
258
|
|
|
@@ -253,24 +261,33 @@ flowchart TD
|
|
|
253
261
|
<p align="center">
|
|
254
262
|
<img src="https://raw.githubusercontent.com/Mr-xiaotian/CelestialFlow/main/img/file_structure.svg" alt="FileStructure" />
|
|
255
263
|
<br/>
|
|
256
|
-
<em>celestial-flow 3.1.
|
|
264
|
+
<em>celestial-flow 3.1.9</em>
|
|
257
265
|
</p>
|
|
258
266
|
|
|
259
267
|
(该视图由我的另一个项目[CelestialVault](https://github.com/Mr-xiaotian/CelestialVault)中inst_file.FileTree.print_tree()生成。转换为图片则借助[Carbon](https://carbon.now.sh)。)
|
|
260
268
|
|
|
261
269
|
## 版本日志(Version Log)
|
|
262
|
-
- 3.1.
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
-
|
|
270
|
+
- 3.1.9
|
|
271
|
+
- feat:
|
|
272
|
+
- [Important] 在TaskStage中允许使用 `async` executor_mode;
|
|
273
|
+
- 3.1.8版本中其实已经可以实现, 在3.1.9版本中彻底测试通过;
|
|
274
|
+
- [Important] 创建基类BaseObservor, 现在可以从外界接入自定义Observor来检测运行状况;
|
|
275
|
+
- 同时创建轻量观察者CallbackObserver;
|
|
276
|
+
- 在TaskStage中添加init字段`log_level`, 自此stage init字段集实现对executor init字段集的包含关系, 仅多出`stage_mode`字段;
|
|
277
|
+
- escapeHtml中添加更多替换项;
|
|
278
|
+
- 在dispatch_thread中添加对futures的清理, 避免无用future的堆积;
|
|
279
|
+
- 基于bench\bench_futures_memory.py, 在十万级任务下futures内存开销为177.01 MB, 在定期清理后则为0.48 MB
|
|
280
|
+
- refactor:
|
|
281
|
+
- 重构TaskProgress, 使其继承BaseObservor;
|
|
282
|
+
- 接口破坏性重构, TaskExecutor的show_progress参数已删除, 现在只有显性的add_observer TaskProgress后才会使用progress
|
|
283
|
+
- 具体使用参考demo\demo_executor.py
|
|
284
|
+
- 重构TaskEnvelope, 不再使用wrap与unwrap, 同时hash值惰性求解;
|
|
285
|
+
- chore:
|
|
286
|
+
- 删除部分无用代码以提高代码质量;
|
|
287
|
+
|
|
288
|
+
更多过往日志可看:
|
|
289
|
+
|
|
290
|
+
[change_log.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/runtime/change_log.md )
|
|
274
291
|
|
|
275
292
|
## Star 历史趋势(Star History)
|
|
276
293
|
|
|
@@ -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 更轻、更快开始
|
|
@@ -33,14 +37,12 @@ TaskExecutor 实现了对任务的结果缓存,任务去重,进度条显示
|
|
|
33
37
|
|
|
34
38
|
但除去直接使用 TaskExecutor,更重要的是使用其子类**TaskStage**。TaskStage 可以互相连接,形成具有上游与下游依赖关系的任务图(**TaskGraph**)。下游 stage 会自动接收上游执行完成的结果作为输入,从而形成明确的数据流。
|
|
35
39
|
|
|
36
|
-
TaskStage
|
|
37
|
-
|
|
38
|
-
* **线性(serial)**
|
|
39
|
-
* **多线程(thread)**
|
|
40
|
+
TaskStage 的任务执行模式同样包含三种,与TaskExecutor中一致。
|
|
40
41
|
|
|
41
|
-
在图级别上,每个 Stage
|
|
42
|
+
在图级别上,每个 Stage 支持三种上下文模式:
|
|
42
43
|
|
|
43
44
|
* **线性执行(serial layout)**:当前节点执行完毕再启动下一节点(下游节点可提前接收任务但不会立即执行)。
|
|
45
|
+
* **线程执行(thread layout)**:当前节点在主进程的独立线程中启动,适合 I/O 密集型任务和不可 pickle 的函数(如 lambda)。
|
|
44
46
|
* **并行执行(process layout)**:当前节点启动后立刻前去启动下一节点。
|
|
45
47
|
|
|
46
48
|
TaskGraph 能构建完整的 **有向图结构(Directed Graph)**,不仅支持传统的有向无环图(DAG),也能灵活表达 **树形(Tree)**、**环形(loop)** 乃至于 **完全图(Complete Graph)** 形式的任务依赖。
|
|
@@ -123,13 +125,13 @@ def square(x):
|
|
|
123
125
|
|
|
124
126
|
if __name__ == "__main__":
|
|
125
127
|
# 定义两个任务节点
|
|
126
|
-
stage1 = TaskStage(add, execution_mode="thread", unpack_task_args=True)
|
|
127
|
-
stage2 = TaskStage(square, execution_mode="thread")
|
|
128
|
+
stage1 = TaskStage(name="Adder", func=add, execution_mode="thread", unpack_task_args=True, stage_mode="process")
|
|
129
|
+
stage2 = TaskStage(name="Squarer"func=square, execution_mode="thread", stage_mode="process")
|
|
128
130
|
|
|
129
131
|
# 构建任务图结构
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
graph
|
|
132
|
+
graph = TaskGraph()
|
|
133
|
+
graph.set_stages(root_stages=[stage1], stages=[stage2])
|
|
134
|
+
graph.connect([stage1], [stage2])
|
|
133
135
|
|
|
134
136
|
# 初始化任务并启动
|
|
135
137
|
graph.start_graph({stage1.get_tag(): [(1, 2), (3, 4), (5, 6)]})
|
|
@@ -137,29 +139,23 @@ if __name__ == "__main__":
|
|
|
137
139
|
|
|
138
140
|
注意不要在.ipynb中运行。
|
|
139
141
|
|
|
140
|
-
👉 想查看完整Quick Start,请见[Quick Start](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/quick_start.md)
|
|
142
|
+
👉 想查看完整Quick Start,请见[Quick Start](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/quick_start.md)
|
|
141
143
|
|
|
142
144
|
## 深入阅读(Further Reading)
|
|
143
145
|
|
|
144
|
-
(以下文档完善中)
|
|
145
|
-
|
|
146
|
-
你可以继续运行更多的测试代码,这里记录了各个测试文件与其中的测试函数说明:
|
|
147
|
-
|
|
148
|
-
[📄tests/README.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/tests/README.md)
|
|
149
|
-
|
|
150
146
|
若你想了解框架的整体结构与核心组件,下面的参考文档会对你有帮助:
|
|
151
147
|
|
|
152
|
-
- [stage/core_executor.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
153
|
-
- [stage/core_stage.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
154
|
-
- [graph/core_graph.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
155
|
-
- [observability/core_progress.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
156
|
-
- [runtime/core_metrics.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
157
|
-
- [runtime/core_queue.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
158
|
-
- [stage/core_stages.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
159
|
-
- [observability/core_report.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
160
|
-
- [graph/core_structure.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
161
|
-
- [web/core_server.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
162
|
-
- [other/go_worker.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
148
|
+
- [stage/core_executor.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/stage/core_executor.md)
|
|
149
|
+
- [stage/core_stage.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/stage/core_stage.md)
|
|
150
|
+
- [graph/core_graph.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/graph/core_graph.md)
|
|
151
|
+
- [observability/core_progress.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/observability/core_progress.md)
|
|
152
|
+
- [runtime/core_metrics.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/runtime/core_metrics.md)
|
|
153
|
+
- [runtime/core_queue.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/runtime/core_queue.md)
|
|
154
|
+
- [stage/core_stages.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/stage/core_stages.md)
|
|
155
|
+
- [observability/core_report.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/observability/core_report.md)
|
|
156
|
+
- [graph/core_structure.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/graph/core_structure.md)
|
|
157
|
+
- [web/core_server.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/web/core_server.md)
|
|
158
|
+
- [other/go_worker.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/other/go_worker.md)
|
|
163
159
|
|
|
164
160
|
推荐阅读顺序:
|
|
165
161
|
|
|
@@ -192,19 +188,31 @@ flowchart TD
|
|
|
192
188
|
|
|
193
189
|
以下三篇可以作为补充阅读:
|
|
194
190
|
|
|
195
|
-
- [runtime/util_queue.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
196
|
-
- [runtime/util_types.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
197
|
-
- [runtime/util_errors.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
198
|
-
- [persistence/core_fail.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
199
|
-
- [persistence/core_log.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
191
|
+
- [runtime/util_queue.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/runtime/util_queue.md)
|
|
192
|
+
- [runtime/util_types.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/runtime/util_types.md)
|
|
193
|
+
- [runtime/util_errors.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/runtime/util_errors.md)
|
|
194
|
+
- [persistence/core_fail.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/persistence/core_fail.md)
|
|
195
|
+
- [persistence/core_log.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/persistence/core_log.md)
|
|
200
196
|
|
|
201
|
-
|
|
197
|
+
如果你更喜欢通过完整案例理解框架的运行方式,可以参考这篇利用 TaskGraph 从零开始构建项目的教程:
|
|
202
198
|
|
|
203
|
-
[📘案例教程](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/tutorial.md)
|
|
199
|
+
[📘案例教程](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/tutorial.md)
|
|
204
200
|
|
|
205
201
|
如果你对3.0.7版本加入的ctree_client与其功能感兴趣, 可以看看这一篇:
|
|
206
202
|
|
|
207
|
-
[📚CelestialTreeClient](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/
|
|
203
|
+
[📚CelestialTreeClient](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/other/ctree_client.md)
|
|
204
|
+
|
|
205
|
+
你可以继续运行更多的演示代码,这里记录了各个演示文件与其中的演示函数说明:
|
|
206
|
+
|
|
207
|
+
[🎮demo/](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/demo/)
|
|
208
|
+
|
|
209
|
+
如果你想运行测试代码, 可以先查看如下文档内容:
|
|
210
|
+
|
|
211
|
+
[🧪tests/](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/tests/)
|
|
212
|
+
|
|
213
|
+
如果你想查看bench内容, 这里的数据成为框架中部分设计的决策依据:
|
|
214
|
+
|
|
215
|
+
[⚡bench/](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/bench/)
|
|
208
216
|
|
|
209
217
|
## 环境要求(Requirements)
|
|
210
218
|
|
|
@@ -214,12 +222,12 @@ flowchart TD
|
|
|
214
222
|
| 依赖包 | 说明 |
|
|
215
223
|
| ----------------- | ---- |
|
|
216
224
|
| **Python ≥ 3.10** | 运行环境,建议使用 3.10 及以上版本 |
|
|
217
|
-
| **tqdm** | 控制台进度条显示,用于任务执行可视化 |
|
|
218
225
|
| **fastapi** | Web 服务接口框架(用于任务可视化与远程控制) |
|
|
219
226
|
| **uvicorn** | FastAPI 的高性能 ASGI 服务器 |
|
|
220
227
|
| **requests** | HTTP 客户端库,用于任务状态上报与远程调用 |
|
|
221
228
|
| **networkx** | 任务图(TaskGraph)结构与依赖分析 |
|
|
222
229
|
| **jinja2** | FastAPI 模板引擎,用于 Web 可视化界面渲染 |
|
|
230
|
+
| **tqdm** | 可选组件,进度条显示,用于任务执行可视化 |
|
|
223
231
|
| **redis** | 可选组件,用于分布式任务通信(`TaskRedis*` 系列模块) |
|
|
224
232
|
| **celestialtree** | 可选组件,用于任务状态上报与远程调用(`ctree_client`) |
|
|
225
233
|
|
|
@@ -228,24 +236,33 @@ flowchart TD
|
|
|
228
236
|
<p align="center">
|
|
229
237
|
<img src="https://raw.githubusercontent.com/Mr-xiaotian/CelestialFlow/main/img/file_structure.svg" alt="FileStructure" />
|
|
230
238
|
<br/>
|
|
231
|
-
<em>celestial-flow 3.1.
|
|
239
|
+
<em>celestial-flow 3.1.9</em>
|
|
232
240
|
</p>
|
|
233
241
|
|
|
234
242
|
(该视图由我的另一个项目[CelestialVault](https://github.com/Mr-xiaotian/CelestialVault)中inst_file.FileTree.print_tree()生成。转换为图片则借助[Carbon](https://carbon.now.sh)。)
|
|
235
243
|
|
|
236
244
|
## 版本日志(Version Log)
|
|
237
|
-
- 3.1.
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
-
|
|
245
|
+
- 3.1.9
|
|
246
|
+
- feat:
|
|
247
|
+
- [Important] 在TaskStage中允许使用 `async` executor_mode;
|
|
248
|
+
- 3.1.8版本中其实已经可以实现, 在3.1.9版本中彻底测试通过;
|
|
249
|
+
- [Important] 创建基类BaseObservor, 现在可以从外界接入自定义Observor来检测运行状况;
|
|
250
|
+
- 同时创建轻量观察者CallbackObserver;
|
|
251
|
+
- 在TaskStage中添加init字段`log_level`, 自此stage init字段集实现对executor init字段集的包含关系, 仅多出`stage_mode`字段;
|
|
252
|
+
- escapeHtml中添加更多替换项;
|
|
253
|
+
- 在dispatch_thread中添加对futures的清理, 避免无用future的堆积;
|
|
254
|
+
- 基于bench\bench_futures_memory.py, 在十万级任务下futures内存开销为177.01 MB, 在定期清理后则为0.48 MB
|
|
255
|
+
- refactor:
|
|
256
|
+
- 重构TaskProgress, 使其继承BaseObservor;
|
|
257
|
+
- 接口破坏性重构, TaskExecutor的show_progress参数已删除, 现在只有显性的add_observer TaskProgress后才会使用progress
|
|
258
|
+
- 具体使用参考demo\demo_executor.py
|
|
259
|
+
- 重构TaskEnvelope, 不再使用wrap与unwrap, 同时hash值惰性求解;
|
|
260
|
+
- chore:
|
|
261
|
+
- 删除部分无用代码以提高代码质量;
|
|
262
|
+
|
|
263
|
+
更多过往日志可看:
|
|
264
|
+
|
|
265
|
+
[change_log.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/zh-CN/src/runtime/change_log.md )
|
|
249
266
|
|
|
250
267
|
## Star 历史趋势(Star History)
|
|
251
268
|
|
|
@@ -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.
|
|
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.9"
|
|
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"]
|
|
@@ -8,6 +8,7 @@ from .graph import (
|
|
|
8
8
|
TaskLoop,
|
|
9
9
|
TaskWheel,
|
|
10
10
|
)
|
|
11
|
+
from .observability import BaseObserver, CallbackObserver, TaskProgress
|
|
11
12
|
from .persistence.util_jsonl import (
|
|
12
13
|
load_jsonl_logs,
|
|
13
14
|
load_task_by_error,
|
|
@@ -26,7 +27,7 @@ from .stage import (
|
|
|
26
27
|
)
|
|
27
28
|
from .utils.util_benchmark import benchmark_executor, benchmark_graph
|
|
28
29
|
from .utils.util_format import format_table
|
|
29
|
-
from .web
|
|
30
|
+
from .web import TaskWebServer
|
|
30
31
|
|
|
31
32
|
__all__ = [
|
|
32
33
|
"TaskGraph",
|
|
@@ -36,6 +37,9 @@ __all__ = [
|
|
|
36
37
|
"TaskComplete",
|
|
37
38
|
"TaskWheel",
|
|
38
39
|
"TaskGrid",
|
|
40
|
+
"BaseObserver",
|
|
41
|
+
"CallbackObserver",
|
|
42
|
+
"TaskProgress",
|
|
39
43
|
"TaskExecutor",
|
|
40
44
|
"TaskStage",
|
|
41
45
|
"TaskSplitter",
|
|
@@ -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
|
|