stageflow-framework 0.1.6__tar.gz → 0.10.0__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 (98) hide show
  1. stageflow_framework-0.10.0/LICENSE +21 -0
  2. stageflow_framework-0.10.0/PKG-INFO +186 -0
  3. stageflow_framework-0.10.0/README.md +153 -0
  4. stageflow_framework-0.10.0/pyproject.toml +54 -0
  5. stageflow_framework-0.10.0/stageflow/__init__.py +99 -0
  6. {stageflow_framework-0.1.6 → stageflow_framework-0.10.0}/stageflow/builtins/__init__.py +12 -15
  7. stageflow_framework-0.10.0/stageflow/builtins/_args.py +35 -0
  8. {stageflow_framework-0.1.6 → stageflow_framework-0.10.0}/stageflow/builtins/dicts.py +12 -15
  9. stageflow_framework-0.10.0/stageflow/builtins/lists.py +171 -0
  10. stageflow_framework-0.10.0/stageflow/builtins/logic.py +100 -0
  11. stageflow_framework-0.10.0/stageflow/builtins/strings.py +75 -0
  12. stageflow_framework-0.10.0/stageflow/builtins/vars.py +114 -0
  13. stageflow_framework-0.10.0/stageflow/core/__init__.py +69 -0
  14. stageflow_framework-0.10.0/stageflow/core/cel.py +75 -0
  15. stageflow_framework-0.10.0/stageflow/core/context.py +48 -0
  16. stageflow_framework-0.10.0/stageflow/core/debug.py +146 -0
  17. {stageflow_framework-0.1.6 → stageflow_framework-0.10.0}/stageflow/core/event.py +19 -33
  18. stageflow_framework-0.10.0/stageflow/core/inputs.py +63 -0
  19. stageflow_framework-0.10.0/stageflow/core/nodes/__init__.py +28 -0
  20. stageflow_framework-0.10.0/stageflow/core/nodes/base.py +110 -0
  21. stageflow_framework-0.10.0/stageflow/core/nodes/bindings.py +88 -0
  22. stageflow_framework-0.10.0/stageflow/core/nodes/branching.py +89 -0
  23. stageflow_framework-0.10.0/stageflow/core/nodes/entry.py +152 -0
  24. stageflow_framework-0.10.0/stageflow/core/nodes/map_block.py +269 -0
  25. stageflow_framework-0.10.0/stageflow/core/nodes/parallel.py +159 -0
  26. stageflow_framework-0.10.0/stageflow/core/nodes/recovery.py +92 -0
  27. stageflow_framework-0.10.0/stageflow/core/nodes/stage.py +149 -0
  28. stageflow_framework-0.10.0/stageflow/core/nodes/subpipeline.py +89 -0
  29. stageflow_framework-0.10.0/stageflow/core/nodes/terminal.py +36 -0
  30. stageflow_framework-0.10.0/stageflow/core/nodes/try_block.py +163 -0
  31. stageflow_framework-0.10.0/stageflow/core/payload_schema.py +106 -0
  32. stageflow_framework-0.10.0/stageflow/core/pipeline.py +146 -0
  33. stageflow_framework-0.10.0/stageflow/core/registry.py +36 -0
  34. stageflow_framework-0.10.0/stageflow/core/session.py +347 -0
  35. stageflow_framework-0.10.0/stageflow/core/spec.py +79 -0
  36. stageflow_framework-0.10.0/stageflow/core/stage.py +115 -0
  37. stageflow_framework-0.10.0/stageflow/core/typesys.py +402 -0
  38. stageflow_framework-0.10.0/stageflow/docs/__init__.py +13 -0
  39. stageflow_framework-0.10.0/stageflow/docs/schema.py +35 -0
  40. stageflow_framework-0.10.0/stageflow/docs/schemas/pipeline.json +797 -0
  41. stageflow_framework-0.10.0/stageflow/exceptions.py +54 -0
  42. stageflow_framework-0.10.0/stageflow/py.typed +0 -0
  43. stageflow_framework-0.10.0/stageflow/testing.py +84 -0
  44. stageflow_framework-0.10.0/stageflow_framework.egg-info/PKG-INFO +186 -0
  45. {stageflow_framework-0.1.6 → stageflow_framework-0.10.0}/stageflow_framework.egg-info/SOURCES.txt +32 -8
  46. stageflow_framework-0.10.0/stageflow_framework.egg-info/requires.txt +13 -0
  47. stageflow_framework-0.10.0/tests/test_core_flow.py +283 -0
  48. stageflow_framework-0.10.0/tests/test_debug.py +253 -0
  49. stageflow_framework-0.10.0/tests/test_docs_schema.py +184 -0
  50. stageflow_framework-0.10.0/tests/test_entry_node.py +334 -0
  51. {stageflow_framework-0.1.6 → stageflow_framework-0.10.0}/tests/test_full_pipeline.py +57 -50
  52. stageflow_framework-0.10.0/tests/test_map.py +405 -0
  53. stageflow_framework-0.10.0/tests/test_packaging.py +29 -0
  54. stageflow_framework-0.10.0/tests/test_parallel.py +132 -0
  55. {stageflow_framework-0.1.6 → stageflow_framework-0.10.0}/tests/test_payload_validation.py +7 -8
  56. {stageflow_framework-0.1.6 → stageflow_framework-0.10.0}/tests/test_pipeline_tester.py +8 -5
  57. stageflow_framework-0.10.0/tests/test_removed_local_scope.py +110 -0
  58. stageflow_framework-0.10.0/tests/test_session_control.py +89 -0
  59. {stageflow_framework-0.1.6 → stageflow_framework-0.10.0}/tests/test_session_wait_input.py +16 -6
  60. {stageflow_framework-0.1.6 → stageflow_framework-0.10.0}/tests/test_snapshot.py +4 -10
  61. stageflow_framework-0.10.0/tests/test_std_stages.py +196 -0
  62. stageflow_framework-0.10.0/tests/test_subpipeline.py +155 -0
  63. stageflow_framework-0.10.0/tests/test_try_block.py +313 -0
  64. stageflow_framework-0.10.0/tests/test_typesystem.py +397 -0
  65. stageflow_framework-0.1.6/PKG-INFO +0 -167
  66. stageflow_framework-0.1.6/README.md +0 -157
  67. stageflow_framework-0.1.6/pyproject.toml +0 -24
  68. stageflow_framework-0.1.6/stageflow/__init__.py +0 -25
  69. stageflow_framework-0.1.6/stageflow/builtins/lists.py +0 -71
  70. stageflow_framework-0.1.6/stageflow/builtins/lists_extra.py +0 -110
  71. stageflow_framework-0.1.6/stageflow/builtins/logic.py +0 -84
  72. stageflow_framework-0.1.6/stageflow/builtins/strings.py +0 -81
  73. stageflow_framework-0.1.6/stageflow/builtins/vars.py +0 -118
  74. stageflow_framework-0.1.6/stageflow/core/__init__.py +0 -7
  75. stageflow_framework-0.1.6/stageflow/core/context.py +0 -86
  76. stageflow_framework-0.1.6/stageflow/core/jsonlogic.py +0 -43
  77. stageflow_framework-0.1.6/stageflow/core/node.py +0 -254
  78. stageflow_framework-0.1.6/stageflow/core/pipeline.py +0 -105
  79. stageflow_framework-0.1.6/stageflow/core/session.py +0 -407
  80. stageflow_framework-0.1.6/stageflow/core/stage.py +0 -168
  81. stageflow_framework-0.1.6/stageflow/core/utils.py +0 -108
  82. stageflow_framework-0.1.6/stageflow/docs/__init__.py +0 -4
  83. stageflow_framework-0.1.6/stageflow/docs/html.py +0 -479
  84. stageflow_framework-0.1.6/stageflow/docs/schema.py +0 -38
  85. stageflow_framework-0.1.6/stageflow/docs/schemas/pipeline.json +0 -134
  86. stageflow_framework-0.1.6/stageflow/py.typed +0 -1
  87. stageflow_framework-0.1.6/stageflow/testing.py +0 -59
  88. stageflow_framework-0.1.6/stageflow_framework.egg-info/PKG-INFO +0 -167
  89. stageflow_framework-0.1.6/stageflow_framework.egg-info/requires.txt +0 -2
  90. stageflow_framework-0.1.6/tests/test_core_flow.py +0 -79
  91. stageflow_framework-0.1.6/tests/test_docs_schema.py +0 -99
  92. stageflow_framework-0.1.6/tests/test_jsonlogic.py +0 -34
  93. stageflow_framework-0.1.6/tests/test_stage_wait_input.py +0 -64
  94. stageflow_framework-0.1.6/tests/test_std_stages.py +0 -53
  95. stageflow_framework-0.1.6/tests/test_subpipeline.py +0 -187
  96. {stageflow_framework-0.1.6 → stageflow_framework-0.10.0}/setup.cfg +0 -0
  97. {stageflow_framework-0.1.6 → stageflow_framework-0.10.0}/stageflow_framework.egg-info/dependency_links.txt +0 -0
  98. {stageflow_framework-0.1.6 → stageflow_framework-0.10.0}/stageflow_framework.egg-info/top_level.txt +0 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 лень
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,186 @@
1
+ Metadata-Version: 2.4
2
+ Name: stageflow-framework
3
+ Version: 0.10.0
4
+ Summary: StageFlow: pipeline framework for stages
5
+ Author-email: лень <pzrnqt1vrss@protonmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Repository, https://github.com/leo-need-more-coffee/stageflow
8
+ Project-URL: Issues, https://github.com/leo-need-more-coffee/stageflow/issues
9
+ Keywords: pipeline,workflow,orchestration,state-machine,cel
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
17
+ Classifier: Typing :: Typed
18
+ Requires-Python: >=3.11
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: pyyaml
22
+ Requires-Dist: jsonschema>=4.0.0
23
+ Requires-Dist: immutables>=0.20
24
+ Requires-Dist: common-expression-language>=0.9
25
+ Provides-Extra: dev
26
+ Requires-Dist: flake8; extra == "dev"
27
+ Requires-Dist: build; extra == "dev"
28
+ Requires-Dist: twine; extra == "dev"
29
+ Provides-Extra: docs
30
+ Requires-Dist: mkdocs-material; extra == "docs"
31
+ Requires-Dist: mkdocs-static-i18n; extra == "docs"
32
+ Dynamic: license-file
33
+
34
+ <div align="center">
35
+
36
+ # StageFlow
37
+
38
+ **Pipelines described in JSON, executed in Python — and debuggable node by node.**
39
+
40
+ [![tests](https://github.com/leo-need-more-coffee/stageflow/actions/workflows/tests.yml/badge.svg)](https://github.com/leo-need-more-coffee/stageflow/actions/workflows/tests.yml)
41
+ [![PyPI](https://img.shields.io/pypi/v/stageflow-framework)](https://pypi.org/project/stageflow-framework/)
42
+ [![Python](https://img.shields.io/pypi/pyversions/stageflow-framework)](https://pypi.org/project/stageflow-framework/)
43
+ [![docs](https://img.shields.io/badge/docs-stageflow-blue)](https://leo-need-more-coffee.github.io/stageflow/)
44
+ [![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)
45
+
46
+ [Documentation](https://leo-need-more-coffee.github.io/stageflow/) ·
47
+ [Tutorial](https://leo-need-more-coffee.github.io/stageflow/tutorial/) ·
48
+ [Документация на русском](https://leo-need-more-coffee.github.io/stageflow/ru/)
49
+
50
+ </div>
51
+
52
+ A pipeline is a graph of nodes in JSON. The work happens in stages — Python
53
+ classes you write. Between them travels one immutable frame of variables, and
54
+ everything the graph does with that frame is visible in the JSON: branching,
55
+ retries, error handling, concurrency, nested graphs.
56
+
57
+ Because the pipeline is data, it can be stored, diffed, generated, validated
58
+ before it runs — and drawn:
59
+
60
+ ![A pipeline open in the StageFlow editor](docs/img/tut-final.png)
61
+
62
+ That is the [editor](https://github.com/leo-need-more-coffee/stageflow-ui): a
63
+ separate static page that draws and debugs a graph while this core executes it.
64
+
65
+ ## Install
66
+
67
+ ```bash
68
+ pip install stageflow-framework
69
+ ```
70
+
71
+ Python 3.11+.
72
+
73
+ ## A pipeline in 30 seconds
74
+
75
+ ```python
76
+ import asyncio
77
+
78
+ from stageflow import BaseStage, Pipeline, Session, register_stage
79
+
80
+
81
+ @register_stage("HelloStage")
82
+ class HelloStage(BaseStage):
83
+ """
84
+ description: "Greets whoever the pipeline points at"
85
+ arguments:
86
+ name: string
87
+ outputs:
88
+ greeting: string
89
+ """
90
+
91
+ async def run(self):
92
+ name = self.get_arguments().get("name", "world")
93
+ self.set_outputs({"greeting": f"Hello, {name}!"})
94
+
95
+
96
+ pipeline = Pipeline.from_dict({
97
+ "nodes": [
98
+ {"id": "start", "type": "entry",
99
+ "variables": {"user_name": "Alice"}, "next": "hello"},
100
+ {"id": "hello", "type": "stage", "stage": "HelloStage",
101
+ "arguments": {"vars": {"name": "user_name"}},
102
+ "outputs": {"greeting": "greeting"}, "next": "finish"},
103
+ {"id": "finish", "type": "terminal",
104
+ "result": {"status": "ok"}, "artifacts": ["greeting"]},
105
+ ],
106
+ })
107
+ pipeline.validate()
108
+
109
+ result = asyncio.run(Session(id="demo", pipeline=pipeline).run())
110
+ print(result.result) # {'status': 'ok'}
111
+ print(result.artifacts) # {'greeting': 'Hello, Alice!'}
112
+ ```
113
+
114
+ The docstring is the stage's specification. `validate()` checks the graph
115
+ against it, so a wrong argument name is an error before anything runs.
116
+
117
+ ## What the graph can do
118
+
119
+ | | |
120
+ |---|---|
121
+ | **Nine node types** | `entry`, `stage`, `condition`, `switch`, `parallel`, `try`, `map`, `subpipeline`, `terminal` |
122
+ | **One immutable frame** | variables travel along the path; a write produces a new frame, so branches never collide |
123
+ | **CEL expressions** | in conditions, in switch cases, and in any argument or output through the `.$` suffix |
124
+ | **Errors as roads** | `retry` on a node, `try`/`except` over a region of the graph derived from its shape |
125
+ | **Real concurrency** | `parallel` branches with their own frames and explicit merge rules |
126
+ | **Loops over data** | `map` runs a region of the graph once per element, sequentially or at once |
127
+ | **Nested graphs** | a `subpipeline` starts with a fresh frame and returns artifacts |
128
+ | **Gradual typing** | declare the variables that matter; checked at validation and on every write |
129
+ | **Step debugging** | stop between nodes, read and edit the frame, replay the event stream |
130
+
131
+ ## Documentation
132
+
133
+ The [tutorial](https://leo-need-more-coffee.github.io/stageflow/tutorial/)
134
+ builds one working pipeline step by step, with screenshots from the editor.
135
+ The reference covers the rest:
136
+
137
+ [Quick start](https://leo-need-more-coffee.github.io/stageflow/quick-start/) ·
138
+ [Node types](https://leo-need-more-coffee.github.io/stageflow/node-types/) ·
139
+ [Data model](https://leo-need-more-coffee.github.io/stageflow/data-model/) ·
140
+ [Expressions](https://leo-need-more-coffee.github.io/stageflow/expressions/) ·
141
+ [Errors](https://leo-need-more-coffee.github.io/stageflow/errors/) ·
142
+ [Variable typing](https://leo-need-more-coffee.github.io/stageflow/variable-typing/) ·
143
+ [Session control](https://leo-need-more-coffee.github.io/stageflow/session-control/) ·
144
+ [Step debugging](https://leo-need-more-coffee.github.io/stageflow/step-debugging/)
145
+
146
+ One page per node type:
147
+ [entry](https://leo-need-more-coffee.github.io/stageflow/entry-node/) ·
148
+ [stage](https://leo-need-more-coffee.github.io/stageflow/stage-node/) ·
149
+ [condition](https://leo-need-more-coffee.github.io/stageflow/condition-node/) ·
150
+ [switch](https://leo-need-more-coffee.github.io/stageflow/switch-node/) ·
151
+ [parallel](https://leo-need-more-coffee.github.io/stageflow/parallel-branches/) ·
152
+ [try](https://leo-need-more-coffee.github.io/stageflow/try-node/) ·
153
+ [map](https://leo-need-more-coffee.github.io/stageflow/map-node/) ·
154
+ [subpipeline](https://leo-need-more-coffee.github.io/stageflow/subpipeline-node/) ·
155
+ [terminal](https://leo-need-more-coffee.github.io/stageflow/terminal-node/)
156
+
157
+ Sources are in [`docs/`](docs) (`*.md` English, `*.ru.md` Russian) and publish
158
+ themselves on every push to `main`.
159
+
160
+ ## The rest of the project
161
+
162
+ | Repository | What it is |
163
+ |---|---|
164
+ | **stageflow** | this one: the core that runs the pipelines |
165
+ | [stageflow-ui](https://github.com/leo-need-more-coffee/stageflow-ui) | the editor: a static page that draws and debugs a graph |
166
+ | [stageflow-example](https://github.com/leo-need-more-coffee/stageflow-example) | a working backend for the editor: a support bot in four pipelines |
167
+
168
+ ## Development
169
+
170
+ ```bash
171
+ pip install -e ".[dev]"
172
+ python -m unittest discover -s tests
173
+ ```
174
+
175
+ Pipelines can be tested declaratively:
176
+
177
+ ```python
178
+ from stageflow.testing import PipelineTestSpec, run_pipeline_test
179
+ ```
180
+
181
+ Releases are tag-driven: the tag has to match `project.version` in
182
+ `pyproject.toml`, and the workflow publishes to PyPI.
183
+
184
+ ## License
185
+
186
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,153 @@
1
+ <div align="center">
2
+
3
+ # StageFlow
4
+
5
+ **Pipelines described in JSON, executed in Python — and debuggable node by node.**
6
+
7
+ [![tests](https://github.com/leo-need-more-coffee/stageflow/actions/workflows/tests.yml/badge.svg)](https://github.com/leo-need-more-coffee/stageflow/actions/workflows/tests.yml)
8
+ [![PyPI](https://img.shields.io/pypi/v/stageflow-framework)](https://pypi.org/project/stageflow-framework/)
9
+ [![Python](https://img.shields.io/pypi/pyversions/stageflow-framework)](https://pypi.org/project/stageflow-framework/)
10
+ [![docs](https://img.shields.io/badge/docs-stageflow-blue)](https://leo-need-more-coffee.github.io/stageflow/)
11
+ [![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)
12
+
13
+ [Documentation](https://leo-need-more-coffee.github.io/stageflow/) ·
14
+ [Tutorial](https://leo-need-more-coffee.github.io/stageflow/tutorial/) ·
15
+ [Документация на русском](https://leo-need-more-coffee.github.io/stageflow/ru/)
16
+
17
+ </div>
18
+
19
+ A pipeline is a graph of nodes in JSON. The work happens in stages — Python
20
+ classes you write. Between them travels one immutable frame of variables, and
21
+ everything the graph does with that frame is visible in the JSON: branching,
22
+ retries, error handling, concurrency, nested graphs.
23
+
24
+ Because the pipeline is data, it can be stored, diffed, generated, validated
25
+ before it runs — and drawn:
26
+
27
+ ![A pipeline open in the StageFlow editor](docs/img/tut-final.png)
28
+
29
+ That is the [editor](https://github.com/leo-need-more-coffee/stageflow-ui): a
30
+ separate static page that draws and debugs a graph while this core executes it.
31
+
32
+ ## Install
33
+
34
+ ```bash
35
+ pip install stageflow-framework
36
+ ```
37
+
38
+ Python 3.11+.
39
+
40
+ ## A pipeline in 30 seconds
41
+
42
+ ```python
43
+ import asyncio
44
+
45
+ from stageflow import BaseStage, Pipeline, Session, register_stage
46
+
47
+
48
+ @register_stage("HelloStage")
49
+ class HelloStage(BaseStage):
50
+ """
51
+ description: "Greets whoever the pipeline points at"
52
+ arguments:
53
+ name: string
54
+ outputs:
55
+ greeting: string
56
+ """
57
+
58
+ async def run(self):
59
+ name = self.get_arguments().get("name", "world")
60
+ self.set_outputs({"greeting": f"Hello, {name}!"})
61
+
62
+
63
+ pipeline = Pipeline.from_dict({
64
+ "nodes": [
65
+ {"id": "start", "type": "entry",
66
+ "variables": {"user_name": "Alice"}, "next": "hello"},
67
+ {"id": "hello", "type": "stage", "stage": "HelloStage",
68
+ "arguments": {"vars": {"name": "user_name"}},
69
+ "outputs": {"greeting": "greeting"}, "next": "finish"},
70
+ {"id": "finish", "type": "terminal",
71
+ "result": {"status": "ok"}, "artifacts": ["greeting"]},
72
+ ],
73
+ })
74
+ pipeline.validate()
75
+
76
+ result = asyncio.run(Session(id="demo", pipeline=pipeline).run())
77
+ print(result.result) # {'status': 'ok'}
78
+ print(result.artifacts) # {'greeting': 'Hello, Alice!'}
79
+ ```
80
+
81
+ The docstring is the stage's specification. `validate()` checks the graph
82
+ against it, so a wrong argument name is an error before anything runs.
83
+
84
+ ## What the graph can do
85
+
86
+ | | |
87
+ |---|---|
88
+ | **Nine node types** | `entry`, `stage`, `condition`, `switch`, `parallel`, `try`, `map`, `subpipeline`, `terminal` |
89
+ | **One immutable frame** | variables travel along the path; a write produces a new frame, so branches never collide |
90
+ | **CEL expressions** | in conditions, in switch cases, and in any argument or output through the `.$` suffix |
91
+ | **Errors as roads** | `retry` on a node, `try`/`except` over a region of the graph derived from its shape |
92
+ | **Real concurrency** | `parallel` branches with their own frames and explicit merge rules |
93
+ | **Loops over data** | `map` runs a region of the graph once per element, sequentially or at once |
94
+ | **Nested graphs** | a `subpipeline` starts with a fresh frame and returns artifacts |
95
+ | **Gradual typing** | declare the variables that matter; checked at validation and on every write |
96
+ | **Step debugging** | stop between nodes, read and edit the frame, replay the event stream |
97
+
98
+ ## Documentation
99
+
100
+ The [tutorial](https://leo-need-more-coffee.github.io/stageflow/tutorial/)
101
+ builds one working pipeline step by step, with screenshots from the editor.
102
+ The reference covers the rest:
103
+
104
+ [Quick start](https://leo-need-more-coffee.github.io/stageflow/quick-start/) ·
105
+ [Node types](https://leo-need-more-coffee.github.io/stageflow/node-types/) ·
106
+ [Data model](https://leo-need-more-coffee.github.io/stageflow/data-model/) ·
107
+ [Expressions](https://leo-need-more-coffee.github.io/stageflow/expressions/) ·
108
+ [Errors](https://leo-need-more-coffee.github.io/stageflow/errors/) ·
109
+ [Variable typing](https://leo-need-more-coffee.github.io/stageflow/variable-typing/) ·
110
+ [Session control](https://leo-need-more-coffee.github.io/stageflow/session-control/) ·
111
+ [Step debugging](https://leo-need-more-coffee.github.io/stageflow/step-debugging/)
112
+
113
+ One page per node type:
114
+ [entry](https://leo-need-more-coffee.github.io/stageflow/entry-node/) ·
115
+ [stage](https://leo-need-more-coffee.github.io/stageflow/stage-node/) ·
116
+ [condition](https://leo-need-more-coffee.github.io/stageflow/condition-node/) ·
117
+ [switch](https://leo-need-more-coffee.github.io/stageflow/switch-node/) ·
118
+ [parallel](https://leo-need-more-coffee.github.io/stageflow/parallel-branches/) ·
119
+ [try](https://leo-need-more-coffee.github.io/stageflow/try-node/) ·
120
+ [map](https://leo-need-more-coffee.github.io/stageflow/map-node/) ·
121
+ [subpipeline](https://leo-need-more-coffee.github.io/stageflow/subpipeline-node/) ·
122
+ [terminal](https://leo-need-more-coffee.github.io/stageflow/terminal-node/)
123
+
124
+ Sources are in [`docs/`](docs) (`*.md` English, `*.ru.md` Russian) and publish
125
+ themselves on every push to `main`.
126
+
127
+ ## The rest of the project
128
+
129
+ | Repository | What it is |
130
+ |---|---|
131
+ | **stageflow** | this one: the core that runs the pipelines |
132
+ | [stageflow-ui](https://github.com/leo-need-more-coffee/stageflow-ui) | the editor: a static page that draws and debugs a graph |
133
+ | [stageflow-example](https://github.com/leo-need-more-coffee/stageflow-example) | a working backend for the editor: a support bot in four pipelines |
134
+
135
+ ## Development
136
+
137
+ ```bash
138
+ pip install -e ".[dev]"
139
+ python -m unittest discover -s tests
140
+ ```
141
+
142
+ Pipelines can be tested declaratively:
143
+
144
+ ```python
145
+ from stageflow.testing import PipelineTestSpec, run_pipeline_test
146
+ ```
147
+
148
+ Releases are tag-driven: the tag has to match `project.version` in
149
+ `pyproject.toml`, and the workflow publishes to PyPI.
150
+
151
+ ## License
152
+
153
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,54 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "stageflow-framework"
7
+ version = "0.10.0"
8
+ description = "StageFlow: pipeline framework for stages"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ authors = [
13
+ { name = "лень", email = "pzrnqt1vrss@protonmail.com" }
14
+ ]
15
+ dependencies = [
16
+ "pyyaml",
17
+ "jsonschema>=4.0.0",
18
+ "immutables>=0.20",
19
+ "common-expression-language>=0.9",
20
+ ]
21
+ requires-python = ">=3.11"
22
+ keywords = ["pipeline", "workflow", "orchestration", "state-machine", "cel"]
23
+ classifiers = [
24
+ "Development Status :: 4 - Beta",
25
+ "Intended Audience :: Developers",
26
+ "Programming Language :: Python :: 3.11",
27
+ "Programming Language :: Python :: 3.12",
28
+ "Programming Language :: Python :: 3.13",
29
+ "Programming Language :: Python :: 3.14",
30
+ "Topic :: Software Development :: Libraries :: Application Frameworks",
31
+ "Typing :: Typed",
32
+ ]
33
+
34
+ [project.urls]
35
+ Repository = "https://github.com/leo-need-more-coffee/stageflow"
36
+ Issues = "https://github.com/leo-need-more-coffee/stageflow/issues"
37
+
38
+ [project.optional-dependencies]
39
+ dev = [
40
+ "flake8",
41
+ "build",
42
+ "twine",
43
+ ]
44
+ docs = [
45
+ "mkdocs-material",
46
+ "mkdocs-static-i18n",
47
+ ]
48
+
49
+ [tool.setuptools.packages.find]
50
+ where = ["."]
51
+ include = ["stageflow*"]
52
+
53
+ [tool.setuptools.package-data]
54
+ "stageflow" = ["py.typed", "docs/schemas/pipeline.json"]
@@ -0,0 +1,99 @@
1
+ from . import builtins # noqa: F401
2
+ from .core import (
3
+ BaseStage,
4
+ CelEngine,
5
+ CelError,
6
+ ConditionNode,
7
+ Context,
8
+ EntryNode,
9
+ Event,
10
+ EventSpec,
11
+ InputSpec,
12
+ MapNode,
13
+ Node,
14
+ ParallelNode,
15
+ Pipeline,
16
+ Retrier,
17
+ Session,
18
+ SessionResult,
19
+ StepDebugger,
20
+ StageNode,
21
+ SubPipelineNode,
22
+ SwitchNode,
23
+ TerminalNode,
24
+ TryNode,
25
+ ExceptHandler,
26
+ TypeRegistry,
27
+ TypeSystem,
28
+ get_node_types,
29
+ get_stage,
30
+ get_stages,
31
+ get_stages_by_category,
32
+ parse_type,
33
+ register_node,
34
+ register_stage,
35
+ )
36
+ from .docs import generate_stages_json, generate_stages_yaml
37
+ from .exceptions import (
38
+ ArtifactNotFoundError,
39
+ BranchError,
40
+ ExpressionError,
41
+ PayloadValidationError,
42
+ PipelineDefinitionError,
43
+ PipelineValidationError,
44
+ RegistryError,
45
+ StageContractError,
46
+ StageFlowError,
47
+ StageOutputError,
48
+ TypeCheckError,
49
+ TypeDeclarationError,
50
+ )
51
+
52
+ __all__ = [
53
+ "Pipeline",
54
+ "Session",
55
+ "SessionResult",
56
+ "StepDebugger",
57
+ "Context",
58
+ "BaseStage",
59
+ "register_stage",
60
+ "get_stage",
61
+ "get_stages",
62
+ "get_stages_by_category",
63
+ "Node",
64
+ "register_node",
65
+ "get_node_types",
66
+ "EntryNode",
67
+ "StageNode",
68
+ "ConditionNode",
69
+ "SwitchNode",
70
+ "ParallelNode",
71
+ "MapNode",
72
+ "SubPipelineNode",
73
+ "TerminalNode",
74
+ "Retrier",
75
+ "TryNode",
76
+ "ExceptHandler",
77
+ "Event",
78
+ "EventSpec",
79
+ "InputSpec",
80
+ "CelEngine",
81
+ "CelError",
82
+ "TypeSystem",
83
+ "TypeRegistry",
84
+ "parse_type",
85
+ "generate_stages_yaml",
86
+ "generate_stages_json",
87
+ "StageFlowError",
88
+ "RegistryError",
89
+ "PipelineDefinitionError",
90
+ "PipelineValidationError",
91
+ "ExpressionError",
92
+ "PayloadValidationError",
93
+ "StageContractError",
94
+ "StageOutputError",
95
+ "ArtifactNotFoundError",
96
+ "BranchError",
97
+ "TypeDeclarationError",
98
+ "TypeCheckError",
99
+ ]
@@ -1,17 +1,14 @@
1
- from .vars import (
2
- SetValueStage,
3
- CopyValueStage,
4
- IncrementStage,
5
- MergeDictStage,
6
- )
1
+ from .dicts import DropKeysStage, PickKeysStage
7
2
  from .lists import (
8
3
  AppendListStage,
9
4
  ExtendListStage,
5
+ FilterListStage,
6
+ PopListStage,
7
+ UniqueListStage,
10
8
  )
11
9
  from .logic import AssertStage, FailStage, LogStage, SleepStage
12
10
  from .strings import ConcatStage, TemplateStage
13
- from .dicts import PickKeysStage, DropKeysStage
14
- from .lists_extra import FilterListStage, UniqueListStage, PopListStage
11
+ from .vars import CopyValueStage, IncrementStage, MergeDictStage, SetValueStage
15
12
 
16
13
  __all__ = [
17
14
  "SetValueStage",
@@ -20,15 +17,15 @@ __all__ = [
20
17
  "MergeDictStage",
21
18
  "AppendListStage",
22
19
  "ExtendListStage",
20
+ "FilterListStage",
21
+ "UniqueListStage",
22
+ "PopListStage",
23
+ "PickKeysStage",
24
+ "DropKeysStage",
25
+ "ConcatStage",
26
+ "TemplateStage",
23
27
  "AssertStage",
24
28
  "FailStage",
25
29
  "LogStage",
26
30
  "SleepStage",
27
- "ConcatStage",
28
- "TemplateStage",
29
- "PickKeysStage",
30
- "DropKeysStage",
31
- "FilterListStage",
32
- "UniqueListStage",
33
- "PopListStage",
34
31
  ]
@@ -0,0 +1,35 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any
4
+
5
+ from ..exceptions import StageContractError
6
+
7
+
8
+ def require_list(stage_name: str, field: str, value: Any) -> list:
9
+ if not isinstance(value, list):
10
+ raise StageContractError(
11
+ f"{stage_name}: '{field}' must be a list, got {type(value).__name__}"
12
+ )
13
+ return value
14
+
15
+
16
+ def require_dict(stage_name: str, field: str, value: Any) -> dict:
17
+ if not isinstance(value, dict):
18
+ raise StageContractError(
19
+ f"{stage_name}: '{field}' must be an object, got {type(value).__name__}"
20
+ )
21
+ return value
22
+
23
+
24
+ def require_number(stage_name: str, field: str, value: Any) -> int | float:
25
+ if isinstance(value, bool) or not isinstance(value, (int, float)):
26
+ raise StageContractError(
27
+ f"{stage_name}: '{field}' must be a number, got {type(value).__name__}"
28
+ )
29
+ return value
30
+
31
+
32
+ def require_present(stage_name: str, field: str, value: Any) -> Any:
33
+ if value is None:
34
+ raise StageContractError(f"{stage_name}: argument '{field}' is required")
35
+ return value
@@ -1,15 +1,16 @@
1
- from stageflow.core.stage import BaseStage, register_stage
1
+ from ..core.stage import BaseStage, register_stage
2
+ from ._args import require_dict, require_list
2
3
 
3
4
 
4
5
  @register_stage("PickKeysStage")
5
6
  class PickKeysStage(BaseStage):
6
7
  """
7
8
  description: "Pick only specified keys from a dict and return new object"
9
+ icon: "⊂"
8
10
  arguments:
9
11
  src:
10
12
  type: object
11
13
  description: "Source dict"
12
- config:
13
14
  keys:
14
15
  type: list
15
16
  description: "Keys to keep in the result"
@@ -18,27 +19,25 @@ class PickKeysStage(BaseStage):
18
19
  type: object
19
20
  description: "Dict containing only picked keys"
20
21
  """
22
+
21
23
  category = "builtin.dicts"
22
24
 
23
25
  async def run(self):
24
26
  args = self.get_arguments()
25
- src_val = args.get("src") or {}
26
- keys = self.config.get("keys", [])
27
- if not isinstance(src_val, dict):
28
- raise ValueError("PickKeysStage expects dict in arguments.src")
29
- picked = {k: src_val[k] for k in keys if k in src_val}
30
- self.set_outputs({"result": picked})
27
+ src = require_dict("PickKeysStage", "src", args.get("src") or {})
28
+ keys = require_list("PickKeysStage", "keys", args.get("keys") or [])
29
+ self.set_outputs({"result": {k: src[k] for k in keys if k in src}})
31
30
 
32
31
 
33
32
  @register_stage("DropKeysStage")
34
33
  class DropKeysStage(BaseStage):
35
34
  """
36
35
  description: "Remove specified keys from dict and return cleaned object"
36
+ icon: "⊘"
37
37
  arguments:
38
38
  src:
39
39
  type: object
40
40
  description: "Source dict"
41
- config:
42
41
  keys:
43
42
  type: list
44
43
  description: "Keys to remove from the dict"
@@ -47,13 +46,11 @@ class DropKeysStage(BaseStage):
47
46
  type: object
48
47
  description: "Dict without removed keys"
49
48
  """
49
+
50
50
  category = "builtin.dicts"
51
51
 
52
52
  async def run(self):
53
53
  args = self.get_arguments()
54
- keys = set(self.config.get("keys", []))
55
- src_val = args.get("src") or {}
56
- if not isinstance(src_val, dict):
57
- raise ValueError("DropKeysStage expects dict in arguments.src")
58
- cleaned = {k: v for k, v in src_val.items() if k not in keys}
59
- self.set_outputs({"result": cleaned})
54
+ src = require_dict("DropKeysStage", "src", args.get("src") or {})
55
+ drop = set(require_list("DropKeysStage", "keys", args.get("keys") or []))
56
+ self.set_outputs({"result": {k: v for k, v in src.items() if k not in drop}})