celestialflow 3.1.1__tar.gz → 3.1.3__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 (67) hide show
  1. {celestialflow-3.1.1 → celestialflow-3.1.3}/PKG-INFO +56 -20
  2. {celestialflow-3.1.1 → celestialflow-3.1.3}/README.md +54 -17
  3. {celestialflow-3.1.1 → celestialflow-3.1.3}/pyproject.toml +9 -5
  4. {celestialflow-3.1.1 → celestialflow-3.1.3}/src/celestialflow/__init__.py +16 -12
  5. celestialflow-3.1.3/src/celestialflow/graph/__init__.py +20 -0
  6. celestialflow-3.1.3/src/celestialflow/graph/analysis.py +50 -0
  7. celestialflow-3.1.1/src/celestialflow/task_graph.py → celestialflow-3.1.3/src/celestialflow/graph/graph.py +98 -181
  8. celestialflow-3.1.3/src/celestialflow/graph/serialize.py +103 -0
  9. celestialflow-3.1.1/src/celestialflow/task_structure.py → celestialflow-3.1.3/src/celestialflow/graph/structure.py +3 -2
  10. celestialflow-3.1.3/src/celestialflow/observability/__init__.py +7 -0
  11. celestialflow-3.1.1/src/celestialflow/task_report.py → celestialflow-3.1.3/src/celestialflow/observability/report.py +24 -27
  12. celestialflow-3.1.3/src/celestialflow/persistence/__init__.py +13 -0
  13. celestialflow-3.1.3/src/celestialflow/persistence/base.py +61 -0
  14. celestialflow-3.1.3/src/celestialflow/persistence/constant.py +11 -0
  15. celestialflow-3.1.3/src/celestialflow/persistence/fail.py +103 -0
  16. celestialflow-3.1.3/src/celestialflow/persistence/jsonl.py +132 -0
  17. celestialflow-3.1.1/src/celestialflow/task_logger.py → celestialflow-3.1.3/src/celestialflow/persistence/log.py +86 -98
  18. celestialflow-3.1.3/src/celestialflow/runtime/__init__.py +13 -0
  19. celestialflow-3.1.3/src/celestialflow/runtime/envelope.py +28 -0
  20. celestialflow-3.1.1/src/celestialflow/task_errors.py → celestialflow-3.1.3/src/celestialflow/runtime/errors.py +20 -0
  21. celestialflow-3.1.3/src/celestialflow/runtime/estimators.py +128 -0
  22. celestialflow-3.1.3/src/celestialflow/runtime/factories.py +62 -0
  23. celestialflow-3.1.3/src/celestialflow/runtime/hash.py +35 -0
  24. celestialflow-3.1.3/src/celestialflow/runtime/metrics.py +209 -0
  25. celestialflow-3.1.1/src/celestialflow/task_progress.py → celestialflow-3.1.3/src/celestialflow/runtime/progress.py +1 -0
  26. celestialflow-3.1.1/src/celestialflow/task_queue.py → celestialflow-3.1.3/src/celestialflow/runtime/queue.py +75 -96
  27. celestialflow-3.1.3/src/celestialflow/runtime/tools.py +13 -0
  28. celestialflow-3.1.1/src/celestialflow/task_types.py → celestialflow-3.1.3/src/celestialflow/runtime/types.py +2 -38
  29. celestialflow-3.1.3/src/celestialflow/stage/__init__.py +20 -0
  30. celestialflow-3.1.1/src/celestialflow/task_executor.py → celestialflow-3.1.3/src/celestialflow/stage/executor.py +312 -441
  31. celestialflow-3.1.1/src/celestialflow/task_nodes.py → celestialflow-3.1.3/src/celestialflow/stage/nodes.py +30 -29
  32. celestialflow-3.1.1/src/celestialflow/task_stage.py → celestialflow-3.1.3/src/celestialflow/stage/stage.py +36 -31
  33. celestialflow-3.1.3/src/celestialflow/utils/__init__.py +1 -0
  34. celestialflow-3.1.3/src/celestialflow/utils/benchmark.py +103 -0
  35. celestialflow-3.1.3/src/celestialflow/utils/clone.py +118 -0
  36. celestialflow-3.1.3/src/celestialflow/utils/collections.py +17 -0
  37. celestialflow-3.1.3/src/celestialflow/utils/debug.py +10 -0
  38. celestialflow-3.1.3/src/celestialflow/utils/format.py +195 -0
  39. celestialflow-3.1.1/src/celestialflow/task_web.py → celestialflow-3.1.3/src/celestialflow/web/server.py +2 -1
  40. {celestialflow-3.1.1 → celestialflow-3.1.3}/src/celestialflow.egg-info/PKG-INFO +56 -20
  41. celestialflow-3.1.3/src/celestialflow.egg-info/SOURCES.txt +46 -0
  42. celestialflow-3.1.3/src/celestialflow.egg-info/entry_points.txt +2 -0
  43. {celestialflow-3.1.1 → celestialflow-3.1.3}/src/celestialflow.egg-info/requires.txt +1 -2
  44. {celestialflow-3.1.1 → celestialflow-3.1.3}/tests/test_nodes.py +12 -6
  45. celestialflow-3.1.1/src/celestialflow/static/css/base.css +0 -330
  46. celestialflow-3.1.1/src/celestialflow/static/css/dashboard.css +0 -365
  47. celestialflow-3.1.1/src/celestialflow/static/css/errors.css +0 -279
  48. celestialflow-3.1.1/src/celestialflow/static/css/inject.css +0 -668
  49. celestialflow-3.1.1/src/celestialflow/static/favicon.ico +0 -0
  50. celestialflow-3.1.1/src/celestialflow/static/js/main.js +0 -143
  51. celestialflow-3.1.1/src/celestialflow/static/js/task_errors.js +0 -147
  52. celestialflow-3.1.1/src/celestialflow/static/js/task_injection.js +0 -296
  53. celestialflow-3.1.1/src/celestialflow/static/js/task_statuses.js +0 -234
  54. celestialflow-3.1.1/src/celestialflow/static/js/task_structure.js +0 -150
  55. celestialflow-3.1.1/src/celestialflow/static/js/task_summary.js +0 -36
  56. celestialflow-3.1.1/src/celestialflow/static/js/task_topology.js +0 -54
  57. celestialflow-3.1.1/src/celestialflow/static/js/utils.js +0 -97
  58. celestialflow-3.1.1/src/celestialflow/task_tools.py +0 -747
  59. celestialflow-3.1.1/src/celestialflow/templates/index.html +0 -384
  60. celestialflow-3.1.1/src/celestialflow.egg-info/SOURCES.txt +0 -40
  61. celestialflow-3.1.1/src/celestialflow.egg-info/entry_points.txt +0 -2
  62. celestialflow-3.1.1/tests/test_executor.py +0 -121
  63. celestialflow-3.1.1/tests/test_graph.py +0 -219
  64. {celestialflow-3.1.1 → celestialflow-3.1.3}/setup.cfg +0 -0
  65. {celestialflow-3.1.1 → celestialflow-3.1.3}/src/celestialflow.egg-info/dependency_links.txt +0 -0
  66. {celestialflow-3.1.1 → celestialflow-3.1.3}/src/celestialflow.egg-info/top_level.txt +0 -0
  67. {celestialflow-3.1.1 → celestialflow-3.1.3}/tests/test_structure.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: celestialflow
3
- Version: 3.1.1
3
+ Version: 3.1.3
4
4
  Summary: A flexible GRAPH-based task orchestration framework.
5
5
  Author-email: Mr-xiaotian <mingxiaomingtian@gmail.com>
6
6
  License: MIT
@@ -12,17 +12,16 @@ Classifier: License :: OSI Approved :: MIT License
12
12
  Classifier: Operating System :: OS Independent
13
13
  Classifier: Framework :: FastAPI
14
14
  Classifier: Topic :: Software Development :: Libraries
15
- Requires-Python: >=3.8
15
+ Requires-Python: >=3.10
16
16
  Description-Content-Type: text/markdown
17
17
  Requires-Dist: tqdm
18
- Requires-Dist: loguru
19
18
  Requires-Dist: fastapi
20
19
  Requires-Dist: uvicorn
21
20
  Requires-Dist: requests
22
21
  Requires-Dist: networkx
23
22
  Requires-Dist: redis
24
23
  Requires-Dist: jinja2
25
- Requires-Dist: celestialtree
24
+ Requires-Dist: celestialtree>=0.1.2
26
25
 
27
26
  # CelestialFlow ——一个轻量级、可并行、基于图结构的 Python 任务调度框架
28
27
 
@@ -176,19 +175,31 @@ if __name__ == "__main__":
176
175
 
177
176
  若你想了解框架的整体结构与核心组件,下面的参考文档会对你有帮助:
178
177
 
179
- - [🔧TaskExecutor概念](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_executor.md)
180
- - [🔧TaskStage概念](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_stage.md)
181
- - [🌐TaskGraph概念](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_graph.md)
182
- - [📚Go Worker概念](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/go_worker.md)
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)
183
189
 
184
190
  推荐阅读顺序:
185
191
 
186
192
  ```mermaid
187
193
  flowchart TD
188
- classDef whiteNode fill:#ffffff,stroke:#000000,color:#000000;
194
+ classDef core fill:#e6efff,stroke:#3b82f6,color:#1e3a8a;
195
+ classDef runtime fill:#e9f8ef,stroke:#22c55e,color:#14532d;
196
+ classDef structure fill:#fff6e6,stroke:#f59e0b,color:#78350f;
197
+ classDef execution fill:#f3e8ff,stroke:#a855f7,color:#581c87;
198
+ classDef web fill:#ffeaea,stroke:#ef4444,color:#7f1d1d;
189
199
 
190
200
  TM[TaskExecutor.md] --> TS[TaskStage.md] --> TG[TaskGraph.md]
191
201
  TM --> TP[TaskProgress.md]
202
+ TM --> TME[TaskMetrics.md]
192
203
 
193
204
  TG --> TQ[TaskQueue.md]
194
205
  TG --> TN[TaskNodes.md]
@@ -198,15 +209,20 @@ flowchart TD
198
209
  TR --> TW[TaskWeb.md]
199
210
  TN --> GW[Go Worker.md]
200
211
 
201
- class TM,TG,TP,TQ,TN,TR,TS,TW,GW,TSR whiteNode;
212
+ class TM,TS,TG core;
213
+ class TP,TME runtime;
214
+ class TSR structure;
215
+ class TQ,TN,GW execution;
216
+ class TR,TW web;
202
217
  ```
203
218
 
204
219
  以下三篇可以作为补充阅读:
205
220
 
206
- - [TaskTools](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_tools.md)
207
- - [TaskTypes](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_types.md)
208
- - [TaskLogging](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_logging.md)
209
- - [TaskErrors](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_errors.md)
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)
210
226
 
211
227
  如果你更喜欢通过完整案例理解框架的运行方式,可以参考这篇从零开始构建 TaskGraph 的教程:
212
228
 
@@ -214,7 +230,7 @@ flowchart TD
214
230
 
215
231
  如果你对3.0.7版本加入的ctree_client与其功能感兴趣, 可以看看这一篇:
216
232
 
217
- [📚CelestialTreeClient](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/ctree_client.md)
233
+ [📚CelestialTreeClient](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/other/ctree_client.md)
218
234
 
219
235
  ## 环境要求(Requirements)
220
236
 
@@ -223,9 +239,8 @@ flowchart TD
223
239
 
224
240
  | 依赖包 | 说明 |
225
241
  | ----------------- | ---- |
226
- | **Python ≥ 3.8** | 运行环境,建议使用 3.10 及以上版本 |
242
+ | **Python ≥ 3.10** | 运行环境,建议使用 3.10 及以上版本 |
227
243
  | **tqdm** | 控制台进度条显示,用于任务执行可视化 |
228
- | **loguru** | 高性能日志系统,支持多进程安全输出 |
229
244
  | **fastapi** | Web 服务接口框架(用于任务可视化与远程控制) |
230
245
  | **uvicorn** | FastAPI 的高性能 ASGI 服务器 |
231
246
  | **requests** | HTTP 客户端库,用于任务状态上报与远程调用 |
@@ -239,7 +254,7 @@ flowchart TD
239
254
  <p align="center">
240
255
  <img src="https://raw.githubusercontent.com/Mr-xiaotian/CelestialFlow/main/img/file_structure.svg" alt="FileStructure" />
241
256
  <br/>
242
- <em>celestial-flow 3.1.1</em>
257
+ <em>celestial-flow 3.1.3</em>
243
258
  </p>
244
259
 
245
260
  (该视图由我的另一个项目[CelestialVault](https://github.com/Mr-xiaotian/CelestialVault)中inst_file.FileTree.print_tree()生成。转换为图片则借助[Carbon](https://carbon.now.sh)。)
@@ -259,7 +274,7 @@ flowchart TD
259
274
  - 6/16/2025: 多轮评测后, 当前框架已支持完整有向图结构, 将TaskTree改名为TaskGraph
260
275
  - 3.0.1: 上线Pypi, 可喜可贺
261
276
  - 3.0.4: 新增一个抽象结构TaskQueue, 用于表示节点的所有"入边"与"出边"; 恢复未消费任务的保存功能
262
- - 3.0.5: 删除原有的TaskRedisTransfer节点, 并增添三种新的redis交互节点TaskRedisSink TaskRedisSource TaskRedisAck, 用于跨语言 跨进程 跨设备处理任务; 并在Web页面添加展示拓扑信息的卡片
277
+ - 3.0.5: 删除原有的TaskRedisTransfer节点, 并增添三种新的redis交互节点TaskRedisTransport TaskRedisSource TaskRedisAck, 用于跨语言 跨进程 跨设备处理任务; 并在Web页面添加展示拓扑信息的卡片
263
278
  - 3.0.6: 添加对[CelestialTree](https://github.com/Mr-xiaotian/CelestialTree)系统的支持, 现在可以追踪单个任务的流向
264
279
  - 3.0.7: 将TaskStage从TaskExecutor中单独抽出来作为一个子类; 增加新节点TaskRouter, 可以将传入的任务选择的传给不同的下游节点, 而不是进行广播
265
280
  - 3.0.8: 在ctree逻辑上将"任务重试"事件后的"任务成功/失败/重试"事件视为因果关系, 而非之前的并行关系; 重构错误搜集部分逻辑; 修复大量3.0.6与3.07版本引入的bug; 优化部分log表现
@@ -270,7 +285,7 @@ flowchart TD
270
285
  - 在前端中添加error_id的显示, 为之后显示provenance_tree做准备;
271
286
  - 增加大量warning与error, 用于提醒不规范设置;
272
287
  - 优化前后端中错误数据的传输方式, 在大量错误数据时减少内存消耗;
273
- - 优化TaskLogger中log队列的准入机制;
288
+ - 优化LogSinker中log队列的准入机制;
274
289
  - 修改部分Bug;
275
290
  - 3.1.0:
276
291
  - 新增:
@@ -290,6 +305,27 @@ flowchart TD
290
305
  - 修复:
291
306
  - 修复节点剩余时间在小于1s时显示0的问题(这很影响判断);
292
307
  - 在task_graph中使用"staged"模式时会报错的问题;
308
+ - 3.1.2:
309
+ - feat:
310
+ - [Important] 模仿已有Logger逻辑, 建立新的组合结构FailListener和FailSinker, 将原有绑定于TaskReporter的fail持久化在线程中实现;
311
+ - 借此让TaskExecutor也可以进行fail持久化, 文件为fallback/{date_str}/{executor_errors}({time_str}).jsonl";
312
+ - 重构整体项目结构, 现在更加清晰;
313
+ - 补全docs/reference中全部文档, 并令其符合项目重构后结构
314
+ - 引入uv进行环境管理;
315
+ - 将executor中技术逻辑分离为runtime/metrics.py;
316
+ - 整合TaskQueue中重复逻辑;
317
+ - fix
318
+ - 修复前端renderNodeList中参数设置错误;
319
+ - 修复其他微小bug;
320
+ - 3.1.3
321
+ - feat:
322
+ - 抽象出BaseListener与BaseSinker;
323
+ - 移除loguru, 完全由LogListener和LogSinker实现log记录;
324
+ - 将bench相关代码从TaskExecutor和TaskGraph中抽离, 不再作为方法, 而是单独bench函数;
325
+ - 重构TaskExecutor部分代码, 以尽量瘦身;
326
+ - 优化log处理代码中对时间戳的处理, 现在更加准确;
327
+ - fix:
328
+ - 修复一些影响性能的小问题;
293
329
 
294
330
  ## Star 历史趋势(Star History)
295
331
 
@@ -150,19 +150,31 @@ if __name__ == "__main__":
150
150
 
151
151
  若你想了解框架的整体结构与核心组件,下面的参考文档会对你有帮助:
152
152
 
153
- - [🔧TaskExecutor概念](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_executor.md)
154
- - [🔧TaskStage概念](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_stage.md)
155
- - [🌐TaskGraph概念](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_graph.md)
156
- - [📚Go Worker概念](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/go_worker.md)
153
+ - [stage/executor.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/stage/executor.md)
154
+ - [stage/stage.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/stage/stage.md)
155
+ - [graph/graph.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/graph/graph.md)
156
+ - [runtime/progress.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/progress.md)
157
+ - [runtime/metrics.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/metrics.md)
158
+ - [runtime/queue.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/queue.md)
159
+ - [stage/nodes.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/stage/nodes.md)
160
+ - [observability/report.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/observability/report.md)
161
+ - [graph/structure.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/graph/structure.md)
162
+ - [web/server.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/web/server.md)
163
+ - [other/go_worker.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/other/go_worker.md)
157
164
 
158
165
  推荐阅读顺序:
159
166
 
160
167
  ```mermaid
161
168
  flowchart TD
162
- classDef whiteNode fill:#ffffff,stroke:#000000,color:#000000;
169
+ classDef core fill:#e6efff,stroke:#3b82f6,color:#1e3a8a;
170
+ classDef runtime fill:#e9f8ef,stroke:#22c55e,color:#14532d;
171
+ classDef structure fill:#fff6e6,stroke:#f59e0b,color:#78350f;
172
+ classDef execution fill:#f3e8ff,stroke:#a855f7,color:#581c87;
173
+ classDef web fill:#ffeaea,stroke:#ef4444,color:#7f1d1d;
163
174
 
164
175
  TM[TaskExecutor.md] --> TS[TaskStage.md] --> TG[TaskGraph.md]
165
176
  TM --> TP[TaskProgress.md]
177
+ TM --> TME[TaskMetrics.md]
166
178
 
167
179
  TG --> TQ[TaskQueue.md]
168
180
  TG --> TN[TaskNodes.md]
@@ -172,15 +184,20 @@ flowchart TD
172
184
  TR --> TW[TaskWeb.md]
173
185
  TN --> GW[Go Worker.md]
174
186
 
175
- class TM,TG,TP,TQ,TN,TR,TS,TW,GW,TSR whiteNode;
187
+ class TM,TS,TG core;
188
+ class TP,TME runtime;
189
+ class TSR structure;
190
+ class TQ,TN,GW execution;
191
+ class TR,TW web;
176
192
  ```
177
193
 
178
194
  以下三篇可以作为补充阅读:
179
195
 
180
- - [TaskTools](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_tools.md)
181
- - [TaskTypes](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_types.md)
182
- - [TaskLogging](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_logging.md)
183
- - [TaskErrors](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/task_errors.md)
196
+ - [runtime/tools.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/tools.md)
197
+ - [runtime/types.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/types.md)
198
+ - [runtime/errors.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/runtime/errors.md)
199
+ - [persistence/fail.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/persistence/fail.md)
200
+ - [persistence/log.md](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/persistence/log.md)
184
201
 
185
202
  如果你更喜欢通过完整案例理解框架的运行方式,可以参考这篇从零开始构建 TaskGraph 的教程:
186
203
 
@@ -188,7 +205,7 @@ flowchart TD
188
205
 
189
206
  如果你对3.0.7版本加入的ctree_client与其功能感兴趣, 可以看看这一篇:
190
207
 
191
- [📚CelestialTreeClient](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/ctree_client.md)
208
+ [📚CelestialTreeClient](https://github.com/Mr-xiaotian/CelestialFlow/blob/main/docs/reference/other/ctree_client.md)
192
209
 
193
210
  ## 环境要求(Requirements)
194
211
 
@@ -197,9 +214,8 @@ flowchart TD
197
214
 
198
215
  | 依赖包 | 说明 |
199
216
  | ----------------- | ---- |
200
- | **Python ≥ 3.8** | 运行环境,建议使用 3.10 及以上版本 |
217
+ | **Python ≥ 3.10** | 运行环境,建议使用 3.10 及以上版本 |
201
218
  | **tqdm** | 控制台进度条显示,用于任务执行可视化 |
202
- | **loguru** | 高性能日志系统,支持多进程安全输出 |
203
219
  | **fastapi** | Web 服务接口框架(用于任务可视化与远程控制) |
204
220
  | **uvicorn** | FastAPI 的高性能 ASGI 服务器 |
205
221
  | **requests** | HTTP 客户端库,用于任务状态上报与远程调用 |
@@ -213,7 +229,7 @@ flowchart TD
213
229
  <p align="center">
214
230
  <img src="https://raw.githubusercontent.com/Mr-xiaotian/CelestialFlow/main/img/file_structure.svg" alt="FileStructure" />
215
231
  <br/>
216
- <em>celestial-flow 3.1.1</em>
232
+ <em>celestial-flow 3.1.3</em>
217
233
  </p>
218
234
 
219
235
  (该视图由我的另一个项目[CelestialVault](https://github.com/Mr-xiaotian/CelestialVault)中inst_file.FileTree.print_tree()生成。转换为图片则借助[Carbon](https://carbon.now.sh)。)
@@ -233,7 +249,7 @@ flowchart TD
233
249
  - 6/16/2025: 多轮评测后, 当前框架已支持完整有向图结构, 将TaskTree改名为TaskGraph
234
250
  - 3.0.1: 上线Pypi, 可喜可贺
235
251
  - 3.0.4: 新增一个抽象结构TaskQueue, 用于表示节点的所有"入边"与"出边"; 恢复未消费任务的保存功能
236
- - 3.0.5: 删除原有的TaskRedisTransfer节点, 并增添三种新的redis交互节点TaskRedisSink TaskRedisSource TaskRedisAck, 用于跨语言 跨进程 跨设备处理任务; 并在Web页面添加展示拓扑信息的卡片
252
+ - 3.0.5: 删除原有的TaskRedisTransfer节点, 并增添三种新的redis交互节点TaskRedisTransport TaskRedisSource TaskRedisAck, 用于跨语言 跨进程 跨设备处理任务; 并在Web页面添加展示拓扑信息的卡片
237
253
  - 3.0.6: 添加对[CelestialTree](https://github.com/Mr-xiaotian/CelestialTree)系统的支持, 现在可以追踪单个任务的流向
238
254
  - 3.0.7: 将TaskStage从TaskExecutor中单独抽出来作为一个子类; 增加新节点TaskRouter, 可以将传入的任务选择的传给不同的下游节点, 而不是进行广播
239
255
  - 3.0.8: 在ctree逻辑上将"任务重试"事件后的"任务成功/失败/重试"事件视为因果关系, 而非之前的并行关系; 重构错误搜集部分逻辑; 修复大量3.0.6与3.07版本引入的bug; 优化部分log表现
@@ -244,7 +260,7 @@ flowchart TD
244
260
  - 在前端中添加error_id的显示, 为之后显示provenance_tree做准备;
245
261
  - 增加大量warning与error, 用于提醒不规范设置;
246
262
  - 优化前后端中错误数据的传输方式, 在大量错误数据时减少内存消耗;
247
- - 优化TaskLogger中log队列的准入机制;
263
+ - 优化LogSinker中log队列的准入机制;
248
264
  - 修改部分Bug;
249
265
  - 3.1.0:
250
266
  - 新增:
@@ -264,6 +280,27 @@ flowchart TD
264
280
  - 修复:
265
281
  - 修复节点剩余时间在小于1s时显示0的问题(这很影响判断);
266
282
  - 在task_graph中使用"staged"模式时会报错的问题;
283
+ - 3.1.2:
284
+ - feat:
285
+ - [Important] 模仿已有Logger逻辑, 建立新的组合结构FailListener和FailSinker, 将原有绑定于TaskReporter的fail持久化在线程中实现;
286
+ - 借此让TaskExecutor也可以进行fail持久化, 文件为fallback/{date_str}/{executor_errors}({time_str}).jsonl";
287
+ - 重构整体项目结构, 现在更加清晰;
288
+ - 补全docs/reference中全部文档, 并令其符合项目重构后结构
289
+ - 引入uv进行环境管理;
290
+ - 将executor中技术逻辑分离为runtime/metrics.py;
291
+ - 整合TaskQueue中重复逻辑;
292
+ - fix
293
+ - 修复前端renderNodeList中参数设置错误;
294
+ - 修复其他微小bug;
295
+ - 3.1.3
296
+ - feat:
297
+ - 抽象出BaseListener与BaseSinker;
298
+ - 移除loguru, 完全由LogListener和LogSinker实现log记录;
299
+ - 将bench相关代码从TaskExecutor和TaskGraph中抽离, 不再作为方法, 而是单独bench函数;
300
+ - 重构TaskExecutor部分代码, 以尽量瘦身;
301
+ - 优化log处理代码中对时间戳的处理, 现在更加准确;
302
+ - fix:
303
+ - 修复一些影响性能的小问题;
267
304
 
268
305
  ## Star 历史趋势(Star History)
269
306
 
@@ -277,4 +314,4 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
277
314
  ## 作者(Author)
278
315
  Author: Mr-xiaotian
279
316
  Email: mingxiaomingtian@gmail.com
280
- Project Link: [https://github.com/Mr-xiaotian/CelestialFlow](https://github.com/Mr-xiaotian/CelestialFlow)
317
+ Project Link: [https://github.com/Mr-xiaotian/CelestialFlow](https://github.com/Mr-xiaotian/CelestialFlow)
@@ -4,24 +4,23 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "celestialflow"
7
- version = "3.1.1"
7
+ version = "3.1.3"
8
8
  description = "A flexible GRAPH-based task orchestration framework."
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
11
11
  authors = [{ name = "Mr-xiaotian", email = "mingxiaomingtian@gmail.com" }]
12
12
  keywords = ["workflow", "task", "graph", "async", "CelestialFlow"]
13
- requires-python = ">=3.8"
13
+ requires-python = ">=3.10"
14
14
 
15
15
  dependencies = [
16
16
  "tqdm",
17
- "loguru",
18
17
  "fastapi",
19
18
  "uvicorn",
20
19
  "requests",
21
20
  "networkx",
22
21
  "redis",
23
22
  "jinja2",
24
- "celestialtree",
23
+ "celestialtree>=0.1.2",
25
24
  ]
26
25
 
27
26
  classifiers = [
@@ -37,7 +36,7 @@ classifiers = [
37
36
  "Bug Tracker" = "https://github.com/Mr-xiaotian/CelestialFlow/issues"
38
37
 
39
38
  [project.scripts]
40
- celestialflow-web = "celestialflow.task_web:main_entry"
39
+ celestialflow-web = "celestialflow.web.server:main_entry"
41
40
 
42
41
  [tool.setuptools]
43
42
  license-files = []
@@ -63,4 +62,9 @@ asyncio_default_fixture_loop_scope = "function"
63
62
  dev = [
64
63
  "build>=1.2.2.post1",
65
64
  "twine>=6.1.0",
65
+ "pytest>=8.3.4",
66
+ "pytest-asyncio>=0.25.3",
67
+ "httpx>=0.28.1",
68
+ "python-dotenv>=1.2.2",
69
+ "black>=26.1.0",
66
70
  ]
@@ -1,14 +1,15 @@
1
- from .task_graph import TaskGraph
2
- from .task_executor import TaskExecutor
3
- from .task_stage import TaskStage
4
- from .task_nodes import (
1
+ # __init__.py
2
+ from .stage import (
3
+ TaskExecutor,
4
+ TaskStage,
5
5
  TaskSplitter,
6
- TaskRedisSink,
6
+ TaskRedisTransport,
7
7
  TaskRedisSource,
8
8
  TaskRedisAck,
9
9
  TaskRouter,
10
10
  )
11
- from .task_structure import (
11
+ from .graph import (
12
+ TaskGraph,
12
13
  TaskChain,
13
14
  TaskLoop,
14
15
  TaskCross,
@@ -16,15 +17,16 @@ from .task_structure import (
16
17
  TaskWheel,
17
18
  TaskGrid,
18
19
  )
19
- from .task_types import TerminationSignal
20
- from .task_tools import (
20
+ from .persistence.jsonl import (
21
21
  load_jsonl_logs,
22
22
  load_task_by_stage,
23
23
  load_task_by_error,
24
- make_hashable,
25
- format_table,
26
24
  )
27
- from .task_web import TaskWebServer
25
+ from .runtime.types import TerminationSignal
26
+ from .runtime.hash import make_hashable
27
+ from .utils.format import format_table
28
+ from .utils.benchmark import benchmark_graph, benchmark_executor
29
+ from .web.server import TaskWebServer
28
30
 
29
31
  __all__ = [
30
32
  "TaskGraph",
@@ -37,7 +39,7 @@ __all__ = [
37
39
  "TaskExecutor",
38
40
  "TaskStage",
39
41
  "TaskSplitter",
40
- "TaskRedisSink",
42
+ "TaskRedisTransport",
41
43
  "TaskRedisSource",
42
44
  "TaskRedisAck",
43
45
  "TaskRouter",
@@ -48,4 +50,6 @@ __all__ = [
48
50
  "load_task_by_error",
49
51
  "make_hashable",
50
52
  "format_table",
53
+ "benchmark_graph",
54
+ "benchmark_executor",
51
55
  ]
@@ -0,0 +1,20 @@
1
+ # graph/__init__.py
2
+ from .graph import TaskGraph
3
+ from .structure import (
4
+ TaskChain,
5
+ TaskLoop,
6
+ TaskCross,
7
+ TaskComplete,
8
+ TaskWheel,
9
+ TaskGrid,
10
+ )
11
+
12
+ __all__ = [
13
+ "TaskGraph",
14
+ "TaskChain",
15
+ "TaskLoop",
16
+ "TaskCross",
17
+ "TaskComplete",
18
+ "TaskWheel",
19
+ "TaskGrid",
20
+ ]
@@ -0,0 +1,50 @@
1
+ # graph/analysis.py
2
+ import networkx as nx
3
+ from networkx import is_directed_acyclic_graph
4
+ from typing import Dict, Any, List
5
+
6
+
7
+ # ======== (图论分析) ========
8
+ def format_networkx_graph(structure_graph: List[Dict[str, Any]]) -> nx.DiGraph:
9
+ """
10
+ 将结构图(由 build_structure_graph 生成)转换为 networkx 有向图(DiGraph)
11
+
12
+ :param structure_graph: JSON 格式的任务结构图,List[Dict]
13
+ :return: 构建好的 networkx.DiGraph
14
+ """
15
+ G = nx.DiGraph()
16
+
17
+ def add_node_and_edges(node: Dict[str, Any]):
18
+ node_id = f'{node["name"]}[{node["func_name"]}]'
19
+ G.add_node(node_id, **{"mode": node.get("stage_mode")})
20
+
21
+ for child in node.get("next_stages", []):
22
+ child_id = f'{child["name"]}[{child["func_name"]}]'
23
+ G.add_edge(node_id, child_id)
24
+ # 递归添加子节点
25
+ add_node_and_edges(child)
26
+
27
+ for root in structure_graph:
28
+ add_node_and_edges(root)
29
+
30
+ return G
31
+
32
+
33
+ def compute_node_levels(G: nx.DiGraph) -> Dict[str, int]:
34
+ """
35
+ 计算 DAG 中每个节点的层级(最早执行阶段)
36
+ 前提:图必须是有向无环图(DAG)
37
+
38
+ :param G: networkx 有向图(DiGraph)
39
+ :return: dict[node] = level (int)
40
+ """
41
+ if not nx.is_directed_acyclic_graph(G):
42
+ raise ValueError("该图不是 DAG,无法进行层级划分")
43
+
44
+ level = {node: 0 for node in G.nodes} # 初始层级为 0
45
+
46
+ for node in nx.topological_sort(G): # 按拓扑顺序遍历
47
+ for succ in G.successors(node):
48
+ level[succ] = max(level[succ], level[node] + 1)
49
+
50
+ return level