codeupipe 0.1.0__tar.gz → 1.0.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 (150) hide show
  1. codeupipe-1.0.0/LICENSE +177 -0
  2. codeupipe-1.0.0/NOTICE +4 -0
  3. codeupipe-1.0.0/PKG-INFO +122 -0
  4. codeupipe-1.0.0/README.md +96 -0
  5. codeupipe-1.0.0/codeupipe/__init__.py +8 -0
  6. codeupipe-1.0.0/codeupipe/config.py +83 -0
  7. codeupipe-1.0.0/codeupipe/core/__init__.py +29 -0
  8. codeupipe-1.0.0/codeupipe/core/anonymous_step.py +13 -0
  9. codeupipe-1.0.0/codeupipe/core/async_filter.py +26 -0
  10. codeupipe-1.0.0/codeupipe/core/async_hook.py +26 -0
  11. codeupipe-1.0.0/codeupipe/core/async_step_in_sync_run.py +7 -0
  12. codeupipe-1.0.0/codeupipe/core/async_tap.py +25 -0
  13. codeupipe-1.0.0/codeupipe/core/filter.py +29 -0
  14. codeupipe-1.0.0/codeupipe/core/hook.py +25 -0
  15. codeupipe-1.0.0/codeupipe/core/payload.py +92 -0
  16. codeupipe-1.0.0/codeupipe/core/pipeline.py +405 -0
  17. codeupipe-1.0.0/codeupipe/core/predicate.py +23 -0
  18. codeupipe-1.0.0/codeupipe/core/state.py +48 -0
  19. codeupipe-1.0.0/codeupipe/core/step_identity.py +77 -0
  20. codeupipe-1.0.0/codeupipe/core/tap.py +22 -0
  21. codeupipe-1.0.0/codeupipe/core/valve.py +114 -0
  22. codeupipe-1.0.0/codeupipe/lower/__init__.py +7 -0
  23. codeupipe-1.0.0/codeupipe/lower/__main__.py +92 -0
  24. codeupipe-1.0.0/codeupipe/lower/errors.py +155 -0
  25. codeupipe-1.0.0/codeupipe/lower/filters/__init__.py +0 -0
  26. codeupipe-1.0.0/codeupipe/lower/filters/emit_inline_module_filter.py +324 -0
  27. codeupipe-1.0.0/codeupipe/lower/filters/emit_orchestrator_filter.py +202 -0
  28. codeupipe-1.0.0/codeupipe/lower/filters/emit_plain_files_filter.py +96 -0
  29. codeupipe-1.0.0/codeupipe/lower/filters/load_pipeline_filter.py +160 -0
  30. codeupipe-1.0.0/codeupipe/lower/filters/lower_control_flow_filter.py +42 -0
  31. codeupipe-1.0.0/codeupipe/lower/filters/parse_filter_source_filter.py +427 -0
  32. codeupipe-1.0.0/codeupipe/lower/filters/rewrite_payload_ops_filter.py +287 -0
  33. codeupipe-1.0.0/codeupipe/lower/ir.py +166 -0
  34. codeupipe-1.0.0/codeupipe/lower/pipelines/__init__.py +0 -0
  35. codeupipe-1.0.0/codeupipe/lower/pipelines/export_pipeline.py +61 -0
  36. codeupipe-1.0.0/codeupipe/lower/pipelines/lowering_mode_predicate.py +17 -0
  37. codeupipe-1.0.0/codeupipe/lower/resolve_target.py +39 -0
  38. codeupipe-1.0.0/codeupipe/lower/taps/__init__.py +0 -0
  39. codeupipe-1.0.0/codeupipe/lower/taps/write_files_tap.py +37 -0
  40. codeupipe-1.0.0/codeupipe.egg-info/PKG-INFO +122 -0
  41. codeupipe-1.0.0/codeupipe.egg-info/SOURCES.txt +43 -0
  42. codeupipe-1.0.0/pyproject.toml +35 -0
  43. codeupipe-0.1.0/LICENSE +0 -190
  44. codeupipe-0.1.0/PKG-INFO +0 -216
  45. codeupipe-0.1.0/README.md +0 -190
  46. codeupipe-0.1.0/codeupipe/__init__.py +0 -39
  47. codeupipe-0.1.0/codeupipe/cli.py +0 -1502
  48. codeupipe-0.1.0/codeupipe/converter/__init__.py +0 -9
  49. codeupipe-0.1.0/codeupipe/converter/config.py +0 -119
  50. codeupipe-0.1.0/codeupipe/converter/filters/__init__.py +0 -21
  51. codeupipe-0.1.0/codeupipe/converter/filters/analyze.py +0 -60
  52. codeupipe-0.1.0/codeupipe/converter/filters/classify.py +0 -52
  53. codeupipe-0.1.0/codeupipe/converter/filters/classify_files.py +0 -61
  54. codeupipe-0.1.0/codeupipe/converter/filters/generate_export.py +0 -187
  55. codeupipe-0.1.0/codeupipe/converter/filters/generate_import.py +0 -229
  56. codeupipe-0.1.0/codeupipe/converter/filters/parse_config.py +0 -26
  57. codeupipe-0.1.0/codeupipe/converter/filters/scan_project.py +0 -52
  58. codeupipe-0.1.0/codeupipe/converter/pipelines/__init__.py +0 -8
  59. codeupipe-0.1.0/codeupipe/converter/pipelines/export_pipeline.py +0 -40
  60. codeupipe-0.1.0/codeupipe/converter/pipelines/import_pipeline.py +0 -40
  61. codeupipe-0.1.0/codeupipe/converter/taps/__init__.py +0 -7
  62. codeupipe-0.1.0/codeupipe/converter/taps/conversion_log.py +0 -46
  63. codeupipe-0.1.0/codeupipe/core/__init__.py +0 -20
  64. codeupipe-0.1.0/codeupipe/core/filter.py +0 -27
  65. codeupipe-0.1.0/codeupipe/core/hook.py +0 -34
  66. codeupipe-0.1.0/codeupipe/core/payload.py +0 -94
  67. codeupipe-0.1.0/codeupipe/core/pipeline.py +0 -231
  68. codeupipe-0.1.0/codeupipe/core/state.py +0 -78
  69. codeupipe-0.1.0/codeupipe/core/stream_filter.py +0 -33
  70. codeupipe-0.1.0/codeupipe/core/tap.py +0 -27
  71. codeupipe-0.1.0/codeupipe/core/valve.py +0 -52
  72. codeupipe-0.1.0/codeupipe/linter/__init__.py +0 -57
  73. codeupipe-0.1.0/codeupipe/linter/assemble_doc_report.py +0 -97
  74. codeupipe-0.1.0/codeupipe/linter/assemble_report.py +0 -140
  75. codeupipe-0.1.0/codeupipe/linter/check_bundle.py +0 -47
  76. codeupipe-0.1.0/codeupipe/linter/check_index.py +0 -88
  77. codeupipe-0.1.0/codeupipe/linter/check_naming.py +0 -47
  78. codeupipe-0.1.0/codeupipe/linter/check_protocols.py +0 -73
  79. codeupipe-0.1.0/codeupipe/linter/check_structure.py +0 -41
  80. codeupipe-0.1.0/codeupipe/linter/check_symbols.py +0 -116
  81. codeupipe-0.1.0/codeupipe/linter/check_tests.py +0 -48
  82. codeupipe-0.1.0/codeupipe/linter/coverage_pipeline.py +0 -39
  83. codeupipe-0.1.0/codeupipe/linter/detect_drift.py +0 -44
  84. codeupipe-0.1.0/codeupipe/linter/detect_orphans.py +0 -106
  85. codeupipe-0.1.0/codeupipe/linter/doc_check_pipeline.py +0 -28
  86. codeupipe-0.1.0/codeupipe/linter/git_history.py +0 -130
  87. codeupipe-0.1.0/codeupipe/linter/lint_pipeline.py +0 -51
  88. codeupipe-0.1.0/codeupipe/linter/map_coverage.py +0 -84
  89. codeupipe-0.1.0/codeupipe/linter/report_gaps.py +0 -68
  90. codeupipe-0.1.0/codeupipe/linter/report_pipeline.py +0 -49
  91. codeupipe-0.1.0/codeupipe/linter/resolve_refs.py +0 -48
  92. codeupipe-0.1.0/codeupipe/linter/scan_components.py +0 -95
  93. codeupipe-0.1.0/codeupipe/linter/scan_directory.py +0 -123
  94. codeupipe-0.1.0/codeupipe/linter/scan_docs.py +0 -62
  95. codeupipe-0.1.0/codeupipe/linter/scan_tests.py +0 -104
  96. codeupipe-0.1.0/codeupipe/py.typed +0 -1
  97. codeupipe-0.1.0/codeupipe/testing.py +0 -344
  98. codeupipe-0.1.0/codeupipe/utils/__init__.py +0 -10
  99. codeupipe-0.1.0/codeupipe/utils/error_handling.py +0 -68
  100. codeupipe-0.1.0/codeupipe.egg-info/PKG-INFO +0 -216
  101. codeupipe-0.1.0/codeupipe.egg-info/SOURCES.txt +0 -106
  102. codeupipe-0.1.0/codeupipe.egg-info/entry_points.txt +0 -2
  103. codeupipe-0.1.0/pyproject.toml +0 -54
  104. codeupipe-0.1.0/tests/test_assemble_doc_report.py +0 -137
  105. codeupipe-0.1.0/tests/test_assemble_report.py +0 -255
  106. codeupipe-0.1.0/tests/test_check_bundle.py +0 -77
  107. codeupipe-0.1.0/tests/test_check_index.py +0 -155
  108. codeupipe-0.1.0/tests/test_check_naming.py +0 -61
  109. codeupipe-0.1.0/tests/test_check_protocols.py +0 -123
  110. codeupipe-0.1.0/tests/test_check_structure.py +0 -74
  111. codeupipe-0.1.0/tests/test_check_symbols.py +0 -119
  112. codeupipe-0.1.0/tests/test_check_tests.py +0 -90
  113. codeupipe-0.1.0/tests/test_cli.py +0 -942
  114. codeupipe-0.1.0/tests/test_cli_smoke.py +0 -81
  115. codeupipe-0.1.0/tests/test_core_edge_cases.py +0 -581
  116. codeupipe-0.1.0/tests/test_coverage_pipeline.py +0 -123
  117. codeupipe-0.1.0/tests/test_detect_drift.py +0 -78
  118. codeupipe-0.1.0/tests/test_detect_orphans.py +0 -201
  119. codeupipe-0.1.0/tests/test_doc_check_cli.py +0 -110
  120. codeupipe-0.1.0/tests/test_doc_check_pipeline.py +0 -104
  121. codeupipe-0.1.0/tests/test_docs_examples.py +0 -609
  122. codeupipe-0.1.0/tests/test_error_handling.py +0 -310
  123. codeupipe-0.1.0/tests/test_filter.py +0 -254
  124. codeupipe-0.1.0/tests/test_git_history.py +0 -172
  125. codeupipe-0.1.0/tests/test_hook.py +0 -172
  126. codeupipe-0.1.0/tests/test_lint_pipeline.py +0 -127
  127. codeupipe-0.1.0/tests/test_map_coverage.py +0 -98
  128. codeupipe-0.1.0/tests/test_mixed_stream_pipeline.py +0 -268
  129. codeupipe-0.1.0/tests/test_payload.py +0 -178
  130. codeupipe-0.1.0/tests/test_pipeline.py +0 -352
  131. codeupipe-0.1.0/tests/test_real_world_pipelines.py +0 -1811
  132. codeupipe-0.1.0/tests/test_report_gaps.py +0 -94
  133. codeupipe-0.1.0/tests/test_report_pipeline.py +0 -111
  134. codeupipe-0.1.0/tests/test_resolve_refs.py +0 -63
  135. codeupipe-0.1.0/tests/test_scan_components.py +0 -121
  136. codeupipe-0.1.0/tests/test_scan_directory.py +0 -136
  137. codeupipe-0.1.0/tests/test_scan_docs.py +0 -103
  138. codeupipe-0.1.0/tests/test_scan_tests.py +0 -118
  139. codeupipe-0.1.0/tests/test_state.py +0 -93
  140. codeupipe-0.1.0/tests/test_stream_filter_run_protection.py +0 -175
  141. codeupipe-0.1.0/tests/test_streaming.py +0 -413
  142. codeupipe-0.1.0/tests/test_sync_support.py +0 -201
  143. codeupipe-0.1.0/tests/test_tap.py +0 -94
  144. codeupipe-0.1.0/tests/test_testing.py +0 -350
  145. codeupipe-0.1.0/tests/test_typed.py +0 -233
  146. codeupipe-0.1.0/tests/test_unintended_usage.py +0 -1286
  147. codeupipe-0.1.0/tests/test_valve.py +0 -96
  148. {codeupipe-0.1.0 → codeupipe-1.0.0}/codeupipe.egg-info/dependency_links.txt +0 -0
  149. {codeupipe-0.1.0 → codeupipe-1.0.0}/codeupipe.egg-info/top_level.txt +0 -0
  150. {codeupipe-0.1.0 → codeupipe-1.0.0}/setup.cfg +0 -0
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
codeupipe-1.0.0/NOTICE ADDED
@@ -0,0 +1,4 @@
1
+ codeupipe
2
+ Copyright 2026 Orchestrate LLC
3
+
4
+ Licensed under the Apache License, Version 2.0. See LICENSE.
@@ -0,0 +1,122 @@
1
+ Metadata-Version: 2.4
2
+ Name: codeupipe
3
+ Version: 1.0.0
4
+ Summary: A Python library for writing a program as a pipeline of small steps.
5
+ Author: Joshua Wink
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/orchestrate-solutions/codeupipe
8
+ Project-URL: Repository, https://github.com/orchestrate-solutions/codeupipe
9
+ Project-URL: Issues, https://github.com/orchestrate-solutions/codeupipe/issues
10
+ Keywords: pipeline,filter,payload,composition
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Software Development :: Libraries
21
+ Requires-Python: >=3.9
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ License-File: NOTICE
25
+ Dynamic: license-file
26
+
27
+ # codeupipe
28
+
29
+ codeupipe is a Python library for writing a program as a pipeline of small
30
+ steps. It has no dependencies. Python 3.9 or later.
31
+
32
+ ```bash
33
+ pip install codeupipe
34
+ ```
35
+
36
+ ## The eight primitives
37
+
38
+ | Primitive | What it does | Who writes it |
39
+ |---|---|---|
40
+ | **Payload** | Carries the data | The library |
41
+ | **Filter** | Changes the data | You |
42
+ | **Predicate** | Asks a yes-or-no question about the data | You |
43
+ | **Valve** | Joins a Predicate to a Filter: the Filter runs when the answer is yes | The library. You add one with `add_valve(predicate, filter)` |
44
+ | **Tap** | Reads the data as it goes by | You |
45
+ | **Hook** | Is called before and after each step | You |
46
+ | **State** | Records which steps ran | The library |
47
+ | **Pipeline** | Runs the steps in order | You |
48
+
49
+ ## Example
50
+
51
+ Each class is in its own file. The pipeline file imports them and adds them.
52
+
53
+ ```python
54
+ # discount_filter.py
55
+ class DiscountFilter:
56
+ def __init__(self, rate):
57
+ self.rate = rate
58
+
59
+ def call(self, payload):
60
+ return payload.insert("price", round(payload.get("price", 0) * (1 - self.rate), 2))
61
+ ```
62
+
63
+ ```python
64
+ # at_least_predicate.py
65
+ class AtLeastPredicate:
66
+ def __init__(self, key, minimum):
67
+ self.key = key
68
+ self.minimum = minimum
69
+
70
+ def test(self, payload):
71
+ return payload.get(self.key, 0) >= self.minimum
72
+ ```
73
+
74
+ ```python
75
+ # pricing_pipeline.py
76
+ from codeupipe import Pipeline
77
+
78
+ from .at_least_predicate import AtLeastPredicate
79
+ from .audit_tap import AuditTap
80
+ from .discount_filter import DiscountFilter
81
+ from .mark_bulk_filter import MarkBulkFilter
82
+
83
+
84
+ class PricingPipeline(Pipeline):
85
+ def __init__(self):
86
+ super().__init__()
87
+ self.add_filter(DiscountFilter(0.1))
88
+ # MarkBulkFilter runs only when the predicate is true.
89
+ self.add_valve(AtLeastPredicate("qty", 10), MarkBulkFilter())
90
+ # A Tap failure is recorded and does not stop the run.
91
+ self.add_tap(AuditTap())
92
+ ```
93
+
94
+ ```python
95
+ from codeupipe import Payload
96
+
97
+ PricingPipeline().run(Payload({"price": 100.0, "qty": 12})).to_dict()
98
+ # {'price': 90.0, 'qty': 12, 'bulk': True}
99
+ ```
100
+
101
+ A step must be a class in a module. A lambda is refused, because a step is
102
+ identified by its type, and State, Hooks and the export use that identity.
103
+
104
+ ## What is in the package
105
+
106
+ - `codeupipe`: the eight primitives.
107
+ - `python -m codeupipe.lower`: writes a pipeline as plain Python with no
108
+ import of codeupipe.
109
+ - `codeupipe.config`: reads `cup.config.json`.
110
+
111
+ The linter is a separate package: `pip install codeupipe-lint`.
112
+
113
+ ## Documentation
114
+
115
+ - The contract: https://github.com/orchestrate-solutions/codeupipe/blob/main/conformance/API.md
116
+ - The export: https://github.com/orchestrate-solutions/codeupipe/blob/main/docs/static-export.md
117
+ - The config file: https://github.com/orchestrate-solutions/codeupipe/blob/main/docs/config.md
118
+ - The repository: https://github.com/orchestrate-solutions/codeupipe
119
+
120
+ ## License
121
+
122
+ Apache License 2.0.
@@ -0,0 +1,96 @@
1
+ # codeupipe
2
+
3
+ codeupipe is a Python library for writing a program as a pipeline of small
4
+ steps. It has no dependencies. Python 3.9 or later.
5
+
6
+ ```bash
7
+ pip install codeupipe
8
+ ```
9
+
10
+ ## The eight primitives
11
+
12
+ | Primitive | What it does | Who writes it |
13
+ |---|---|---|
14
+ | **Payload** | Carries the data | The library |
15
+ | **Filter** | Changes the data | You |
16
+ | **Predicate** | Asks a yes-or-no question about the data | You |
17
+ | **Valve** | Joins a Predicate to a Filter: the Filter runs when the answer is yes | The library. You add one with `add_valve(predicate, filter)` |
18
+ | **Tap** | Reads the data as it goes by | You |
19
+ | **Hook** | Is called before and after each step | You |
20
+ | **State** | Records which steps ran | The library |
21
+ | **Pipeline** | Runs the steps in order | You |
22
+
23
+ ## Example
24
+
25
+ Each class is in its own file. The pipeline file imports them and adds them.
26
+
27
+ ```python
28
+ # discount_filter.py
29
+ class DiscountFilter:
30
+ def __init__(self, rate):
31
+ self.rate = rate
32
+
33
+ def call(self, payload):
34
+ return payload.insert("price", round(payload.get("price", 0) * (1 - self.rate), 2))
35
+ ```
36
+
37
+ ```python
38
+ # at_least_predicate.py
39
+ class AtLeastPredicate:
40
+ def __init__(self, key, minimum):
41
+ self.key = key
42
+ self.minimum = minimum
43
+
44
+ def test(self, payload):
45
+ return payload.get(self.key, 0) >= self.minimum
46
+ ```
47
+
48
+ ```python
49
+ # pricing_pipeline.py
50
+ from codeupipe import Pipeline
51
+
52
+ from .at_least_predicate import AtLeastPredicate
53
+ from .audit_tap import AuditTap
54
+ from .discount_filter import DiscountFilter
55
+ from .mark_bulk_filter import MarkBulkFilter
56
+
57
+
58
+ class PricingPipeline(Pipeline):
59
+ def __init__(self):
60
+ super().__init__()
61
+ self.add_filter(DiscountFilter(0.1))
62
+ # MarkBulkFilter runs only when the predicate is true.
63
+ self.add_valve(AtLeastPredicate("qty", 10), MarkBulkFilter())
64
+ # A Tap failure is recorded and does not stop the run.
65
+ self.add_tap(AuditTap())
66
+ ```
67
+
68
+ ```python
69
+ from codeupipe import Payload
70
+
71
+ PricingPipeline().run(Payload({"price": 100.0, "qty": 12})).to_dict()
72
+ # {'price': 90.0, 'qty': 12, 'bulk': True}
73
+ ```
74
+
75
+ A step must be a class in a module. A lambda is refused, because a step is
76
+ identified by its type, and State, Hooks and the export use that identity.
77
+
78
+ ## What is in the package
79
+
80
+ - `codeupipe`: the eight primitives.
81
+ - `python -m codeupipe.lower`: writes a pipeline as plain Python with no
82
+ import of codeupipe.
83
+ - `codeupipe.config`: reads `cup.config.json`.
84
+
85
+ The linter is a separate package: `pip install codeupipe-lint`.
86
+
87
+ ## Documentation
88
+
89
+ - The contract: https://github.com/orchestrate-solutions/codeupipe/blob/main/conformance/API.md
90
+ - The export: https://github.com/orchestrate-solutions/codeupipe/blob/main/docs/static-export.md
91
+ - The config file: https://github.com/orchestrate-solutions/codeupipe/blob/main/docs/config.md
92
+ - The repository: https://github.com/orchestrate-solutions/codeupipe
93
+
94
+ ## License
95
+
96
+ Apache License 2.0.
@@ -0,0 +1,8 @@
1
+ """codeupipe: the eight primitives, runnable two ways.
2
+
3
+ ``codeupipe.core`` is the dynamic runtime. ``codeupipe.lower`` exports a
4
+ pipeline as plain code with no framework import.
5
+ """
6
+
7
+ from .core import * # noqa: F401,F403
8
+ from .core import __all__ # noqa: F401
@@ -0,0 +1,83 @@
1
+ """cup.config.json: what Lint and Compile do when they are given no arguments.
2
+
3
+ {"lint": {"paths": ["src"], "exclude": ["*/generated/*"], "disable": ["CUP-I005"]},
4
+ "compile": [{"target": "app.pipelines:checkout", "out": "build/checkout",
5
+ "lowering": "inline", "observe": false}]}
6
+
7
+ The file is optional and every key in it is optional. A key is here only
8
+ because a tool reads it: one that no tool reads is an error, not ignored, so
9
+ the file cannot fill up with settings that do nothing. An argument given on
10
+ the command line wins over the file.
11
+ """
12
+
13
+ import json
14
+ import os
15
+ from typing import Optional
16
+
17
+ __all__ = ["ConfigError", "DEFAULT_NAME", "load_config"]
18
+
19
+ DEFAULT_NAME = "cup.config.json"
20
+ _SECTIONS = ("lint", "compile")
21
+ _LINT_KEYS = ("paths", "exclude", "disable")
22
+ _PIPELINE_KEYS = ("target", "out", "lowering", "observe")
23
+ _LOWERINGS = ("steps", "inline")
24
+
25
+
26
+ class ConfigError(Exception):
27
+ """The config file cannot be used as it is."""
28
+
29
+
30
+ def _unknown(where: str, given, allowed) -> None:
31
+ extra = sorted(set(given) - set(allowed))
32
+ if extra:
33
+ raise ConfigError("%s: unknown key %s (the keys are %s)" % (
34
+ where, ", ".join(repr(key) for key in extra), ", ".join(allowed)))
35
+
36
+
37
+ def _strings(where: str, value) -> None:
38
+ if not (isinstance(value, list) and all(isinstance(item, str) for item in value)):
39
+ raise ConfigError("%s must be a list of strings" % where)
40
+
41
+
42
+ def load_config(path: Optional[str] = None) -> Optional[dict]:
43
+ """The config as a dict, checked. With no ``path``: ``cup.config.json`` in
44
+ the working directory, or None when there is no such file."""
45
+ name = path or DEFAULT_NAME
46
+ if not os.path.isfile(name):
47
+ if path is None:
48
+ return None
49
+ raise ConfigError("%s: no such file" % name)
50
+ try:
51
+ with open(name, encoding="utf-8") as handle:
52
+ config = json.load(handle)
53
+ except ValueError as error:
54
+ raise ConfigError("%s is not valid JSON: %s" % (name, error))
55
+ if not isinstance(config, dict):
56
+ raise ConfigError("%s must hold a JSON object" % name)
57
+ _unknown(name, config, _SECTIONS)
58
+
59
+ lint = config.get("lint", {})
60
+ if not isinstance(lint, dict):
61
+ raise ConfigError("%s: lint must be an object" % name)
62
+ _unknown("%s: lint" % name, lint, _LINT_KEYS)
63
+ for key in lint:
64
+ _strings("%s: lint.%s" % (name, key), lint[key])
65
+
66
+ pipelines = config.get("compile", [])
67
+ if not isinstance(pipelines, list):
68
+ raise ConfigError("%s: compile must be a list of pipelines" % name)
69
+ for index, pipeline in enumerate(pipelines):
70
+ where = "%s: compile[%d]" % (name, index)
71
+ if not isinstance(pipeline, dict):
72
+ raise ConfigError("%s must be an object" % where)
73
+ _unknown(where, pipeline, _PIPELINE_KEYS)
74
+ for key in ("target", "out"):
75
+ if not isinstance(pipeline.get(key), str):
76
+ raise ConfigError("%s needs %s, a string" % (where, key))
77
+ if pipeline.get("lowering", "steps") not in _LOWERINGS:
78
+ raise ConfigError("%s: lowering is one of %s" % (where, ", ".join(_LOWERINGS)))
79
+ if not isinstance(pipeline.get("observe", False), bool):
80
+ raise ConfigError("%s: observe is true or false" % where)
81
+ if pipeline.get("observe") and pipeline.get("lowering") == "inline":
82
+ raise ConfigError("%s: observe needs the steps lowering, not inline" % where)
83
+ return config
@@ -0,0 +1,29 @@
1
+ """
2
+ Core: the eight primitives.
3
+
4
+ Payload, Filter, Predicate, Valve, Tap, Hook, State and Pipeline, as conformance/API.md
5
+ defines them. Standard library only. A Valve is added with
6
+ ``Pipeline.add_valve(predicate, filter)``; its class is not a public name.
7
+ """
8
+
9
+ from .payload import Payload
10
+ from .filter import AsyncFilter, Filter
11
+ from .async_step_in_sync_run import AsyncStepInSyncRun
12
+ from .anonymous_step import AnonymousStep
13
+ from .pipeline import Pipeline
14
+ from .predicate import Predicate
15
+ from .tap import AsyncTap, Tap
16
+ from .state import State
17
+ from .async_hook import AsyncHook
18
+ from .hook import Hook
19
+
20
+ __all__ = [
21
+ "Payload",
22
+ "Filter", "AsyncFilter",
23
+ "Pipeline",
24
+ "Predicate",
25
+ "Tap", "AsyncTap",
26
+ "Hook", "AsyncHook",
27
+ "State",
28
+ "AnonymousStep", "AsyncStepInSyncRun",
29
+ ]
@@ -0,0 +1,13 @@
1
+ """AnonymousStep: a step whose identity cannot be derived from the code.
2
+
3
+ Step identity is a pointer to the filter (conformance/API.md, "Step
4
+ identity"). Lambdas, closures, classes defined inside a function, filters
5
+ defined in the entry script and unnamed nested pipelines have no stable
6
+ pointer, and are not independently testable, so the runtime refuses them.
7
+ """
8
+
9
+ __all__ = ["AnonymousStep"]
10
+
11
+
12
+ class AnonymousStep(TypeError):
13
+ """Raised when a step has no stable identity to report."""
@@ -0,0 +1,26 @@
1
+ """AsyncFilter protocol — the processing unit that explicitly awaits.
2
+
3
+ Split from ``filter.py`` to satisfy the one-component-per-file rule (CUP001).
4
+ ``Filter`` remains the default; reach for this only when a step truly awaits
5
+ I/O rather than doing CPU-bound work.
6
+
7
+ ``filter.py`` re-exports this name, so ``from codeupipe.core.filter import
8
+ AsyncFilter`` keeps working.
9
+ """
10
+
11
+ from typing import Protocol, TypeVar
12
+
13
+ from .payload import Payload
14
+
15
+ __all__ = ["AsyncFilter"]
16
+
17
+ TInput = TypeVar('TInput')
18
+ TOutput = TypeVar('TOutput')
19
+
20
+
21
+ class AsyncFilter(Protocol[TInput, TOutput]):
22
+ """Async processing unit — explicitly opts into suspension."""
23
+
24
+ async def call(self, payload: Payload[TInput]) -> Payload[TOutput]:
25
+ """Process the payload and return a transformed result."""
26
+ ...
@@ -0,0 +1,26 @@
1
+ """AsyncHook: a Hook whose methods are coroutines."""
2
+
3
+ from typing import Optional, TypeVar
4
+
5
+ from .hook import Hook
6
+ from .payload import Payload
7
+
8
+ __all__ = ["AsyncHook"]
9
+
10
+ T = TypeVar('T')
11
+
12
+
13
+ class AsyncHook(Hook):
14
+ """Lifecycle hook that explicitly opts into async suspension."""
15
+
16
+ async def before(self, step: Optional[str], payload: Payload[T]) -> None:
17
+ """Before step ``step`` (its name), or before the pipeline starts (``None``)."""
18
+ pass
19
+
20
+ async def after(self, step: Optional[str], payload: Payload[T]) -> None:
21
+ """After step ``step`` (its name), or after the pipeline ends (``None``)."""
22
+ pass
23
+
24
+ async def on_error(self, step: Optional[str], error: Exception, payload: Payload[T]) -> None:
25
+ """Called when an error occurs."""
26
+ pass
@@ -0,0 +1,7 @@
1
+ """Raised when the sync ``Pipeline.run()`` meets async work."""
2
+
3
+ __all__ = ["AsyncStepInSyncRun"]
4
+
5
+
6
+ class AsyncStepInSyncRun(RuntimeError):
7
+ """``run()`` never starts an event loop; use ``run_async()`` for async steps."""
@@ -0,0 +1,25 @@
1
+ """AsyncTap protocol — the observation point that explicitly awaits.
2
+
3
+ Split from ``tap.py`` to satisfy the one-component-per-file rule (CUP001).
4
+ Like every Tap it must not modify the payload, and it must not raise into the
5
+ pipeline it observes.
6
+
7
+ ``tap.py`` re-exports this name, so ``from codeupipe.core.tap import AsyncTap``
8
+ keeps working.
9
+ """
10
+
11
+ from typing import Protocol, TypeVar
12
+
13
+ from .payload import Payload
14
+
15
+ __all__ = ["AsyncTap"]
16
+
17
+ T = TypeVar('T')
18
+
19
+
20
+ class AsyncTap(Protocol[T]):
21
+ """Async observation point — explicitly opts into suspension."""
22
+
23
+ async def observe(self, payload: Payload[T]) -> None:
24
+ """Observe the payload. Must not modify it."""
25
+ ...
@@ -0,0 +1,29 @@
1
+ """Filter protocol: sync by default, async by declaration.
2
+
3
+ New code should prefer ``Filter`` for CPU-bound transforms and opt into
4
+ ``AsyncFilter`` (in ``async_filter.py``) when the step truly awaits I/O.
5
+
6
+ The runtime remains backward compatible with legacy async filters passed to
7
+ ``Pipeline.add_filter()`` by detecting the coroutine signature at
8
+ registration time.
9
+ """
10
+
11
+ from typing import Protocol, TypeVar
12
+
13
+ from .async_filter import AsyncFilter
14
+ from .payload import Payload
15
+
16
+ # AsyncFilter is re-exported for backward compatibility — it moved to
17
+ # async_filter.py under the one-component-per-file rule.
18
+ __all__ = ["Filter", "AsyncFilter"]
19
+
20
+ TInput = TypeVar('TInput')
21
+ TOutput = TypeVar('TOutput')
22
+
23
+
24
+ class Filter(Protocol[TInput, TOutput]):
25
+ """Synchronous processing unit — takes a payload in, returns payload out."""
26
+
27
+ def call(self, payload: Payload[TInput]) -> Payload[TOutput]:
28
+ """Process the payload and return a transformed result."""
29
+ ...