celestialflow 3.2.4__tar.gz → 3.2.5__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 (107) hide show
  1. {celestialflow-3.2.4 → celestialflow-3.2.5}/PKG-INFO +14 -48
  2. {celestialflow-3.2.4 → celestialflow-3.2.5}/README.md +13 -46
  3. {celestialflow-3.2.4 → celestialflow-3.2.5}/pyproject.toml +1 -2
  4. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/__init__.py +5 -0
  5. celestialflow-3.2.5/src/celestialflow/funnel/core_inlet.py +48 -0
  6. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/funnel/core_spout.py +63 -28
  7. celestialflow-3.2.5/src/celestialflow/funnel/util_count.py +51 -0
  8. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/graph/core_graph.py +38 -33
  9. celestialflow-3.2.5/src/celestialflow/graph/util_graph.py +344 -0
  10. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/observability/core_report.py +21 -14
  11. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/persistence/core_fallback.py +13 -13
  12. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/persistence/core_log.py +2 -5
  13. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/persistence/util_sqlite.py +112 -27
  14. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/runtime/util_errors.py +6 -0
  15. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/runtime/util_estimators.py +8 -7
  16. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/stage/core_executor.py +4 -7
  17. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/stage/core_stage.py +8 -12
  18. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/stage/core_stages.py +0 -6
  19. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/config.json +2 -2
  20. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/core_server.py +26 -3
  21. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/routes/pull_routes.py +19 -5
  22. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/routes/push_routes.py +22 -0
  23. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/css/base.css +40 -0
  24. celestialflow-3.2.5/src/celestialflow/web/static/css/dashboard_error_types.css +100 -0
  25. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/css/injection_editor.css +8 -17
  26. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/css/injection_layout.css +0 -37
  27. celestialflow-3.2.5/src/celestialflow/web/static/js/dashboard_error_types.js +223 -0
  28. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/js/dashboard_history.js +19 -12
  29. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/js/errors.js +4 -4
  30. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/js/i18n.js +39 -12
  31. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/js/injection.js +41 -21
  32. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/js/layout_editor.js +1 -1
  33. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/js/main.js +14 -3
  34. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/js/web_config.js +28 -5
  35. celestialflow-3.2.5/src/celestialflow/web/static/ts/dashboard_error_types.ts +247 -0
  36. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/ts/dashboard_history.ts +17 -12
  37. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/ts/errors.ts +15 -15
  38. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/ts/globals.d.ts +25 -14
  39. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/ts/i18n.ts +524 -491
  40. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/ts/injection.ts +47 -22
  41. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/ts/layout_editor.ts +1 -1
  42. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/ts/main.ts +22 -10
  43. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/ts/web_config.ts +28 -5
  44. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/templates/index.html +37 -8
  45. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/util_models.py +4 -0
  46. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow.egg-info/PKG-INFO +14 -48
  47. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow.egg-info/SOURCES.txt +5 -1
  48. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow.egg-info/requires.txt +0 -1
  49. celestialflow-3.2.4/src/celestialflow/funnel/core_inlet.py +0 -22
  50. celestialflow-3.2.4/src/celestialflow/graph/util_analysis.py +0 -70
  51. {celestialflow-3.2.4 → celestialflow-3.2.5}/setup.cfg +0 -0
  52. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/funnel/__init__.py +0 -0
  53. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/graph/__init__.py +0 -0
  54. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/graph/core_structure.py +0 -0
  55. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/graph/util_serialize.py +0 -0
  56. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/observability/__init__.py +0 -0
  57. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/observability/core_observer.py +0 -0
  58. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/observability/core_progress.py +0 -0
  59. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/observability/util_types.py +0 -0
  60. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/persistence/__init__.py +0 -0
  61. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/persistence/util_payload.py +0 -0
  62. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/runtime/__init__.py +0 -0
  63. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/runtime/core_dispatch.py +0 -0
  64. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/runtime/core_envelope.py +0 -0
  65. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/runtime/core_metrics.py +0 -0
  66. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/runtime/core_queue.py +0 -0
  67. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/runtime/util_constant.py +0 -0
  68. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/runtime/util_event.py +0 -0
  69. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/runtime/util_hash.py +0 -0
  70. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/runtime/util_types.py +0 -0
  71. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/stage/__init__.py +0 -0
  72. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/stage/util_callable.py +0 -0
  73. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/stage/util_types.py +0 -0
  74. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/utils/__init__.py +0 -0
  75. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/utils/util_benchmark.py +0 -0
  76. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/utils/util_clone.py +0 -0
  77. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/utils/util_collections.py +0 -0
  78. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/utils/util_format.py +0 -0
  79. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/__init__.py +0 -0
  80. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/routes/__init__.py +0 -0
  81. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/css/_colors.css +0 -0
  82. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/css/dashboard.css +0 -0
  83. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/css/dashboard_analysis.css +0 -0
  84. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/css/dashboard_history.css +0 -0
  85. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/css/dashboard_statuses.css +0 -0
  86. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/css/dashboard_structure.css +0 -0
  87. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/css/dashboard_summary.css +0 -0
  88. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/css/errors.css +0 -0
  89. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/css/injection_nodes.css +0 -0
  90. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/css/injection_preview.css +0 -0
  91. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/favicon.ico +0 -0
  92. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/js/dashboard_analysis.js +0 -0
  93. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/js/dashboard_statuses.js +0 -0
  94. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/js/dashboard_structure.js +0 -0
  95. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/js/dashboard_summary.js +0 -0
  96. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/js/utils.js +0 -0
  97. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/ts/dashboard_analysis.ts +0 -0
  98. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/ts/dashboard_statuses.ts +0 -0
  99. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/ts/dashboard_structure.ts +0 -0
  100. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/ts/dashboard_summary.ts +0 -0
  101. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/static/ts/utils.ts +0 -0
  102. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/util_cal.py +0 -0
  103. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/util_config.py +0 -0
  104. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow/web/util_error.py +0 -0
  105. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow.egg-info/dependency_links.txt +0 -0
  106. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow.egg-info/entry_points.txt +0 -0
  107. {celestialflow-3.2.4 → celestialflow-3.2.5}/src/celestialflow.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: celestialflow
3
- Version: 3.2.4
3
+ Version: 3.2.5
4
4
  Summary: A flexible GRAPH-based task orchestration framework.
5
5
  Author-email: Mr-xiaotian <mingxiaomingtian@gmail.com>
6
6
  License: MIT
@@ -18,7 +18,6 @@ Requires-Dist: tqdm
18
18
  Requires-Dist: fastapi
19
19
  Requires-Dist: uvicorn
20
20
  Requires-Dist: requests
21
- Requires-Dist: networkx
22
21
  Requires-Dist: jinja2
23
22
 
24
23
  # CelestialFlow ——一个轻量级、可并行、基于图结构的 Python 任务调度框架
@@ -259,7 +258,6 @@ flowchart TD
259
258
  | **fastapi** | Web 服务接口框架(用于任务可视化与远程控制) |
260
259
  | **uvicorn** | FastAPI 的高性能 ASGI 服务器 |
261
260
  | **requests** | HTTP 客户端库,用于任务状态上报与远程调用 |
262
- | **networkx** | 任务图(TaskGraph)结构与依赖分析 |
263
261
  | **jinja2** | FastAPI 模板引擎,用于 Web 可视化界面渲染 |
264
262
  | **tqdm** | 可选组件,进度条显示,用于任务执行可视化 |
265
263
 
@@ -272,60 +270,28 @@ flowchart TD
272
270
  <p align="center">
273
271
  <img src="https://raw.githubusercontent.com/Mr-xiaotian/CelestialFlow/main/img/file_structure.svg" alt="FileStructure" />
274
272
  <br/>
275
- <em>celestial-flow 3.2.4</em>
273
+ <em>celestial-flow 3.2.5</em>
276
274
  </p>
277
275
 
278
276
  (该视图由我的另一个项目[CelestialVault](https://github.com/Mr-xiaotian/CelestialVault)中inst_file.FileTree.print_tree()生成。转换为图片则借助[Carbon](https://carbon.now.sh)。)
279
277
 
280
278
  ## 版本日志(Version Log)
281
- - 3.2.4
279
+ - 3.2.5
282
280
  - feat:
283
- - **[IMPORTANT]** 合并原有的 `fail_funnel` 与 `success_funnel` 机制为 `fallback` , 并采用 `sqlite` 进行存储
284
- - 原有基于 `jsonl` 存储的fail持久化机制在存储时非常好用, 但读取时每次都需要全量读取到内存中再进行检索, 非常麻烦; 我虽然也想过用类似 `redis` 的数据库服务, 但实在不想另外启动第三方服务. 然后我意外发现 `sqlite` 完美符合我的一切要求
285
- - Richard 万岁!
286
- - 至于原有的 `success_funnel` 机制完全是个半成品: 只能用于 `executor`, 而不能用于 `stage`; 完全在内存存储. 所以借着这次机会也一并重构, 合并入 `fallback_funnel`
287
- - 现在 `fallback_funnel` 会在任务 `注入/重复/重试/失败/成功` 时对sqlite中相应记录进行插入/更新/删除操作
288
- - 其中在任务成功时默认会删除该条记录, 但如果开启 `executor` 中的 `perist_result` 选项, 则会保留该条记录, 并将 `status` 字段更新为 `success`
289
- - **[IMPORTANT]** 移除 `stages` 中的三个redis节点, 并添加demo文件, 说明如果自行构建相关节点
290
- - 相比 `TaskSplitter` 与 `TaskRouter`, 这三个节点实在可有可无, 还会导致多一个 `redis` 依赖包
291
- - **[IMPORTANT]** `celestialtree` 不再继续作为依赖库, 现有的事件声明机制基于一套protol接口, 并默认使用本地的超简化实现
292
- - 这样做同样是为了避免太多库依赖, `celestialtree` 库包含对 `grpcio` 与 `protobuf` 的依赖, 而这两者对于python free-threading版本的支持性不太好, 因此在有他们的情况下 `celestialflow` 无法在free-threading版本下运行----而这是我非常期待的
293
- - 根据 `bench_gil_vs_nogil`, 在free-threading版本下, `executor` 在cpu密集任务中会得到5.25倍提升, 而 `graph` 在cpu密集任务中则会得到7.55倍提升. 非常喜人
294
- - 在前端 `节点指标走向` 卡片中添加 `全局等待队列`
295
- - 在 `graph` 中添加 `start_graph_db` 方法, 接受一个fallback数据库地址, 然后根据其中失败数据进行 `start_graph`; 在 `executor` 中添加 `start_db` 方法, 接受一个fallback数据库地址, 然后根据其中失败数据进行 `start`
296
- - 很方便
281
+ - 在 `Spout` 和 `Inlet` 中 添加 `counter`, 对 `queue` 中未消费任务的数量进行记录
282
+ - 在上版本大幅修改 `fallback` 机制后, `FallbackSpout` 中很有可能出现任务堆积, 进而导致误判
283
+ - 在web端错误日志页面对当前显示的错误数量可能与node_status中的error数量不一致的情况进行说明
284
+ - 在web端仪表盘页面添加错误分类的饼图
297
285
  - refactor:
298
- - **[IMPORTANT]** 将server端存储error数据的方式从py原生列表改为一个临时sqlite数据库
299
- - 在锤子效应下我想更多的尝试sqlite的使用
300
- - 为每个 `graph` 添加基于 `name` 与 `time.time()` 的 `graph_id` 作为唯一性标识符
301
- - 重写reporter与server端的交互逻辑
302
- - 现在每一轮refresh开始时都会进行状态对齐, 通过 `graph_id` 确定两者所持有的数据是否来自一个 `graph` 对象, 是的话则不用重复push structure/analysis数据
303
- - 在状态对齐时如果双方的graph一致, server会返回自己所持有的错误数据中最大的 `event_id` 值, 经过严格校验, `event_id` 在数据库中严格递增
304
- - 将reporter中原有的 `push_error_meta` 与 `push_error_content` 合并, 每次刷新时只发送新增的错误数据, 而新增数据则根据server返回的最大 `event_id` 值与本地数据库中的最大 `event_id` 值进行筛选
305
- - 为 `graph.connect` 与 `graph_set_stage` 绑定更多职责
306
- - 现在节点与 `graph` 在 `ctree` `reporter` 上的同步在 `graph_set_stage` 中完成
307
- - 而 `task_queue` 与 `result_queue` 的上下流绑定, 以及 `counter` 的绑定都在 `graph.connect` 中完成
308
- - 删除 `TaskEnvelope` 中无关数据, 只保留 `task` `hash` `id` 三项
309
- - `source` 字段本就不该添加, 它一致没有发挥作用
310
- - `prev` 字段是为了原版 `success_funnel` 而服务的, 现在已经没有必要
311
- - `TaskMetrics` 中固定使用 `Lock` 对所有 `counter` 进行限定, 而无关乎 `executor` 的 `execution_mode`
312
- - 这种固定的模式在牺牲部分性能的情况下使得代码更加稳定
313
- - 根据 `bench_lock_overhead`, 这会导致 `counter` 慢3.2倍左右, 考虑到 `counter` 的更新全部基于 `int` 类型, 本就很快, 可以接受
314
- - 在 `process_task_success` 中除去已有的一次 `task.success` 声明, 会在 `result_envelope` 进入 `result_queue` 前再进行 `task.input` 声明
315
- - 为了保证fallback的sqlite中 `event_id` 全局统一
316
- - `executor.get_fail_pairs`(原 `executor.get_error_pairs`) 会返回 `tuple[T, PeristedError]`
317
- - `PeristedError` 由记录的 `error_type` 与 `error_message` 组成
318
- - 重写 `TaskRouter` 节点, 现在必须传入一个 `router` 函数, 去指定任务的路由方向
319
- - 移除一些没用的方法
320
- - 比如 `TaskGraph.get_stage_input_trace`
286
+ - 移除对 `networkx` 的依赖, 添加 `util_graph`, 实现所有图论分析
287
+ - `TaskExecutor` 中将 `enable_duplicate_check` 默认改为 `False`
288
+ - 在duplicate机制中一直有一个内存持续增长点: `processed_set`, 这导致 `enable_duplicate_check` 在大规模的任务下会导致很大的内存压力
289
+ - 分离server端的 `push_task` 和 `push_termination`
321
290
  - fix:
322
- - 前端仪表盘页面中的结构图不会再因切换tab而显示空白
323
- - 这是很古老的bug, 我不知道我为什么译制片没有修复
291
+ - 修复 `UnconsumedError` 在 `drain_task_queue` 中被计算两次的问题
324
292
  - chore:
325
- - 添加更多demo
326
- - 添加更多benchmark
327
- - 添加 `Agents.md` 文件
328
- - 我受够了无休止的对ai进行强调
293
+ - `img/` 中添加全新的 `web_display.png` 图片
294
+ - 完善几个skill, 现在对主agent与子agent的prompt进行分离
329
295
 
330
296
  更多过往日志可看:
331
297
 
@@ -236,7 +236,6 @@ flowchart TD
236
236
  | **fastapi** | Web 服务接口框架(用于任务可视化与远程控制) |
237
237
  | **uvicorn** | FastAPI 的高性能 ASGI 服务器 |
238
238
  | **requests** | HTTP 客户端库,用于任务状态上报与远程调用 |
239
- | **networkx** | 任务图(TaskGraph)结构与依赖分析 |
240
239
  | **jinja2** | FastAPI 模板引擎,用于 Web 可视化界面渲染 |
241
240
  | **tqdm** | 可选组件,进度条显示,用于任务执行可视化 |
242
241
 
@@ -249,60 +248,28 @@ flowchart TD
249
248
  <p align="center">
250
249
  <img src="https://raw.githubusercontent.com/Mr-xiaotian/CelestialFlow/main/img/file_structure.svg" alt="FileStructure" />
251
250
  <br/>
252
- <em>celestial-flow 3.2.4</em>
251
+ <em>celestial-flow 3.2.5</em>
253
252
  </p>
254
253
 
255
254
  (该视图由我的另一个项目[CelestialVault](https://github.com/Mr-xiaotian/CelestialVault)中inst_file.FileTree.print_tree()生成。转换为图片则借助[Carbon](https://carbon.now.sh)。)
256
255
 
257
256
  ## 版本日志(Version Log)
258
- - 3.2.4
257
+ - 3.2.5
259
258
  - feat:
260
- - **[IMPORTANT]** 合并原有的 `fail_funnel` 与 `success_funnel` 机制为 `fallback` , 并采用 `sqlite` 进行存储
261
- - 原有基于 `jsonl` 存储的fail持久化机制在存储时非常好用, 但读取时每次都需要全量读取到内存中再进行检索, 非常麻烦; 我虽然也想过用类似 `redis` 的数据库服务, 但实在不想另外启动第三方服务. 然后我意外发现 `sqlite` 完美符合我的一切要求
262
- - Richard 万岁!
263
- - 至于原有的 `success_funnel` 机制完全是个半成品: 只能用于 `executor`, 而不能用于 `stage`; 完全在内存存储. 所以借着这次机会也一并重构, 合并入 `fallback_funnel`
264
- - 现在 `fallback_funnel` 会在任务 `注入/重复/重试/失败/成功` 时对sqlite中相应记录进行插入/更新/删除操作
265
- - 其中在任务成功时默认会删除该条记录, 但如果开启 `executor` 中的 `perist_result` 选项, 则会保留该条记录, 并将 `status` 字段更新为 `success`
266
- - **[IMPORTANT]** 移除 `stages` 中的三个redis节点, 并添加demo文件, 说明如果自行构建相关节点
267
- - 相比 `TaskSplitter` 与 `TaskRouter`, 这三个节点实在可有可无, 还会导致多一个 `redis` 依赖包
268
- - **[IMPORTANT]** `celestialtree` 不再继续作为依赖库, 现有的事件声明机制基于一套protol接口, 并默认使用本地的超简化实现
269
- - 这样做同样是为了避免太多库依赖, `celestialtree` 库包含对 `grpcio` 与 `protobuf` 的依赖, 而这两者对于python free-threading版本的支持性不太好, 因此在有他们的情况下 `celestialflow` 无法在free-threading版本下运行----而这是我非常期待的
270
- - 根据 `bench_gil_vs_nogil`, 在free-threading版本下, `executor` 在cpu密集任务中会得到5.25倍提升, 而 `graph` 在cpu密集任务中则会得到7.55倍提升. 非常喜人
271
- - 在前端 `节点指标走向` 卡片中添加 `全局等待队列`
272
- - 在 `graph` 中添加 `start_graph_db` 方法, 接受一个fallback数据库地址, 然后根据其中失败数据进行 `start_graph`; 在 `executor` 中添加 `start_db` 方法, 接受一个fallback数据库地址, 然后根据其中失败数据进行 `start`
273
- - 很方便
259
+ - 在 `Spout` 和 `Inlet` 中 添加 `counter`, 对 `queue` 中未消费任务的数量进行记录
260
+ - 在上版本大幅修改 `fallback` 机制后, `FallbackSpout` 中很有可能出现任务堆积, 进而导致误判
261
+ - 在web端错误日志页面对当前显示的错误数量可能与node_status中的error数量不一致的情况进行说明
262
+ - 在web端仪表盘页面添加错误分类的饼图
274
263
  - refactor:
275
- - **[IMPORTANT]** 将server端存储error数据的方式从py原生列表改为一个临时sqlite数据库
276
- - 在锤子效应下我想更多的尝试sqlite的使用
277
- - 为每个 `graph` 添加基于 `name` 与 `time.time()` 的 `graph_id` 作为唯一性标识符
278
- - 重写reporter与server端的交互逻辑
279
- - 现在每一轮refresh开始时都会进行状态对齐, 通过 `graph_id` 确定两者所持有的数据是否来自一个 `graph` 对象, 是的话则不用重复push structure/analysis数据
280
- - 在状态对齐时如果双方的graph一致, server会返回自己所持有的错误数据中最大的 `event_id` 值, 经过严格校验, `event_id` 在数据库中严格递增
281
- - 将reporter中原有的 `push_error_meta` 与 `push_error_content` 合并, 每次刷新时只发送新增的错误数据, 而新增数据则根据server返回的最大 `event_id` 值与本地数据库中的最大 `event_id` 值进行筛选
282
- - 为 `graph.connect` 与 `graph_set_stage` 绑定更多职责
283
- - 现在节点与 `graph` 在 `ctree` `reporter` 上的同步在 `graph_set_stage` 中完成
284
- - 而 `task_queue` 与 `result_queue` 的上下流绑定, 以及 `counter` 的绑定都在 `graph.connect` 中完成
285
- - 删除 `TaskEnvelope` 中无关数据, 只保留 `task` `hash` `id` 三项
286
- - `source` 字段本就不该添加, 它一致没有发挥作用
287
- - `prev` 字段是为了原版 `success_funnel` 而服务的, 现在已经没有必要
288
- - `TaskMetrics` 中固定使用 `Lock` 对所有 `counter` 进行限定, 而无关乎 `executor` 的 `execution_mode`
289
- - 这种固定的模式在牺牲部分性能的情况下使得代码更加稳定
290
- - 根据 `bench_lock_overhead`, 这会导致 `counter` 慢3.2倍左右, 考虑到 `counter` 的更新全部基于 `int` 类型, 本就很快, 可以接受
291
- - 在 `process_task_success` 中除去已有的一次 `task.success` 声明, 会在 `result_envelope` 进入 `result_queue` 前再进行 `task.input` 声明
292
- - 为了保证fallback的sqlite中 `event_id` 全局统一
293
- - `executor.get_fail_pairs`(原 `executor.get_error_pairs`) 会返回 `tuple[T, PeristedError]`
294
- - `PeristedError` 由记录的 `error_type` 与 `error_message` 组成
295
- - 重写 `TaskRouter` 节点, 现在必须传入一个 `router` 函数, 去指定任务的路由方向
296
- - 移除一些没用的方法
297
- - 比如 `TaskGraph.get_stage_input_trace`
264
+ - 移除对 `networkx` 的依赖, 添加 `util_graph`, 实现所有图论分析
265
+ - `TaskExecutor` 中将 `enable_duplicate_check` 默认改为 `False`
266
+ - 在duplicate机制中一直有一个内存持续增长点: `processed_set`, 这导致 `enable_duplicate_check` 在大规模的任务下会导致很大的内存压力
267
+ - 分离server端的 `push_task` 和 `push_termination`
298
268
  - fix:
299
- - 前端仪表盘页面中的结构图不会再因切换tab而显示空白
300
- - 这是很古老的bug, 我不知道我为什么译制片没有修复
269
+ - 修复 `UnconsumedError` 在 `drain_task_queue` 中被计算两次的问题
301
270
  - chore:
302
- - 添加更多demo
303
- - 添加更多benchmark
304
- - 添加 `Agents.md` 文件
305
- - 我受够了无休止的对ai进行强调
271
+ - `img/` 中添加全新的 `web_display.png` 图片
272
+ - 完善几个skill, 现在对主agent与子agent的prompt进行分离
306
273
 
307
274
  更多过往日志可看:
308
275
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "celestialflow"
7
- version = "3.2.4"
7
+ version = "3.2.5"
8
8
  description = "A flexible GRAPH-based task orchestration framework."
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
@@ -17,7 +17,6 @@ dependencies = [
17
17
  "fastapi",
18
18
  "uvicorn",
19
19
  "requests",
20
- "networkx",
21
20
  "jinja2",
22
21
  ]
23
22
 
@@ -4,6 +4,7 @@
4
4
  提供任务图构建、执行调度、实时监控、Web 可视化和持久化等核心能力。
5
5
  """
6
6
 
7
+ from .funnel import BaseInlet, BaseSpout
7
8
  from .graph import (
8
9
  TaskChain,
9
10
  TaskComplete,
@@ -17,6 +18,7 @@ from .observability import BaseObserver, TaskProgress
17
18
  from .persistence.util_sqlite import (
18
19
  load_records,
19
20
  load_records_grouped_by_stage,
21
+ load_tasks_grouped_by_stage,
20
22
  )
21
23
  from .runtime.util_hash import make_hashable
22
24
  from .runtime.util_types import TerminationSignal
@@ -31,7 +33,9 @@ from .utils.util_format import format_table
31
33
  from .web import TaskWebServer
32
34
 
33
35
  __all__ = [
36
+ "BaseInlet",
34
37
  "BaseObserver",
38
+ "BaseSpout",
35
39
  "TaskChain",
36
40
  "TaskComplete",
37
41
  "TaskCross",
@@ -51,5 +55,6 @@ __all__ = [
51
55
  "format_table",
52
56
  "load_records",
53
57
  "load_records_grouped_by_stage",
58
+ "load_tasks_grouped_by_stage",
54
59
  "make_hashable",
55
60
  ]
@@ -0,0 +1,48 @@
1
+ # funnel/core_inlet.py
2
+ from __future__ import annotations
3
+
4
+ from queue import Queue
5
+ from typing import TYPE_CHECKING, Any, Self
6
+
7
+ from ..runtime.util_errors import InitializationError
8
+ from .util_count import PendingCounter
9
+
10
+ if TYPE_CHECKING:
11
+ from .core_spout import BaseSpout
12
+
13
+
14
+ class BaseInlet:
15
+ """数据收集器基类,负责将记录通过队列发送到对应的监听器。"""
16
+
17
+ _queue: Queue[Any]
18
+ _counter: PendingCounter
19
+
20
+ def bind_spout(self, spout: BaseSpout) -> Self:
21
+ """
22
+ 将当前 inlet 绑定到给定 spout。
23
+
24
+ :param spout: 目标监听器
25
+ :return: 当前已绑定的 inlet 实例
26
+ :rtype: Self
27
+ """
28
+ self._queue = spout.get_queue()
29
+ self._counter = spout.get_counter()
30
+ return self
31
+
32
+ def _funnel(self, record: Any) -> None:
33
+ """
34
+ 将记录放入队列。
35
+
36
+ :param record: 待发送的记录
37
+ :return: ``None``
38
+ """
39
+ if not hasattr(self, '_queue') or not hasattr(self, '_counter'):
40
+ raise InitializationError("inlet is not bound to spout")
41
+
42
+ # 先增加待处理数量,再入队;若入队失败则立即回滚计数。
43
+ self._counter.increment()
44
+ try:
45
+ self._queue.put(record)
46
+ except Exception:
47
+ self._counter.decrement()
48
+ raise
@@ -8,31 +8,19 @@ from typing import Any
8
8
 
9
9
  from ..runtime.util_errors import CelestialFlowError
10
10
  from ..runtime.util_types import TERMINATION_SIGNAL, TerminationSignal
11
+ from .util_count import PendingCounter
11
12
 
12
13
 
13
14
  class BaseSpout:
14
15
  """数据监听器基类,在独立后台线程中消费队列记录。"""
15
16
 
16
17
  def __init__(self) -> None:
17
- """初始化监听器及其内部队列和线程引用。"""
18
- self.queue: Queue[Any] = Queue()
18
+ """初始化监听器及其内部队列、待处理计数器和线程引用。"""
19
+ self._queue: Queue[Any] = Queue()
20
+ self._counter = PendingCounter()
19
21
  self._thread: Thread | None = None
20
22
 
21
- def _before_start(self) -> None:
22
- """在后台线程启动前调用,子类可覆写以做初始化(如打开文件、清空缓存)。"""
23
- return None
24
-
25
- def _handle_record(self, _record: Any) -> None:
26
- """
27
- 处理单条队列记录,子类必须覆写。
28
-
29
- :param _record: 队列中取出的记录
30
- """
31
- raise CelestialFlowError("_handle_record must be implemented by subclasses")
32
-
33
- def _after_stop(self) -> None:
34
- """在后台线程停止后调用,子类可覆写以做清理(如关闭文件句柄)。"""
35
- return None
23
+ # ==== 外部调用函数 ====
36
24
 
37
25
  def start(self) -> None:
38
26
  """启动后台监听线程(若未运行)。"""
@@ -42,30 +30,77 @@ class BaseSpout:
42
30
  self._thread.start()
43
31
 
44
32
  def _spout(self) -> None:
45
- """后台线程主循环,持续从队列拉取记录并调用 _handle_record,收到终止信号时退出。"""
33
+ """
34
+ 后台线程主循环。
35
+
36
+ 持续从队列拉取记录并调用 ``_handle_record()``,收到终止信号时退出。
37
+ 待处理数量在记录处理完成后递减,因此统计口径包含“已出队但仍在处理”的记录。
38
+ """
46
39
  while True:
47
40
  try:
48
- record = self.queue.get(timeout=0.5)
49
- if isinstance(record, TerminationSignal):
50
- break
51
- self._handle_record(record)
41
+ record = self._queue.get(timeout=0.5)
52
42
  except Empty:
53
43
  continue
44
+
45
+ if isinstance(record, TerminationSignal):
46
+ break
47
+
48
+ try:
49
+ self._handle_record(record)
54
50
  except Exception:
55
- # 单条记录处理失败不致死线程
51
+ # 单条记录处理失败不致死线程。
56
52
  traceback.print_exc()
57
-
58
- def get_queue(self) -> Queue[Any]:
59
- """获取监听器的输入队列。"""
60
- return self.queue
53
+ finally:
54
+ self._counter.decrement()
61
55
 
62
56
  def stop(self) -> None:
63
57
  """发送终止信号并等待后台线程结束。"""
64
58
  if self._thread is None:
65
59
  return
66
60
 
67
- self.queue.put(TERMINATION_SIGNAL)
61
+ self._queue.put(TERMINATION_SIGNAL)
68
62
  if self._thread.is_alive():
69
63
  self._thread.join(timeout=5)
64
+
70
65
  self._thread = None
71
66
  self._after_stop()
67
+
68
+ def get_queue(self) -> Queue[Any]:
69
+ """获取监听器的输入队列。"""
70
+ return self._queue
71
+
72
+ def get_counter(self) -> PendingCounter:
73
+ """
74
+ 获取与当前监听器绑定的待处理计数器。
75
+
76
+ :return: 待处理计数器
77
+ :rtype: PendingCounter
78
+ """
79
+ return self._counter
80
+
81
+ def get_pending_count(self) -> int:
82
+ """
83
+ 读取当前仍未处理完成的记录数量。
84
+
85
+ :return: 当前待处理数量
86
+ :rtype: int
87
+ """
88
+ return self._counter.get_count()
89
+
90
+ # ==== 生命周期回调 ====
91
+
92
+ def _before_start(self) -> None:
93
+ """在后台线程启动前调用,子类可覆写以做初始化(如打开文件、清空缓存)。"""
94
+ return None
95
+
96
+ def _handle_record(self, _record: Any) -> None:
97
+ """
98
+ 处理单条队列记录,子类必须覆写。
99
+
100
+ :param _record: 队列中取出的记录
101
+ """
102
+ raise CelestialFlowError("_handle_record must be implemented by subclasses")
103
+
104
+ def _after_stop(self) -> None:
105
+ """在后台线程停止后调用,子类可覆写以做清理(如关闭文件句柄)。"""
106
+ return None
@@ -0,0 +1,51 @@
1
+ from __future__ import annotations
2
+
3
+ from threading import Lock
4
+
5
+
6
+ class PendingCounter:
7
+ """线程安全的待处理计数器。
8
+
9
+ 该计数器用于统计某个 spout 对应的记录中,仍未完成处理的数量。
10
+ """
11
+
12
+ def __init__(self) -> None:
13
+ """
14
+ 初始化计数器。
15
+
16
+ :return: ``None``
17
+ """
18
+ self._count = 0
19
+ self._lock = Lock()
20
+
21
+ def increment(self) -> int:
22
+ """
23
+ 将待处理数量加一。
24
+
25
+ :return: 自增后的待处理数量
26
+ :rtype: int
27
+ """
28
+ with self._lock:
29
+ self._count += 1
30
+ return self._count
31
+
32
+ def decrement(self) -> int:
33
+ """
34
+ 将待处理数量减一。
35
+
36
+ :return: 自减后的待处理数量
37
+ :rtype: int
38
+ """
39
+ with self._lock:
40
+ self._count -= 1
41
+ return self._count
42
+
43
+ def get_count(self) -> int:
44
+ """
45
+ 读取当前待处理数量。
46
+
47
+ :return: 当前待处理数量
48
+ :rtype: int
49
+ """
50
+ with self._lock:
51
+ return self._count
@@ -9,15 +9,14 @@ from collections.abc import Iterable, Mapping
9
9
  from pathlib import Path
10
10
  from typing import Any
11
11
 
12
- from networkx import DiGraph, is_directed_acyclic_graph
13
-
14
12
  from ..observability import NullTaskReporter, TaskReporter
15
13
  from ..persistence import FallbackInlet, FallbackSpout, LogInlet, LogSpout
16
- from ..persistence.util_sqlite import load_records_grouped_by_stage
14
+ from ..persistence.util_sqlite import load_tasks_grouped_by_stage
17
15
  from ..runtime.util_constant import LEVEL_DICT
18
16
  from ..runtime.util_errors import (
19
17
  DuplicateNodeError,
20
18
  LogLevelError,
19
+ NodeNotFoundError,
21
20
  RuntimeStateError,
22
21
  ScheduleModeError,
23
22
  )
@@ -31,11 +30,7 @@ from ..runtime.util_types import TerminationSignal
31
30
  from ..stage.util_types import AnyTaskStage
32
31
  from ..utils.util_collections import cluster_by_value_sorted
33
32
  from ..utils.util_format import format_avg_time
34
- from .util_analysis import (
35
- build_networkx_graph,
36
- compute_node_levels,
37
- find_source_nodes,
38
- )
33
+ from .util_graph import OrderGraph, compute_node_levels, is_dag, source_nodes
39
34
  from .util_serialize import build_structure_graph, format_structure_list_from_graph
40
35
 
41
36
 
@@ -102,7 +97,9 @@ class TaskGraph:
102
97
 
103
98
  def _init_state(self) -> None:
104
99
  """
105
- 初始化状态
100
+ 初始化任务图运行时状态。
101
+
102
+ :return: ``None``。
106
103
  """
107
104
  # 用于保存所有子线程的引用
108
105
  self.threads: list[threading.Thread] = []
@@ -119,22 +116,27 @@ class TaskGraph:
119
116
  # 用于保存图结构的邻接表
120
117
  self.out_edges: dict[str, list[str]] = defaultdict(list)
121
118
  self.in_edges: dict[str, list[str]] = defaultdict(list)
119
+ self.order_graph = OrderGraph()
122
120
  # 用于保存任务图启动时间
123
121
  self.start_time: float = 0.0
124
122
 
125
123
  def _init_spout(self) -> None:
126
124
  """
127
- 初始化监听器
125
+ 初始化图级持久化输出组件。
126
+
127
+ :return: ``None``。
128
128
  """
129
129
  self.log_spout = LogSpout()
130
130
  self.fallback_spout = FallbackSpout("graph_fallbacks")
131
131
 
132
132
  def _init_inlet(self) -> None:
133
133
  """
134
- 初始化收集器
134
+ 初始化图级日志与回退收集器。
135
+
136
+ :return: ``None``。
135
137
  """
136
- self.log_inlet = LogInlet(self.log_spout.get_queue(), self.log_level)
137
- self.fallback_inlet = FallbackInlet(self.fallback_spout.get_queue())
138
+ self.log_inlet = LogInlet(self.log_level).bind_spout(self.log_spout)
139
+ self.fallback_inlet = FallbackInlet().bind_spout(self.fallback_spout)
138
140
 
139
141
  # ==== 建图 ====
140
142
 
@@ -145,17 +147,15 @@ class TaskGraph:
145
147
  :param stages: 待添加的节点列表
146
148
  :raises DuplicateNodeError: 存在重复的 stage 名称
147
149
  """
148
- fallback_queue = self.fallback_spout.get_queue()
149
- log_queue = self.log_spout.get_queue()
150
-
151
150
  for stage in stages:
152
151
  stage_name = stage.get_name()
153
152
  if stage_name in self.stage_dict:
154
153
  raise DuplicateNodeError(f"duplicate stage name: {stage_name}")
155
154
  self.stage_dict[stage_name] = stage
155
+ self.order_graph.add_node(stage_name)
156
156
 
157
157
  stage.set_ctree(self.ctree_client)
158
- stage.set_inlet(fallback_queue, log_queue)
158
+ stage.set_inlet(self.fallback_inlet, self.log_inlet)
159
159
 
160
160
  def connect(
161
161
  self,
@@ -172,13 +172,20 @@ class TaskGraph:
172
172
  from_name = from_stage.get_name()
173
173
  from_out_queue = from_stage.result_queue
174
174
 
175
+ if from_name not in self.stage_dict:
176
+ raise NodeNotFoundError(f"from stage not found: {from_name}")
177
+
175
178
  for to_stage in to_stages:
176
179
  to_name = to_stage.get_name()
177
180
  to_in_queue = to_stage.task_queue
178
181
 
182
+ if to_name not in self.stage_dict:
183
+ raise NodeNotFoundError(f"to stage not found: {to_name}")
184
+
179
185
  from_out_queue.add_queue(to_in_queue, to_name)
180
186
  to_stage.prev_binding(from_stage)
181
187
  to_in_queue.add_source_name(from_name)
188
+ self.order_graph.add_edge(from_name, to_name)
182
189
 
183
190
  self.out_edges[from_name].append(to_name)
184
191
  self.in_edges[to_name].append(from_name)
@@ -270,19 +277,20 @@ class TaskGraph:
270
277
 
271
278
  def _build_analysis(self) -> None:
272
279
  """
273
- 分析任务图,计算图属性和层级信息(支持 DAG 和含环图)
280
+ 分析任务图,计算源节点、是否为 DAG 与层级信息。
281
+
282
+ :return: ``None``。
274
283
  """
275
- self.networkx_graph = build_networkx_graph(self.out_edges, self.stage_dict)
276
- source_names = find_source_nodes(self.networkx_graph)
284
+ source_names = source_nodes(self.order_graph)
277
285
  self.source_stages = [self.stage_dict[name] for name in source_names]
278
286
 
279
287
  self.structure_graph = build_structure_graph(
280
288
  self.stage_dict, self.out_edges, self.source_stages
281
289
  )
282
290
 
283
- self.is_dag = is_directed_acyclic_graph(self.networkx_graph)
291
+ self.is_dag = is_dag(self.order_graph)
284
292
 
285
- stage_level_dict = compute_node_levels(self.networkx_graph)
293
+ stage_level_dict = compute_node_levels(self.order_graph)
286
294
  self.layers_dict = cluster_by_value_sorted(stage_level_dict)
287
295
 
288
296
  def put_stage_queue(
@@ -377,13 +385,10 @@ class TaskGraph:
377
385
  :param status: 记录状态过滤条件,默认 ``failed``
378
386
  :param put_termination_signal: 是否注入终止信号,默认 True
379
387
  """
380
- grouped_records = load_records_grouped_by_stage(db_path, status)
388
+ grouped_tasks = load_tasks_grouped_by_stage(db_path, status)
381
389
 
382
390
  self.start_graph(
383
- {
384
- stage_name: [record["task_json"] for record in records]
385
- for stage_name, records in grouped_records.items()
386
- },
391
+ grouped_tasks,
387
392
  put_termination_signal=put_termination_signal,
388
393
  )
389
394
 
@@ -519,7 +524,7 @@ class TaskGraph:
519
524
  running_pending_map: dict[str, int],
520
525
  ) -> dict[str, int]:
521
526
  """
522
- 根据 DAG/非 DAG 策略计算全局预计待处理任务数量
527
+ 根据 DAG/非 DAG 策略计算全局预计待处理任务数量。
523
528
 
524
529
  :param running_processed_map: 各节点已处理任务数
525
530
  :param running_pending_map: 各节点待处理任务数
@@ -529,7 +534,7 @@ class TaskGraph:
529
534
  return running_pending_map
530
535
 
531
536
  total_pending_map = calc_global_pending(
532
- self.networkx_graph,
537
+ self.order_graph,
533
538
  running_processed_map,
534
539
  running_pending_map,
535
540
  )
@@ -630,13 +635,13 @@ class TaskGraph:
630
635
  """
631
636
  return format_structure_list_from_graph(self.structure_graph)
632
637
 
633
- def get_networkx_graph(self) -> DiGraph[Any]:
638
+ def get_order_graph(self) -> OrderGraph:
634
639
  """
635
- 获取任务图的 networkx 有向图(DiGraph)
640
+ 获取任务图对应的有序有向图视图。
636
641
 
637
- :return: networkx.DiGraph 实例
642
+ :return: :class:`OrderGraph` 实例
638
643
  """
639
- return self.networkx_graph
644
+ return self.order_graph
640
645
 
641
646
  def get_fallback_path(self) -> Path:
642
647
  """