celestialflow 3.3.0__tar.gz → 3.3.2__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 (74) hide show
  1. {celestialflow-3.3.0/src/celestialflow.egg-info → celestialflow-3.3.2}/PKG-INFO +66 -69
  2. {celestialflow-3.3.0 → celestialflow-3.3.2}/README.md +65 -68
  3. {celestialflow-3.3.0 → celestialflow-3.3.2}/pyproject.toml +5 -1
  4. {celestialflow-3.3.0 → celestialflow-3.3.2}/src/celestialflow/__init__.py +12 -8
  5. celestialflow-3.3.2/src/celestialflow/assembly/__init__.py +13 -0
  6. celestialflow-3.3.2/src/celestialflow/assembly/core_run.py +143 -0
  7. {celestialflow-3.3.0 → celestialflow-3.3.2}/src/celestialflow/benchmark/util_benchmark.py +2 -2
  8. {celestialflow-3.3.0 → celestialflow-3.3.2}/src/celestialflow/benchmark/util_clone.py +18 -46
  9. {celestialflow-3.3.0 → celestialflow-3.3.2}/src/celestialflow/funnel/core_spout.py +2 -6
  10. {celestialflow-3.3.0 → celestialflow-3.3.2}/src/celestialflow/graph/core_graph.py +179 -167
  11. {celestialflow-3.3.0 → celestialflow-3.3.2}/src/celestialflow/node/core_dispatch.py +40 -37
  12. {celestialflow-3.3.0 → celestialflow-3.3.2}/src/celestialflow/node/core_node.py +219 -214
  13. celestialflow-3.3.2/src/celestialflow/node/core_nodes.py +222 -0
  14. {celestialflow-3.3.0 → celestialflow-3.3.2}/src/celestialflow/node/util_types.py +1 -1
  15. celestialflow-3.3.2/src/celestialflow/observer/__init__.py +43 -0
  16. celestialflow-3.3.2/src/celestialflow/observer/core_event.py +211 -0
  17. celestialflow-3.3.2/src/celestialflow/observer/core_hub.py +276 -0
  18. celestialflow-3.3.2/src/celestialflow/observer/core_metrics.py +198 -0
  19. celestialflow-3.3.2/src/celestialflow/observer/core_observer.py +139 -0
  20. celestialflow-3.3.2/src/celestialflow/observer/core_observer_print.py +98 -0
  21. {celestialflow-3.3.0/src/celestialflow/persistence → celestialflow-3.3.2/src/celestialflow/persist}/__init__.py +1 -11
  22. {celestialflow-3.3.0/src/celestialflow/persistence → celestialflow-3.3.2/src/celestialflow/persist}/core_lifecycle.py +86 -83
  23. celestialflow-3.3.2/src/celestialflow/persist/core_log.py +285 -0
  24. {celestialflow-3.3.0/src/celestialflow/persistence → celestialflow-3.3.2/src/celestialflow/persist}/util_payload.py +1 -1
  25. {celestialflow-3.3.0/src/celestialflow/persistence → celestialflow-3.3.2/src/celestialflow/persist}/util_sqlite.py +111 -35
  26. celestialflow-3.3.2/src/celestialflow/reporter/__init__.py +23 -0
  27. celestialflow-3.3.2/src/celestialflow/reporter/core_inject.py +77 -0
  28. celestialflow-3.3.2/src/celestialflow/reporter/core_push.py +251 -0
  29. celestialflow-3.3.2/src/celestialflow/reporter/core_snapshot.py +85 -0
  30. {celestialflow-3.3.0 → celestialflow-3.3.2}/src/celestialflow/runtime/__init__.py +14 -16
  31. celestialflow-3.3.2/src/celestialflow/runtime/core_envelope.py +38 -0
  32. {celestialflow-3.3.0 → celestialflow-3.3.2}/src/celestialflow/runtime/core_queue.py +238 -238
  33. celestialflow-3.3.2/src/celestialflow/runtime/util_config.py +100 -0
  34. celestialflow-3.3.2/src/celestialflow/runtime/util_types.py +177 -0
  35. celestialflow-3.3.2/src/celestialflow/ticker/__init__.py +18 -0
  36. celestialflow-3.3.2/src/celestialflow/ticker/core_event.py +30 -0
  37. celestialflow-3.3.2/src/celestialflow/ticker/core_handler.py +87 -0
  38. celestialflow-3.3.2/src/celestialflow/ticker/core_hub.py +99 -0
  39. celestialflow-3.3.2/src/celestialflow/ticker/core_ticker.py +204 -0
  40. {celestialflow-3.3.0 → celestialflow-3.3.2/src/celestialflow.egg-info}/PKG-INFO +66 -69
  41. {celestialflow-3.3.0 → celestialflow-3.3.2}/src/celestialflow.egg-info/SOURCES.txt +24 -16
  42. celestialflow-3.3.0/src/celestialflow/graph/util_estimators.py +0 -94
  43. celestialflow-3.3.0/src/celestialflow/node/core_nodes.py +0 -332
  44. celestialflow-3.3.0/src/celestialflow/observability/__init__.py +0 -15
  45. celestialflow-3.3.0/src/celestialflow/observability/core_observer.py +0 -112
  46. celestialflow-3.3.0/src/celestialflow/observability/core_report.py +0 -292
  47. celestialflow-3.3.0/src/celestialflow/observability/util_types.py +0 -37
  48. celestialflow-3.3.0/src/celestialflow/persistence/core_log.py +0 -517
  49. celestialflow-3.3.0/src/celestialflow/persistence/core_scope.py +0 -41
  50. celestialflow-3.3.0/src/celestialflow/runtime/core_envelope.py +0 -60
  51. celestialflow-3.3.0/src/celestialflow/runtime/core_metrics.py +0 -309
  52. celestialflow-3.3.0/src/celestialflow/runtime/util_config.py +0 -40
  53. celestialflow-3.3.0/src/celestialflow/runtime/util_estimators.py +0 -68
  54. celestialflow-3.3.0/src/celestialflow/runtime/util_hash.py +0 -39
  55. celestialflow-3.3.0/src/celestialflow/runtime/util_types.py +0 -181
  56. {celestialflow-3.3.0 → celestialflow-3.3.2}/LICENSE +0 -0
  57. {celestialflow-3.3.0 → celestialflow-3.3.2}/setup.cfg +0 -0
  58. {celestialflow-3.3.0 → celestialflow-3.3.2}/src/celestialflow/benchmark/__init__.py +0 -0
  59. {celestialflow-3.3.0 → celestialflow-3.3.2}/src/celestialflow/funnel/__init__.py +0 -0
  60. {celestialflow-3.3.0 → celestialflow-3.3.2}/src/celestialflow/funnel/core_inlet.py +0 -0
  61. {celestialflow-3.3.0 → celestialflow-3.3.2}/src/celestialflow/funnel/util_count.py +0 -0
  62. {celestialflow-3.3.0 → celestialflow-3.3.2}/src/celestialflow/graph/__init__.py +0 -0
  63. {celestialflow-3.3.0 → celestialflow-3.3.2}/src/celestialflow/graph/core_structure.py +0 -0
  64. {celestialflow-3.3.0 → celestialflow-3.3.2}/src/celestialflow/graph/util_order_graph.py +0 -0
  65. {celestialflow-3.3.0 → celestialflow-3.3.2}/src/celestialflow/node/__init__.py +0 -0
  66. {celestialflow-3.3.0 → celestialflow-3.3.2}/src/celestialflow/node/util_callable.py +0 -0
  67. {celestialflow-3.3.0/src/celestialflow/graph → celestialflow-3.3.2/src/celestialflow/persist}/util_render.py +0 -0
  68. {celestialflow-3.3.0 → celestialflow-3.3.2}/src/celestialflow/runtime/util_constant.py +0 -0
  69. {celestialflow-3.3.0 → celestialflow-3.3.2}/src/celestialflow/runtime/util_errors.py +0 -0
  70. {celestialflow-3.3.0 → celestialflow-3.3.2}/src/celestialflow/runtime/util_event.py +0 -0
  71. {celestialflow-3.3.0 → celestialflow-3.3.2}/src/celestialflow/runtime/util_format.py +0 -0
  72. {celestialflow-3.3.0 → celestialflow-3.3.2}/src/celestialflow.egg-info/dependency_links.txt +0 -0
  73. {celestialflow-3.3.0 → celestialflow-3.3.2}/src/celestialflow.egg-info/requires.txt +0 -0
  74. {celestialflow-3.3.0 → celestialflow-3.3.2}/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.3.0
3
+ Version: 3.3.2
4
4
  Summary: A flexible GRAPH-based task orchestration framework.
5
5
  Author-email: Mr-xiaotian <mingxiaomingtian@gmail.com>
6
6
  License: MIT
@@ -19,6 +19,8 @@ Dynamic: license-file
19
19
 
20
20
  # CelestialFlow ——一个轻量级、可并行、基于图结构的 Python 任务调度框架
21
21
 
22
+ > 📅 最后更新日期: 2026/09/24
23
+
22
24
  <p align="center">
23
25
  <img src="https://raw.githubusercontent.com/Mr-xiaotian/CelestialFlow/main/img/logo.png" width="1080" alt="CelestialFlow Logo">
24
26
  </p>
@@ -263,42 +265,45 @@ flowchart TD
263
265
  ## 文件结构(File Structure)
264
266
 
265
267
  ```
266
- 📁 CelestialFlow (664MB 611KB 462B)
267
- 📁 bench (296KB 101B)
268
- 📁 [1项排除的目录] (194KB 222B)
268
+ 📁 CelestialFlow (539MB 107KB 283B)
269
+ 📁 bench (316KB 409B)
270
+ 📁 [1项排除的目录] (193KB 163B)
269
271
  🐍 bench_datastructures.py (6KB 690B)
270
272
  🐍 bench_execution_mode.py (2KB 707B)
273
+ 🐍 bench_funnel_vs_lock.py (21KB 888B)
271
274
  🐍 bench_futures_memory.py (2KB 269B)
272
- 🐍 bench_gil_vs_nogil.py (10KB 101B)
273
- 🐍 bench_graph_mode.py (6KB 774B)
275
+ 🐍 bench_gil_vs_nogil.py (10KB 552B)
276
+ 🐍 bench_graph_mode.py (6KB 614B)
274
277
  🐍 bench_hash.py (7KB 67B)
275
278
  🐍 bench_hash_container.py (3KB 1009B)
276
- 🐍 bench_hash_memory.py (3KB 642B)
277
- 🐍 bench_http_grpc.py (2KB 536B)
279
+ 🐍 bench_hash_memory.py (3KB 655B)
280
+ 🐍 bench_http_grpc.py (2KB 530B)
278
281
  🐍 bench_ipc_queue.py (7KB 104B)
279
282
  🐍 bench_lock_overhead.py (9KB 421B)
280
283
  🐍 bench_mpqueue_vs_shared_memory.py (13KB 127B)
281
- 🐍 bench_observer.py (7KB 860B)
282
- 🐍 bench_persistence_spout.py (4KB 340B)
284
+ 🐍 bench_observer.py (7KB 58B)
285
+ 🐍 bench_persist_spout.py (4KB 323B)
283
286
  🐍 bench_queue.py (5KB 857B)
284
287
  🐍 bench_requests.py (6KB 813B)
285
288
  🐍 bench_tqdm.py (1KB 235B)
286
289
  🐍 bench_utils.py (543B)
287
- 📁 demo (146KB 197B)
288
- 📁 [1项排除的目录] (100KB 9B)
289
- 🐍 demo_executor.py (1KB 495B)
290
- 🐍 demo_funnel.py (2KB 289B)
291
- 🐍 demo_graph.py (3KB 222B)
292
- 🐍 demo_network.py (3KB 756B)
293
- 🐍 demo_nodes.py (4KB 212B)
294
- 🐍 demo_observer.py (4KB 270B)
295
- 🐍 demo_redis.py (9KB 131B)
296
- 🐍 demo_structure.py (11KB 737B)
297
- 🐍 demo_utils.py (6KB 148B)
298
- 📁 docs (1MB 914KB 89B)
299
- 📁 en[已折叠] (632KB 604B)
300
- 📁 ja[已折叠] (718KB 778B)
301
- 📁 zh-CN[已折叠] (586KB 755B)
290
+ 📁 demo (604KB 612B)
291
+ 📁 [3项排除的目录] (548KB 510B)
292
+ 🐍 demo_executor.py (1KB 557B)
293
+ 🐍 demo_funnel.py (2KB 289B)
294
+ 🐍 demo_graph.py (2KB 975B)
295
+ 🐍 demo_network.py (3KB 756B)
296
+ 🐍 demo_nodes.py (3KB 915B)
297
+ 🐍 demo_observer.py (2KB 1004B)
298
+ 🐍 demo_redis.py (8KB 595B)
299
+ 🐍 demo_skip_dedup.py (6KB 286B)
300
+ 🐍 demo_structure.py (8KB 448B)
301
+ 🐍 demo_utils.py (6KB 263B)
302
+ 🐍 demo_web.py (9KB 158B)
303
+ 📁 docs (2MB 40KB 774B)
304
+ 📁 en[已折叠] (689KB 413B)
305
+ 📁 ja[已折叠] (788KB 343B)
306
+ 📁 zh-CN[已折叠] (611KB 18B)
302
307
  📁 experiments (3KB 21B)
303
308
  🐍 experiment_networkx.py (1KB 908B)
304
309
  🐍 experiment_tqdm.py (1KB 137B)
@@ -307,63 +312,55 @@ flowchart TD
307
312
  📷 logo(old).png (836KB 542B)
308
313
  📷 logo.png (122KB 747B)
309
314
  📷 scc_condensation.svg (17KB 1B)
310
- 📁 src (1MB 822KB 642B)
311
- 📁 celestialflow[已折叠] (1MB 822KB 642B)
312
- 📁 tests (4MB 290KB 989B)
313
- 📁 benchmark[已折叠] (45KB 270B)
314
- 📁 funnel[已折叠] (96KB 339B)
315
- 📁 graph[已折叠] (768KB 424B)
316
- 📁 node[已折叠] (451KB 840B)
317
- 📁 observability[已折叠] (188KB 1001B)
318
- 📁 persistence[已折叠] (393KB 151B)
319
- 📁 runtime[已折叠] (1MB 290KB 858B)
320
- 📁 [1项排除的目录] (487KB 637B)
321
- 🐍 conftest.py (1KB 38B)
322
- 📁 [12项排除的目录] (650MB 21KB 212B)
315
+ 📁 src (1MB 670KB 974B)
316
+ 📁 celestialflow[已折叠] (1MB 651KB 430B)
317
+ 📁 [1项排除的目录] (19KB 544B)
318
+ 📁 tests (3MB 34KB 484B)
319
+ 📁 assembly[已折叠] (38KB 341B)
320
+ 📁 benchmark[已折叠] (41KB 377B)
321
+ 📁 funnel[已折叠] (96KB 339B)
322
+ 📁 graph[已折叠] (801KB 83B)
323
+ 📁 node[已折叠] (512KB 601B)
324
+ 📁 observer[已折叠] (121KB 111B)
325
+ 📁 persist[已折叠] (207KB 907B)
326
+ 📁 persistence[已折叠] (381KB 89B)
327
+ 📁 reporter[已折叠] (171KB 861B)
328
+ 📁 runtime[已折叠] (189KB 873B)
329
+ 📁 ticker[已折叠] (54KB 761B)
330
+ 📁 [1项排除的目录] (488KB 592B)
331
+ 🐍 conftest.py (1KB 693B)
332
+ 📁 [13项排除的目录] (525MB 488KB 753B)
323
333
  ❓ .env (468B)
324
334
  ❓ .gitignore (1KB 315B)
325
- 📝 AGENTS.md (1KB 434B)
335
+ 📝 AGENTS.md (1KB 1003B)
326
336
  ❓ LICENSE (1KB 65B)
327
337
  ❓ Makefile (149B)
328
- ⚙️ pyproject.toml (2KB 668B)
329
- 📝 README.md (17KB 298B)
330
- 🔒 uv.lock (120KB 752B)
338
+ ⚙️ pyproject.toml (2KB 858B)
339
+ 📝 README.md (16KB 619B)
340
+ 🔒 uv.lock (124KB 729B)
331
341
  ```
332
342
  <p align="center">
333
- <em>celestial-flow 3.3.0</em>
343
+ <em>celestial-flow 3.3.2</em>
334
344
  </p>
335
345
 
336
346
  (该视图由我的另一个项目[CelestialVault](https://github.com/Mr-xiaotian/CelestialVault)中inst_file.FileTree.print_tree()生成。转换为图片则借助[Carbon](https://carbon.now.sh)。)
337
347
 
338
348
  ## 版本日志(Version Log)
339
- - 3.3.0
349
+ - 3.3.2
340
350
  - feat:
341
- - 现在 `TaskExecutor` 中完全删除了 `func_name` 参数
342
- - 在有 `executor_name` 表达节点后, 这层暴露是不必要的
343
- - 同时也是为了与 `CelestialGraw` 的状态做统一
344
- - 在向 `reporter` 发送状态时, 包含图的 `class_name` 信息
345
- - 移除 `OrderGraph` 中的 `from_edges` 方法
351
+ - [IMPORTANT] 大幅扩充 `observer` 机制, 添加更多钩子
352
+ - 添加 `ObserverHub` 进行管理, 其本身也是 `observer`
353
+ - [IMPORTANT] 添加 `ticker` 机制, 以周期性的时间为驱动
354
+ - 作为纯事件驱动的 `observer` 的补充
355
+ - 由于 `reprter` 机制的完全重构, 其开启与使用方法也有所变化
356
+ - 改为在 `.pyproject` 中进行设置
346
357
  - refactor:
347
- - [IMPORTANT] 重构原有的 `executor/stage` 结构
348
- - 原本为 `executor -> stage -> splitter/router`, 三层结构过于复杂
349
- - 现在删除 `stage` 层, 添加 `BaseTaskNode`, 作为 graph 唯一识别的节点, 而 `executor` 视为与 `splitter/router` 同级别的节点
350
- - 当前结构为 `BaseTaskNode -> executor/splitter/router`
351
- - 重构 `render_structure_list`(原 `format_structure_list_from_graph`) 的实现
352
- - 现在使用广度优先, 而不是原先的递归
353
- - 同时输入参数直接使用 `list[str]` 形式的节点名称列表, 这意味着不再显示 `func_name` `execution_mode` 等信息
354
- - 修改原本对于 `collect_runtime_snapshot` 奇怪的调用方式
355
- - 现在reporter端会在 `_push_status` 中直接调用 `collect_runtime_snapshot`
356
- - 删除 `TaskExecutor` 中的 `get_summary`, 这层包装实际上是多余的
357
- - 同时所有的 `event_client.emit` 也不再附带 `summary` 信息
358
- - 删除 `OrderGraph` 中的 `_node` 参数
359
- - 之前这个参数提供: 所有节点名称; 节点的插入顺序
360
- - 现在前者由 `_out` 提供, 后者不再重视
361
- - `LifecycleInlet` 中的 `task_in` 改名为 `task_input`, 保持与 log 端一致
362
- - fix:
363
- - 修复 `execution_mode = async` 时, worker崩溃被忽略的问题
364
- - 修复任务重试日志中 `retry_times` 的含义模糊, 现在使用 `fail_times`
365
- - 修复 reporter 的 `_push_*` 方法中, 不处理返回值的问题
366
- - 修复 `TaskReporter._pull_injection` 中, 对拉取的任务列表错误 `put_task` 的问题
358
+ - [IMPORTANT] 将 `log` / `lifecycle` 归并入新的 `observer` 体系
359
+ - 结构更加简洁高效
360
+ - [IMPORTANT] 将 `reporter` 拆为 完全分离的 `push` 与 `pull`
361
+ - 前者由 `PushInlet` 进行事件化收集 `error` `meta` 数据, 并由 `PushSnapshotHandler` 周期化收集状态信息
362
+ - 后者由 `InjectionHandler` 周期化从服务端收集注入任务与注入终止符
363
+ - 将 `metric` 机制归入 `observer` 体系
367
364
 
368
365
  更多过往日志可看:
369
366
 
@@ -1,5 +1,7 @@
1
1
  # CelestialFlow ——一个轻量级、可并行、基于图结构的 Python 任务调度框架
2
2
 
3
+ > 📅 最后更新日期: 2026/09/24
4
+
3
5
  <p align="center">
4
6
  <img src="https://raw.githubusercontent.com/Mr-xiaotian/CelestialFlow/main/img/logo.png" width="1080" alt="CelestialFlow Logo">
5
7
  </p>
@@ -244,42 +246,45 @@ flowchart TD
244
246
  ## 文件结构(File Structure)
245
247
 
246
248
  ```
247
- 📁 CelestialFlow (664MB 611KB 462B)
248
- 📁 bench (296KB 101B)
249
- 📁 [1项排除的目录] (194KB 222B)
249
+ 📁 CelestialFlow (539MB 107KB 283B)
250
+ 📁 bench (316KB 409B)
251
+ 📁 [1项排除的目录] (193KB 163B)
250
252
  🐍 bench_datastructures.py (6KB 690B)
251
253
  🐍 bench_execution_mode.py (2KB 707B)
254
+ 🐍 bench_funnel_vs_lock.py (21KB 888B)
252
255
  🐍 bench_futures_memory.py (2KB 269B)
253
- 🐍 bench_gil_vs_nogil.py (10KB 101B)
254
- 🐍 bench_graph_mode.py (6KB 774B)
256
+ 🐍 bench_gil_vs_nogil.py (10KB 552B)
257
+ 🐍 bench_graph_mode.py (6KB 614B)
255
258
  🐍 bench_hash.py (7KB 67B)
256
259
  🐍 bench_hash_container.py (3KB 1009B)
257
- 🐍 bench_hash_memory.py (3KB 642B)
258
- 🐍 bench_http_grpc.py (2KB 536B)
260
+ 🐍 bench_hash_memory.py (3KB 655B)
261
+ 🐍 bench_http_grpc.py (2KB 530B)
259
262
  🐍 bench_ipc_queue.py (7KB 104B)
260
263
  🐍 bench_lock_overhead.py (9KB 421B)
261
264
  🐍 bench_mpqueue_vs_shared_memory.py (13KB 127B)
262
- 🐍 bench_observer.py (7KB 860B)
263
- 🐍 bench_persistence_spout.py (4KB 340B)
265
+ 🐍 bench_observer.py (7KB 58B)
266
+ 🐍 bench_persist_spout.py (4KB 323B)
264
267
  🐍 bench_queue.py (5KB 857B)
265
268
  🐍 bench_requests.py (6KB 813B)
266
269
  🐍 bench_tqdm.py (1KB 235B)
267
270
  🐍 bench_utils.py (543B)
268
- 📁 demo (146KB 197B)
269
- 📁 [1项排除的目录] (100KB 9B)
270
- 🐍 demo_executor.py (1KB 495B)
271
- 🐍 demo_funnel.py (2KB 289B)
272
- 🐍 demo_graph.py (3KB 222B)
273
- 🐍 demo_network.py (3KB 756B)
274
- 🐍 demo_nodes.py (4KB 212B)
275
- 🐍 demo_observer.py (4KB 270B)
276
- 🐍 demo_redis.py (9KB 131B)
277
- 🐍 demo_structure.py (11KB 737B)
278
- 🐍 demo_utils.py (6KB 148B)
279
- 📁 docs (1MB 914KB 89B)
280
- 📁 en[已折叠] (632KB 604B)
281
- 📁 ja[已折叠] (718KB 778B)
282
- 📁 zh-CN[已折叠] (586KB 755B)
271
+ 📁 demo (604KB 612B)
272
+ 📁 [3项排除的目录] (548KB 510B)
273
+ 🐍 demo_executor.py (1KB 557B)
274
+ 🐍 demo_funnel.py (2KB 289B)
275
+ 🐍 demo_graph.py (2KB 975B)
276
+ 🐍 demo_network.py (3KB 756B)
277
+ 🐍 demo_nodes.py (3KB 915B)
278
+ 🐍 demo_observer.py (2KB 1004B)
279
+ 🐍 demo_redis.py (8KB 595B)
280
+ 🐍 demo_skip_dedup.py (6KB 286B)
281
+ 🐍 demo_structure.py (8KB 448B)
282
+ 🐍 demo_utils.py (6KB 263B)
283
+ 🐍 demo_web.py (9KB 158B)
284
+ 📁 docs (2MB 40KB 774B)
285
+ 📁 en[已折叠] (689KB 413B)
286
+ 📁 ja[已折叠] (788KB 343B)
287
+ 📁 zh-CN[已折叠] (611KB 18B)
283
288
  📁 experiments (3KB 21B)
284
289
  🐍 experiment_networkx.py (1KB 908B)
285
290
  🐍 experiment_tqdm.py (1KB 137B)
@@ -288,63 +293,55 @@ flowchart TD
288
293
  📷 logo(old).png (836KB 542B)
289
294
  📷 logo.png (122KB 747B)
290
295
  📷 scc_condensation.svg (17KB 1B)
291
- 📁 src (1MB 822KB 642B)
292
- 📁 celestialflow[已折叠] (1MB 822KB 642B)
293
- 📁 tests (4MB 290KB 989B)
294
- 📁 benchmark[已折叠] (45KB 270B)
295
- 📁 funnel[已折叠] (96KB 339B)
296
- 📁 graph[已折叠] (768KB 424B)
297
- 📁 node[已折叠] (451KB 840B)
298
- 📁 observability[已折叠] (188KB 1001B)
299
- 📁 persistence[已折叠] (393KB 151B)
300
- 📁 runtime[已折叠] (1MB 290KB 858B)
301
- 📁 [1项排除的目录] (487KB 637B)
302
- 🐍 conftest.py (1KB 38B)
303
- 📁 [12项排除的目录] (650MB 21KB 212B)
296
+ 📁 src (1MB 670KB 974B)
297
+ 📁 celestialflow[已折叠] (1MB 651KB 430B)
298
+ 📁 [1项排除的目录] (19KB 544B)
299
+ 📁 tests (3MB 34KB 484B)
300
+ 📁 assembly[已折叠] (38KB 341B)
301
+ 📁 benchmark[已折叠] (41KB 377B)
302
+ 📁 funnel[已折叠] (96KB 339B)
303
+ 📁 graph[已折叠] (801KB 83B)
304
+ 📁 node[已折叠] (512KB 601B)
305
+ 📁 observer[已折叠] (121KB 111B)
306
+ 📁 persist[已折叠] (207KB 907B)
307
+ 📁 persistence[已折叠] (381KB 89B)
308
+ 📁 reporter[已折叠] (171KB 861B)
309
+ 📁 runtime[已折叠] (189KB 873B)
310
+ 📁 ticker[已折叠] (54KB 761B)
311
+ 📁 [1项排除的目录] (488KB 592B)
312
+ 🐍 conftest.py (1KB 693B)
313
+ 📁 [13项排除的目录] (525MB 488KB 753B)
304
314
  ❓ .env (468B)
305
315
  ❓ .gitignore (1KB 315B)
306
- 📝 AGENTS.md (1KB 434B)
316
+ 📝 AGENTS.md (1KB 1003B)
307
317
  ❓ LICENSE (1KB 65B)
308
318
  ❓ Makefile (149B)
309
- ⚙️ pyproject.toml (2KB 668B)
310
- 📝 README.md (17KB 298B)
311
- 🔒 uv.lock (120KB 752B)
319
+ ⚙️ pyproject.toml (2KB 858B)
320
+ 📝 README.md (16KB 619B)
321
+ 🔒 uv.lock (124KB 729B)
312
322
  ```
313
323
  <p align="center">
314
- <em>celestial-flow 3.3.0</em>
324
+ <em>celestial-flow 3.3.2</em>
315
325
  </p>
316
326
 
317
327
  (该视图由我的另一个项目[CelestialVault](https://github.com/Mr-xiaotian/CelestialVault)中inst_file.FileTree.print_tree()生成。转换为图片则借助[Carbon](https://carbon.now.sh)。)
318
328
 
319
329
  ## 版本日志(Version Log)
320
- - 3.3.0
330
+ - 3.3.2
321
331
  - feat:
322
- - 现在 `TaskExecutor` 中完全删除了 `func_name` 参数
323
- - 在有 `executor_name` 表达节点后, 这层暴露是不必要的
324
- - 同时也是为了与 `CelestialGraw` 的状态做统一
325
- - 在向 `reporter` 发送状态时, 包含图的 `class_name` 信息
326
- - 移除 `OrderGraph` 中的 `from_edges` 方法
332
+ - [IMPORTANT] 大幅扩充 `observer` 机制, 添加更多钩子
333
+ - 添加 `ObserverHub` 进行管理, 其本身也是 `observer`
334
+ - [IMPORTANT] 添加 `ticker` 机制, 以周期性的时间为驱动
335
+ - 作为纯事件驱动的 `observer` 的补充
336
+ - 由于 `reprter` 机制的完全重构, 其开启与使用方法也有所变化
337
+ - 改为在 `.pyproject` 中进行设置
327
338
  - refactor:
328
- - [IMPORTANT] 重构原有的 `executor/stage` 结构
329
- - 原本为 `executor -> stage -> splitter/router`, 三层结构过于复杂
330
- - 现在删除 `stage` 层, 添加 `BaseTaskNode`, 作为 graph 唯一识别的节点, 而 `executor` 视为与 `splitter/router` 同级别的节点
331
- - 当前结构为 `BaseTaskNode -> executor/splitter/router`
332
- - 重构 `render_structure_list`(原 `format_structure_list_from_graph`) 的实现
333
- - 现在使用广度优先, 而不是原先的递归
334
- - 同时输入参数直接使用 `list[str]` 形式的节点名称列表, 这意味着不再显示 `func_name` `execution_mode` 等信息
335
- - 修改原本对于 `collect_runtime_snapshot` 奇怪的调用方式
336
- - 现在reporter端会在 `_push_status` 中直接调用 `collect_runtime_snapshot`
337
- - 删除 `TaskExecutor` 中的 `get_summary`, 这层包装实际上是多余的
338
- - 同时所有的 `event_client.emit` 也不再附带 `summary` 信息
339
- - 删除 `OrderGraph` 中的 `_node` 参数
340
- - 之前这个参数提供: 所有节点名称; 节点的插入顺序
341
- - 现在前者由 `_out` 提供, 后者不再重视
342
- - `LifecycleInlet` 中的 `task_in` 改名为 `task_input`, 保持与 log 端一致
343
- - fix:
344
- - 修复 `execution_mode = async` 时, worker崩溃被忽略的问题
345
- - 修复任务重试日志中 `retry_times` 的含义模糊, 现在使用 `fail_times`
346
- - 修复 reporter 的 `_push_*` 方法中, 不处理返回值的问题
347
- - 修复 `TaskReporter._pull_injection` 中, 对拉取的任务列表错误 `put_task` 的问题
339
+ - [IMPORTANT] 将 `log` / `lifecycle` 归并入新的 `observer` 体系
340
+ - 结构更加简洁高效
341
+ - [IMPORTANT] 将 `reporter` 拆为 完全分离的 `push` 与 `pull`
342
+ - 前者由 `PushInlet` 进行事件化收集 `error` `meta` 数据, 并由 `PushSnapshotHandler` 周期化收集状态信息
343
+ - 后者由 `InjectionHandler` 周期化从服务端收集注入任务与注入终止符
344
+ - 将 `metric` 机制归入 `observer` 体系
348
345
 
349
346
  更多过往日志可看:
350
347
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "celestialflow"
7
- version = "3.3.0"
7
+ version = "3.3.2"
8
8
  description = "A flexible GRAPH-based task orchestration framework."
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
@@ -61,6 +61,10 @@ dev = [
61
61
 
62
62
  [tool.celestialflow]
63
63
  log_level = "INFO"
64
+ # 是否启用上报;默认关闭,需显式开启(开启时 report_url 必填)
65
+ if_report = false
66
+ # 上报服务地址(CelestialFlow Web)
67
+ report_url = "http://127.0.0.1:5005"
64
68
 
65
69
  [tool.pyright]
66
70
  include = ["src"]
@@ -20,19 +20,21 @@ from .node import (
20
20
  TaskRouter,
21
21
  TaskSplitter,
22
22
  )
23
- from .observability import BaseObserver, TaskReporter
24
- from .persistence.util_sqlite import (
23
+ from .observer import Observer, ObserverHub, PrintObserver
24
+ from .persist.util_sqlite import (
25
25
  load_records,
26
- load_tasks_grouped_by_stage,
26
+ load_tasks_grouped_by_node,
27
27
  )
28
28
  from .runtime.util_format import format_table
29
- from .runtime.util_hash import make_hashable
30
29
  from .runtime.util_types import TerminationSignal
30
+ from .ticker import Ticker, TickEvent, TickHandler, TickHub
31
31
 
32
32
  __all__ = [
33
33
  "BaseInlet",
34
- "BaseObserver",
35
34
  "BaseSpout",
35
+ "Observer",
36
+ "ObserverHub",
37
+ "PrintObserver",
36
38
  "TaskChain",
37
39
  "TaskComplete",
38
40
  "TaskCross",
@@ -40,15 +42,17 @@ __all__ = [
40
42
  "TaskGraph",
41
43
  "TaskGrid",
42
44
  "TaskLoop",
43
- "TaskReporter",
44
45
  "TaskRouter",
45
46
  "TaskSplitter",
46
47
  "TaskWheel",
47
48
  "TerminationSignal",
49
+ "TickEvent",
50
+ "TickHandler",
51
+ "TickHub",
52
+ "Ticker",
48
53
  "benchmark_executor",
49
54
  "benchmark_graph",
50
55
  "format_table",
51
56
  "load_records",
52
- "load_tasks_grouped_by_stage",
53
- "make_hashable",
57
+ "load_tasks_grouped_by_node",
54
58
  ]
@@ -0,0 +1,13 @@
1
+ # assembly/__init__.py
2
+ """CelestialFlow 运行期资源装配模块。
3
+
4
+ 负责把 lifecycle / log / 上报三类全局 funnel 观察者注册到运行期 hub,
5
+ 并统一管理其 spout 的启停。
6
+ """
7
+
8
+ from .core_run import run_graph_resources, run_node_resources
9
+
10
+ __all__ = [
11
+ "run_graph_resources",
12
+ "run_node_resources",
13
+ ]
@@ -0,0 +1,143 @@
1
+ # assembly/core_run.py
2
+ from __future__ import annotations
3
+
4
+ import uuid
5
+ from collections.abc import Generator
6
+ from contextlib import contextmanager
7
+ from pathlib import Path
8
+
9
+ import requests
10
+
11
+ from ..observer import MetricsObserver, ObserverHub
12
+ from ..persist.core_lifecycle import LifecycleInlet, LifecycleSpout
13
+ from ..persist.core_log import LogInlet, LogSpout
14
+ from ..reporter import (
15
+ InjectionHandler,
16
+ InjectionTarget,
17
+ PushInlet,
18
+ PushSnapshotHandler,
19
+ PushSpout,
20
+ )
21
+ from ..runtime.util_config import (
22
+ load_if_report_from_pyproject,
23
+ load_log_level_from_pyproject,
24
+ load_report_url_from_pyproject,
25
+ )
26
+ from ..ticker import Ticker, TickHub
27
+
28
+ _TICK_INTERVAL: float = 1.0
29
+ """节拍器基准周期(秒)。各处理器以自己的 ``tick_period`` 缩放出实际周期。"""
30
+
31
+
32
+ @contextmanager
33
+ def run_graph_resources(
34
+ observers: ObserverHub,
35
+ injection_target: InjectionTarget,
36
+ ) -> Generator[Path | None, None, None]:
37
+ """
38
+ 任务图运行期资源:``metrics`` + ``lifecycle`` + ``log``,并按 ``if_report``
39
+ 决定是否追加远程上报与注入。
40
+
41
+ 指标写模型由本入口创建并注册到 ``observers``,其只读视图交给 ``LogInlet``
42
+ 与快照处理器。上报开关从项目级 ``pyproject.toml`` 的
43
+ ``[tool.celestialflow]`` 节读取:仅当 ``if_report`` 显式配置为 ``true`` 时启用
44
+ 上报,此时本入口自行生成一个不透明的上报会话标识,注册 :class:`PushInlet` 与
45
+ :class:`PushSnapshotHandler`、启动 :class:`PushSpout` 并启动一个以
46
+ :data:`_TICK_INTERVAL` 为基准周期的节拍器,按拍把状态快照推送到远端(并在图
47
+ 结束时补推一次终态快照),同时按拍从远端拉取任务注入到 ``injection_target``
48
+ (``report_url`` 未配置时回退到
49
+ :data:`~celestialflow.runtime.util_config.DEFAULT_REPORT_URL`)。
50
+
51
+ 退出时先停节拍器再统一停止 spout,保证运行期即使抛出异常也能完成回收。
52
+
53
+ :param observers: 任务图自身的观察者 hub
54
+ :param injection_target: 任务注入目标,通常是任务图自身
55
+ :return: 进入时产出 lifecycle 数据库路径,未就绪时为 ``None``
56
+ """
57
+ log_level = load_log_level_from_pyproject()
58
+
59
+ metrics_view = MetricsObserver()
60
+ observers.add_observer(metrics_view)
61
+
62
+ lifecycle_spout = LifecycleSpout()
63
+ log_spout = LogSpout()
64
+ observers.add_observer(LifecycleInlet().bind_spout(lifecycle_spout))
65
+ observers.add_observer(LogInlet(metrics_view, log_level).bind_spout(log_spout))
66
+
67
+ push_spout: PushSpout | None = None
68
+ session: requests.Session | None = None
69
+ ticker: Ticker | None = None
70
+ if load_if_report_from_pyproject():
71
+ session_id = uuid.uuid4().hex
72
+ push_spout = PushSpout(session_id, load_report_url_from_pyproject())
73
+ push_inlet = PushInlet().bind_spout(push_spout)
74
+
75
+ session = requests.Session()
76
+ hub = TickHub()
77
+ snapshot_handler = PushSnapshotHandler(metrics_view, push_inlet)
78
+ hub.add_handler(snapshot_handler)
79
+ hub.add_handler(
80
+ InjectionHandler(
81
+ push_spout.base_url,
82
+ session_id,
83
+ injection_target,
84
+ session,
85
+ )
86
+ )
87
+ ticker = Ticker(_TICK_INTERVAL, hub, name="report")
88
+
89
+ # 快照处理器同时观察 on_graph_end 补推终态快照;注册在 PushInlet 之前,
90
+ # 保证终态快照先于 shutdown_session 入队。
91
+ observers.add_observer(snapshot_handler)
92
+ observers.add_observer(push_inlet)
93
+
94
+ try:
95
+ lifecycle_spout.start()
96
+ log_spout.start()
97
+ if push_spout is not None:
98
+ push_spout.start()
99
+ if ticker is not None:
100
+ ticker.start()
101
+ yield lifecycle_spout.db_path
102
+ finally:
103
+ if ticker is not None:
104
+ ticker.stop()
105
+ lifecycle_spout.stop()
106
+ log_spout.stop()
107
+ if push_spout is not None:
108
+ push_spout.stop()
109
+ if session is not None:
110
+ session.close()
111
+
112
+
113
+ @contextmanager
114
+ def run_node_resources(
115
+ observers: ObserverHub,
116
+ ) -> Generator[Path | None, None, None]:
117
+ """
118
+ 单节点运行期资源:内部创建并注册指标观察者,仅装配 ``lifecycle`` + ``log``。
119
+
120
+ 独立运行的节点不产生图结构、也不参与图级上报,因此本入口既不接收会话标识,
121
+ 也不装配推送通道、节拍器或注入目标;指标观察者由本入口创建并注册,运行结束后
122
+ 无需外部持有。退出时统一停止 spout,保证运行期即使抛出异常也能完成回收。
123
+
124
+ :param observers: 节点自身的观察者 hub
125
+ :return: 进入时产出 lifecycle 数据库路径,未就绪时为 ``None``
126
+ """
127
+ log_level = load_log_level_from_pyproject()
128
+
129
+ metrics_view = MetricsObserver()
130
+ observers.add_observer(metrics_view)
131
+
132
+ lifecycle_spout = LifecycleSpout()
133
+ log_spout = LogSpout()
134
+ observers.add_observer(LifecycleInlet().bind_spout(lifecycle_spout))
135
+ observers.add_observer(LogInlet(metrics_view, log_level).bind_spout(log_spout))
136
+
137
+ try:
138
+ lifecycle_spout.start()
139
+ log_spout.start()
140
+ yield lifecycle_spout.db_path
141
+ finally:
142
+ lifecycle_spout.stop()
143
+ log_spout.stop()
@@ -82,7 +82,7 @@ async def benchmark_graph(
82
82
  execution_modes = execution_modes or ["serial", "thread", "async"]
83
83
 
84
84
  base_tasks: dict[str, list[Any]] = {
85
- stage_name: list(tasks) for stage_name, tasks in init_tasks_dict.items()
85
+ node_name: list(tasks) for node_name, tasks in init_tasks_dict.items()
86
86
  }
87
87
 
88
88
  test_table_list: list[list[float]] = []
@@ -100,7 +100,7 @@ async def benchmark_graph(
100
100
  cloned_graph.set_node_execution_mode(execution_mode)
101
101
 
102
102
  run_tasks: dict[str, Iterable[Any]] = {
103
- stage_name: list(tasks) for stage_name, tasks in base_tasks.items()
103
+ node_name: list(tasks) for node_name, tasks in base_tasks.items()
104
104
  }
105
105
  start_time = time.perf_counter()
106
106
  if graph_mode == "async":