stabilize 0.13.9__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 (156) hide show
  1. stabilize-0.13.9/.env.example +19 -0
  2. stabilize-0.13.9/.gitignore +68 -0
  3. stabilize-0.13.9/.readthedocs.yaml +15 -0
  4. stabilize-0.13.9/LICENSE +201 -0
  5. stabilize-0.13.9/Makefile +94 -0
  6. stabilize-0.13.9/PKG-INFO +283 -0
  7. stabilize-0.13.9/README.md +232 -0
  8. stabilize-0.13.9/docs/api/handlers.rst +65 -0
  9. stabilize-0.13.9/docs/api/models.rst +22 -0
  10. stabilize-0.13.9/docs/api/persistence.rst +17 -0
  11. stabilize-0.13.9/docs/api/queue.rst +22 -0
  12. stabilize-0.13.9/docs/api/tasks.rst +32 -0
  13. stabilize-0.13.9/docs/conf.py +42 -0
  14. stabilize-0.13.9/docs/examples/http_requests.rst +16 -0
  15. stabilize-0.13.9/docs/examples/parallel_processing.rst +27 -0
  16. stabilize-0.13.9/docs/examples/shell_commands.rst +14 -0
  17. stabilize-0.13.9/docs/examples/simple_pipeline.rst +24 -0
  18. stabilize-0.13.9/docs/guide/core_concepts.rst +51 -0
  19. stabilize-0.13.9/docs/guide/data_flow.rst +252 -0
  20. stabilize-0.13.9/docs/guide/flow_control.rst +47 -0
  21. stabilize-0.13.9/docs/guide/getting_started.rst +92 -0
  22. stabilize-0.13.9/docs/guide/persistence.rst +36 -0
  23. stabilize-0.13.9/docs/guide/resilience.rst +29 -0
  24. stabilize-0.13.9/docs/guide/tasks.rst +88 -0
  25. stabilize-0.13.9/docs/index.rst +56 -0
  26. stabilize-0.13.9/docs/requirements.txt +3 -0
  27. stabilize-0.13.9/examples/__init__.py +1 -0
  28. stabilize-0.13.9/examples/docker-example.py +480 -0
  29. stabilize-0.13.9/examples/golden-standard-expected-result.txt +1 -0
  30. stabilize-0.13.9/examples/golden-standard.py +490 -0
  31. stabilize-0.13.9/examples/highway-integration-example.py +412 -0
  32. stabilize-0.13.9/examples/http-example.py +499 -0
  33. stabilize-0.13.9/examples/llama-example.py +683 -0
  34. stabilize-0.13.9/examples/python-example.py +593 -0
  35. stabilize-0.13.9/examples/shell-example.py +347 -0
  36. stabilize-0.13.9/examples/ssh-example.py +468 -0
  37. stabilize-0.13.9/golden_standard_tests/__init__.py +1 -0
  38. stabilize-0.13.9/golden_standard_tests/conftest.py +18 -0
  39. stabilize-0.13.9/golden_standard_tests/expected/disaster_recovery_expected_result.txt +15 -0
  40. stabilize-0.13.9/golden_standard_tests/expected/v2_expected_result.txt +1 -0
  41. stabilize-0.13.9/golden_standard_tests/test_golden_disaster_recovery.py +83 -0
  42. stabilize-0.13.9/golden_standard_tests/test_golden_v2.py +85 -0
  43. stabilize-0.13.9/golden_standard_tests/workflows/__init__.py +1 -0
  44. stabilize-0.13.9/golden_standard_tests/workflows/disaster_recovery_workflow.py +640 -0
  45. stabilize-0.13.9/golden_standard_tests/workflows/v2_workflow.py +490 -0
  46. stabilize-0.13.9/mg.yaml +6 -0
  47. stabilize-0.13.9/migrations/01KDQ4N9QPJ6Q4MCV3V9GHWPV4_initial_schema.sql +97 -0
  48. stabilize-0.13.9/migrations/01KE39HEAN221S7AWNS4A0H750_add_performance_indexes.sql +40 -0
  49. stabilize-0.13.9/migrations/01KE4YJT2W8A6NBX5R7CQMJK84_add_dlq_table.sql +28 -0
  50. stabilize-0.13.9/migrations/01KE5ZQT3X9B7PCS8R8DRMLN85_add_processed_messages.sql +26 -0
  51. stabilize-0.13.9/migrations/01KE60R04X0C8QDTS9SEESMN96_add_task_version.sql +5 -0
  52. stabilize-0.13.9/migrations/01KFA6JDAS811CB5RKPD1FBAST_add_stage_version.sql +5 -0
  53. stabilize-0.13.9/pyproject.toml +107 -0
  54. stabilize-0.13.9/scripts/release.py +655 -0
  55. stabilize-0.13.9/src/stabilize/__init__.py +287 -0
  56. stabilize-0.13.9/src/stabilize/assertions.py +465 -0
  57. stabilize-0.13.9/src/stabilize/audit.py +105 -0
  58. stabilize-0.13.9/src/stabilize/cli.py +1896 -0
  59. stabilize-0.13.9/src/stabilize/conditions.py +351 -0
  60. stabilize-0.13.9/src/stabilize/config_validation.py +568 -0
  61. stabilize-0.13.9/src/stabilize/context/__init__.py +7 -0
  62. stabilize-0.13.9/src/stabilize/context/stage_context.py +170 -0
  63. stabilize-0.13.9/src/stabilize/dag/__init__.py +15 -0
  64. stabilize-0.13.9/src/stabilize/dag/graph.py +232 -0
  65. stabilize-0.13.9/src/stabilize/dag/topological.py +216 -0
  66. stabilize-0.13.9/src/stabilize/errors.py +467 -0
  67. stabilize-0.13.9/src/stabilize/handlers/__init__.py +65 -0
  68. stabilize-0.13.9/src/stabilize/handlers/base.py +412 -0
  69. stabilize-0.13.9/src/stabilize/handlers/cancel_stage.py +106 -0
  70. stabilize-0.13.9/src/stabilize/handlers/complete_stage.py +307 -0
  71. stabilize-0.13.9/src/stabilize/handlers/complete_task.py +131 -0
  72. stabilize-0.13.9/src/stabilize/handlers/complete_workflow.py +217 -0
  73. stabilize-0.13.9/src/stabilize/handlers/continue_parent_stage.py +378 -0
  74. stabilize-0.13.9/src/stabilize/handlers/run_task.py +943 -0
  75. stabilize-0.13.9/src/stabilize/handlers/skip_stage.py +137 -0
  76. stabilize-0.13.9/src/stabilize/handlers/start_stage.py +449 -0
  77. stabilize-0.13.9/src/stabilize/handlers/start_task.py +154 -0
  78. stabilize-0.13.9/src/stabilize/handlers/start_waiting_workflows.py +157 -0
  79. stabilize-0.13.9/src/stabilize/handlers/start_workflow.py +227 -0
  80. stabilize-0.13.9/src/stabilize/launcher.py +307 -0
  81. stabilize-0.13.9/src/stabilize/lifecycle.py +418 -0
  82. stabilize-0.13.9/src/stabilize/logging.py +228 -0
  83. stabilize-0.13.9/src/stabilize/metrics.py +148 -0
  84. stabilize-0.13.9/src/stabilize/migrations/__init__.py +1 -0
  85. stabilize-0.13.9/src/stabilize/models/__init__.py +15 -0
  86. stabilize-0.13.9/src/stabilize/models/stage.py +477 -0
  87. stabilize-0.13.9/src/stabilize/models/status.py +278 -0
  88. stabilize-0.13.9/src/stabilize/models/task.py +158 -0
  89. stabilize-0.13.9/src/stabilize/models/workflow.py +344 -0
  90. stabilize-0.13.9/src/stabilize/monitor/__init__.py +63 -0
  91. stabilize-0.13.9/src/stabilize/monitor/data.py +482 -0
  92. stabilize-0.13.9/src/stabilize/monitor/display.py +800 -0
  93. stabilize-0.13.9/src/stabilize/orchestrator.py +113 -0
  94. stabilize-0.13.9/src/stabilize/persistence/__init__.py +28 -0
  95. stabilize-0.13.9/src/stabilize/persistence/connection.py +185 -0
  96. stabilize-0.13.9/src/stabilize/persistence/factory.py +140 -0
  97. stabilize-0.13.9/src/stabilize/persistence/memory.py +512 -0
  98. stabilize-0.13.9/src/stabilize/persistence/postgres.py +1229 -0
  99. stabilize-0.13.9/src/stabilize/persistence/sqlite.py +1522 -0
  100. stabilize-0.13.9/src/stabilize/persistence/store.py +636 -0
  101. stabilize-0.13.9/src/stabilize/persistence/transaction.py +203 -0
  102. stabilize-0.13.9/src/stabilize/queue/__init__.py +59 -0
  103. stabilize-0.13.9/src/stabilize/queue/messages.py +400 -0
  104. stabilize-0.13.9/src/stabilize/queue/processor.py +464 -0
  105. stabilize-0.13.9/src/stabilize/queue/queue.py +854 -0
  106. stabilize-0.13.9/src/stabilize/queue/sqlite_queue.py +621 -0
  107. stabilize-0.13.9/src/stabilize/recovery.py +359 -0
  108. stabilize-0.13.9/src/stabilize/resilience/__init__.py +19 -0
  109. stabilize-0.13.9/src/stabilize/resilience/bulkheads.py +170 -0
  110. stabilize-0.13.9/src/stabilize/resilience/circuits.py +175 -0
  111. stabilize-0.13.9/src/stabilize/resilience/config.py +241 -0
  112. stabilize-0.13.9/src/stabilize/resilience/executor.py +168 -0
  113. stabilize-0.13.9/src/stabilize/resilience/process_executor.py +170 -0
  114. stabilize-0.13.9/src/stabilize/resilience/timeouts.py +56 -0
  115. stabilize-0.13.9/src/stabilize/stages/__init__.py +11 -0
  116. stabilize-0.13.9/src/stabilize/stages/builder.py +253 -0
  117. stabilize-0.13.9/src/stabilize/tasks/__init__.py +19 -0
  118. stabilize-0.13.9/src/stabilize/tasks/docker.py +463 -0
  119. stabilize-0.13.9/src/stabilize/tasks/highway/__init__.py +32 -0
  120. stabilize-0.13.9/src/stabilize/tasks/highway/config.py +87 -0
  121. stabilize-0.13.9/src/stabilize/tasks/highway/task.py +465 -0
  122. stabilize-0.13.9/src/stabilize/tasks/http.py +639 -0
  123. stabilize-0.13.9/src/stabilize/tasks/interface.py +335 -0
  124. stabilize-0.13.9/src/stabilize/tasks/python.py +351 -0
  125. stabilize-0.13.9/src/stabilize/tasks/registry.py +386 -0
  126. stabilize-0.13.9/src/stabilize/tasks/result.py +283 -0
  127. stabilize-0.13.9/src/stabilize/tasks/shell.py +312 -0
  128. stabilize-0.13.9/src/stabilize/tasks/ssh.py +171 -0
  129. stabilize-0.13.9/src/stabilize/tracing.py +327 -0
  130. stabilize-0.13.9/src/stabilize/verification.py +316 -0
  131. stabilize-0.13.9/stabilize.db +0 -0
  132. stabilize-0.13.9/tests/__init__.py +1 -0
  133. stabilize-0.13.9/tests/conftest.py +250 -0
  134. stabilize-0.13.9/tests/test_assertions.py +363 -0
  135. stabilize-0.13.9/tests/test_backoff.py +141 -0
  136. stabilize-0.13.9/tests/test_bug_fixes.py +400 -0
  137. stabilize-0.13.9/tests/test_concurrency.py +195 -0
  138. stabilize-0.13.9/tests/test_conditions.py +300 -0
  139. stabilize-0.13.9/tests/test_config_validation.py +479 -0
  140. stabilize-0.13.9/tests/test_docker_task.py +663 -0
  141. stabilize-0.13.9/tests/test_execution.py +329 -0
  142. stabilize-0.13.9/tests/test_failure_scenarios.py +539 -0
  143. stabilize-0.13.9/tests/test_golden_standard.py +372 -0
  144. stabilize-0.13.9/tests/test_handler_config.py +223 -0
  145. stabilize-0.13.9/tests/test_http.py +680 -0
  146. stabilize-0.13.9/tests/test_integration.py +263 -0
  147. stabilize-0.13.9/tests/test_python_task.py +400 -0
  148. stabilize-0.13.9/tests/test_queue.py +144 -0
  149. stabilize-0.13.9/tests/test_repository.py +287 -0
  150. stabilize-0.13.9/tests/test_resilience.py +524 -0
  151. stabilize-0.13.9/tests/test_shell.py +421 -0
  152. stabilize-0.13.9/tests/test_stage_data_flow.py +970 -0
  153. stabilize-0.13.9/tests/test_status_transitions.py +170 -0
  154. stabilize-0.13.9/tests/test_timeout_enforcement.py +181 -0
  155. stabilize-0.13.9/tests/test_topological.py +284 -0
  156. stabilize-0.13.9/tests/test_verification.py +192 -0
@@ -0,0 +1,19 @@
1
+ # Stabilize Environment Configuration
2
+
3
+ # Database Configuration
4
+ # PostgreSQL: postgresql://user:pass@localhost:5432/stabilize
5
+ # SQLite: sqlite:///./stabilize.db
6
+ MG_DATABASE_URL=postgresql://postgres:postgres@localhost:5432/stabilize
7
+
8
+ # Resilience Configuration (optional, defaults shown)
9
+
10
+ # Bulkhead settings per task type - max concurrent executions
11
+ STABILIZE_BULKHEAD_SHELL_MAX_CONCURRENT=5
12
+ STABILIZE_BULKHEAD_PYTHON_MAX_CONCURRENT=3
13
+ STABILIZE_BULKHEAD_HTTP_MAX_CONCURRENT=10
14
+ STABILIZE_BULKHEAD_DOCKER_MAX_CONCURRENT=3
15
+ STABILIZE_BULKHEAD_SSH_MAX_CONCURRENT=5
16
+
17
+ # Circuit breaker settings
18
+ STABILIZE_CIRCUIT_FAILURE_THRESHOLD=0.5
19
+ STABILIZE_CIRCUIT_COOLDOWN_SECONDS=30
@@ -0,0 +1,68 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+
5
+ # C extensions
6
+ *.so
7
+
8
+ # Distribution / packaging
9
+ .Python
10
+ env/
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ .venv
21
+ venv
22
+ sdist/
23
+ var/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+
28
+ # PyInstaller
29
+ # Usually these files are written by a python script from a template
30
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
31
+ *.manifest
32
+ *.spec
33
+
34
+ # Installer logs
35
+ pip-log.txt
36
+ pip-delete-this-directory.txt
37
+
38
+ # Unit test / coverage reports
39
+ htmlcov/
40
+ .tox/
41
+ .coverage
42
+ .coverage.*
43
+ .cache
44
+ nosetests.xml
45
+ coverage.xml
46
+ *,cover
47
+
48
+ # Translations
49
+ *.mo
50
+ *.pot
51
+
52
+ # Django stuff:
53
+ *.log
54
+
55
+ # Sphinx documentation
56
+ docs/_build/
57
+
58
+ # PyBuilder
59
+ target/
60
+ S3_IMPLEMENTATION_PLAN.md
61
+ COMPLETE_S3_INTEGRATION.sh
62
+ data/
63
+ test_table*
64
+ .env
65
+ next-steps.md
66
+ CERTIFICATION_AUDIT_REPORT.md
67
+
68
+ *.md
@@ -0,0 +1,15 @@
1
+ version: 2
2
+
3
+ build:
4
+ os: ubuntu-22.04
5
+ tools:
6
+ python: "3.11"
7
+
8
+ python:
9
+ install:
10
+ - method: pip
11
+ path: .
12
+ - requirements: docs/requirements.txt
13
+
14
+ sphinx:
15
+ configuration: docs/conf.py
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 Farshid Ashouri
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,94 @@
1
+ # Stabilize Makefile
2
+ # Run tests on SQLite and PostgreSQL backends
3
+
4
+ .PHONY: help test golden-tests golden-tests-sqlite golden-tests-postgres test-all lint type-check
5
+
6
+ # Default target
7
+ help:
8
+ @echo "Stabilize Test Commands:"
9
+ @echo ""
10
+ @echo " make test - Run all unit tests (both backends)"
11
+ @echo " make test-sqlite - Run unit tests on SQLite only"
12
+ @echo " make test-postgres - Run unit tests on PostgreSQL only (requires Docker)"
13
+ @echo ""
14
+ @echo " make golden-tests - Run golden standard tests (both backends)"
15
+ @echo " make golden-tests-sqlite - Run golden tests on SQLite only"
16
+ @echo " make golden-tests-postgres - Run golden tests on PostgreSQL only (requires Docker)"
17
+ @echo ""
18
+ @echo " make test-all - Run all tests including golden standards"
19
+ @echo ""
20
+ @echo " make lint - Run ruff linter"
21
+ @echo " make type-check - Run mypy type checker"
22
+ @echo " make check - Run lint + type-check + tests"
23
+ @echo ""
24
+
25
+ # =============================================================================
26
+ # Unit Tests
27
+ # =============================================================================
28
+
29
+ # Run all unit tests (both backends)
30
+ test:
31
+ python -m pytest tests/ -v --tb=short
32
+
33
+ # Run unit tests on SQLite only
34
+ test-sqlite:
35
+ python -m pytest tests/ -v --tb=short -k "sqlite"
36
+
37
+ # Run unit tests on PostgreSQL only (requires Docker)
38
+ test-postgres:
39
+ python -m pytest tests/ -v --tb=short -k "postgres"
40
+
41
+ # =============================================================================
42
+ # Golden Standard Tests
43
+ # =============================================================================
44
+
45
+ # Run golden standard tests on both backends
46
+ golden-tests: golden-tests-sqlite golden-tests-postgres
47
+
48
+ # Run golden tests on SQLite only (fast, no Docker required)
49
+ golden-tests-sqlite:
50
+ python -m pytest golden_standard_tests/ -v --tb=short -k "sqlite"
51
+
52
+ # Run golden tests on PostgreSQL only (requires Docker)
53
+ golden-tests-postgres:
54
+ python -m pytest golden_standard_tests/ -v --tb=short -k "postgres"
55
+
56
+ # =============================================================================
57
+ # Combined Tests
58
+ # =============================================================================
59
+
60
+ # Run all tests including golden standards
61
+ test-all: test golden-tests
62
+
63
+ # =============================================================================
64
+ # Code Quality
65
+ # =============================================================================
66
+
67
+ # Run ruff linter
68
+ lint:
69
+ ruff check src/ tests/ golden_standard_tests/
70
+
71
+ # Run ruff linter with auto-fix
72
+ lint-fix:
73
+ ruff check src/ tests/ golden_standard_tests/ --fix
74
+
75
+ # Run mypy type checker
76
+ type-check:
77
+ mypy src/
78
+
79
+ # Run all quality checks
80
+ check: lint type-check test
81
+
82
+ # =============================================================================
83
+ # Development Helpers
84
+ # =============================================================================
85
+
86
+ # Install development dependencies
87
+ install-dev:
88
+ pip install -e ".[dev]"
89
+
90
+ # Clean up cache files
91
+ clean:
92
+ rm -rf __pycache__ .pytest_cache .mypy_cache .ruff_cache
93
+ find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
94
+ find . -type f -name "*.pyc" -delete 2>/dev/null || true
@@ -0,0 +1,283 @@
1
+ Metadata-Version: 2.4
2
+ Name: stabilize
3
+ Version: 0.13.9
4
+ Summary: Highway Workflow Engine - Stabilize execution layer
5
+ Project-URL: Homepage, https://github.com/rodmena-limited/stabilize
6
+ Project-URL: Repository, https://github.com/rodmena-limited/stabilize
7
+ Project-URL: Issues, https://github.com/rodmena-limited/stabilize/issues
8
+ Author-email: Farshid Ashouri <farsheed.ashouri@gmail.com>
9
+ License: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: dag,orchestration,pipeline,task-runner,workflow
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Programming Language :: Python :: 3
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
+ Requires-Python: >=3.11
21
+ Requires-Dist: bulkman>=0.1.0
22
+ Requires-Dist: pydantic>=2.0
23
+ Requires-Dist: python-ulid>=2.0
24
+ Requires-Dist: resilient-circuit>=0.1.0
25
+ Provides-Extra: all
26
+ Requires-Dist: migretti>=0.3; extra == 'all'
27
+ Requires-Dist: opentelemetry-api>=1.20; extra == 'all'
28
+ Requires-Dist: opentelemetry-sdk>=1.20; extra == 'all'
29
+ Requires-Dist: psycopg[pool]>=3.0; extra == 'all'
30
+ Requires-Dist: structlog>=24.0; extra == 'all'
31
+ Provides-Extra: dev
32
+ Requires-Dist: migretti>=0.3; extra == 'dev'
33
+ Requires-Dist: mypy>=1.8; extra == 'dev'
34
+ Requires-Dist: opentelemetry-api>=1.20; extra == 'dev'
35
+ Requires-Dist: opentelemetry-sdk>=1.20; extra == 'dev'
36
+ Requires-Dist: psycopg[pool]>=3.0; extra == 'dev'
37
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
38
+ Requires-Dist: pytest-xdist>=3.0; extra == 'dev'
39
+ Requires-Dist: pytest>=8.0; extra == 'dev'
40
+ Requires-Dist: ruff>=0.1; extra == 'dev'
41
+ Requires-Dist: structlog>=24.0; extra == 'dev'
42
+ Requires-Dist: testcontainers>=4.0; extra == 'dev'
43
+ Provides-Extra: observability
44
+ Requires-Dist: opentelemetry-api>=1.20; extra == 'observability'
45
+ Requires-Dist: opentelemetry-sdk>=1.20; extra == 'observability'
46
+ Requires-Dist: structlog>=24.0; extra == 'observability'
47
+ Provides-Extra: postgres
48
+ Requires-Dist: migretti>=0.3; extra == 'postgres'
49
+ Requires-Dist: psycopg[pool]>=3.0; extra == 'postgres'
50
+ Description-Content-Type: text/markdown
51
+
52
+ # Stabilize
53
+
54
+ A lightweight full featured Python workflow execution engine with DAG-based stage orchestration.
55
+
56
+ ## Requirements
57
+
58
+ - Python 3.11+
59
+ - SQLite (included) or PostgreSQL 12+
60
+
61
+ ## Installation
62
+
63
+ ```bash
64
+ pip install stabilize # SQLite support only
65
+ pip install stabilize[postgres] # PostgreSQL support
66
+ pip install stabilize[all] # All features
67
+ ```
68
+
69
+ ## Features
70
+
71
+ - Message-driven DAG execution engine
72
+ - Parallel and sequential stage execution
73
+ - Synthetic stages (before/after/onFailure)
74
+ - PostgreSQL and SQLite persistence
75
+ - Pluggable task system
76
+ - Retry and timeout support
77
+
78
+ ## Quick Start
79
+
80
+ ```python
81
+ from stabilize import (
82
+ Workflow, StageExecution, TaskExecution,
83
+ SqliteWorkflowStore, SqliteQueue, QueueProcessor, Orchestrator,
84
+ Task, TaskResult, TaskRegistry,
85
+ # All 11 handlers are required
86
+ StartWorkflowHandler, StartWaitingWorkflowsHandler, StartStageHandler,
87
+ SkipStageHandler, CancelStageHandler, ContinueParentStageHandler,
88
+ StartTaskHandler, RunTaskHandler, CompleteTaskHandler,
89
+ CompleteStageHandler, CompleteWorkflowHandler,
90
+ )
91
+
92
+ # Define a custom task
93
+ class HelloTask(Task):
94
+ def execute(self, stage: StageExecution) -> TaskResult:
95
+ name = stage.context.get("name", "World")
96
+ return TaskResult.success(outputs={"greeting": f"Hello, {name}!"})
97
+
98
+ # Create a workflow
99
+ workflow = Workflow.create(
100
+ application="my-app",
101
+ name="Hello Workflow",
102
+ stages=[
103
+ StageExecution(
104
+ ref_id="1",
105
+ type="hello",
106
+ name="Say Hello",
107
+ tasks=[
108
+ TaskExecution.create(
109
+ name="Hello Task",
110
+ implementing_class="hello",
111
+ stage_start=True,
112
+ stage_end=True,
113
+ ),
114
+ ],
115
+ context={"name": "Stabilize"},
116
+ ),
117
+ ],
118
+ )
119
+
120
+ # Setup persistence and queue
121
+ store = SqliteWorkflowStore("sqlite:///:memory:", create_tables=True)
122
+ queue = SqliteQueue("sqlite:///:memory:")
123
+ queue._create_table()
124
+
125
+ # Register tasks
126
+ registry = TaskRegistry()
127
+ registry.register("hello", HelloTask)
128
+
129
+ # Create processor and register handlers
130
+ processor = QueueProcessor(queue)
131
+ for handler in [
132
+ StartWorkflowHandler(queue, store),
133
+ StartWaitingWorkflowsHandler(queue, store),
134
+ StartStageHandler(queue, store),
135
+ SkipStageHandler(queue, store),
136
+ CancelStageHandler(queue, store),
137
+ ContinueParentStageHandler(queue, store),
138
+ StartTaskHandler(queue, store, registry),
139
+ RunTaskHandler(queue, store, registry),
140
+ CompleteTaskHandler(queue, store),
141
+ CompleteStageHandler(queue, store),
142
+ CompleteWorkflowHandler(queue, store),
143
+ ]:
144
+ processor.register_handler(handler)
145
+
146
+ orchestrator = Orchestrator(queue)
147
+
148
+ # Run workflow
149
+ store.store(workflow)
150
+ orchestrator.start(workflow)
151
+ processor.process_all(timeout=10.0)
152
+
153
+ # Check result
154
+ result = store.retrieve(workflow.id)
155
+ print(f"Status: {result.status}") # WorkflowStatus.SUCCEEDED
156
+ print(f"Output: {result.stages[0].outputs}") # {'greeting': 'Hello, Stabilize!'}
157
+ ```
158
+
159
+ ## Built-in Tasks
160
+
161
+ Stabilize includes ready-to-use tasks for common operations:
162
+
163
+ ### ShellTask - Execute Shell Commands
164
+
165
+ ```python
166
+ from stabilize import ShellTask
167
+
168
+ registry.register("shell", ShellTask)
169
+
170
+ # Use in stage context
171
+ context = {
172
+ "command": "npm install && npm test",
173
+ "cwd": "/app",
174
+ "timeout": 300,
175
+ "env": {"NODE_ENV": "test"},
176
+ }
177
+ ```
178
+
179
+ ### HTTPTask - HTTP/API Requests
180
+
181
+ ```python
182
+ from stabilize import HTTPTask
183
+
184
+ registry.register("http", HTTPTask)
185
+
186
+ # GET with JSON parsing
187
+ context = {"url": "https://api.example.com/data", "parse_json": True}
188
+
189
+ # POST with JSON body
190
+ context = {"url": "https://api.example.com/users", "method": "POST", "json": {"name": "John"}}
191
+
192
+ # With authentication
193
+ context = {"url": "https://api.example.com/private", "bearer_token": "token"}
194
+
195
+ # File upload
196
+ context = {"url": "https://api.example.com/upload", "method": "POST", "upload_file": "/path/to/file.pdf"}
197
+ ```
198
+
199
+ See `examples/` directory for complete examples.
200
+
201
+ ## Parallel Stages
202
+
203
+ Stages with shared dependencies run in parallel:
204
+
205
+ ```python
206
+ # Setup
207
+ # / \
208
+ # Test Lint
209
+ # \ /
210
+ # Deploy
211
+
212
+ workflow = Workflow.create(
213
+ application="my-app",
214
+ name="CI/CD Pipeline",
215
+ stages=[
216
+ StageExecution(ref_id="setup", type="setup", name="Setup", ...),
217
+ StageExecution(ref_id="test", type="test", name="Test",
218
+ requisite_stage_ref_ids={"setup"}, ...),
219
+ StageExecution(ref_id="lint", type="lint", name="Lint",
220
+ requisite_stage_ref_ids={"setup"}, ...),
221
+ StageExecution(ref_id="deploy", type="deploy", name="Deploy",
222
+ requisite_stage_ref_ids={"test", "lint"}, ...),
223
+ ],
224
+ )
225
+ ```
226
+
227
+ ## Database Setup
228
+
229
+ ### SQLite
230
+
231
+ No setup required. Schema is created automatically.
232
+
233
+ ### PostgreSQL
234
+
235
+ Apply migrations using the CLI:
236
+
237
+ ```bash
238
+ # Using mg.yaml in current directory
239
+ stabilize mg-up
240
+
241
+ # Using database URL
242
+ stabilize mg-up --db-url postgres://user:pass@host:5432/dbname
243
+
244
+ # Using environment variable
245
+ MG_DATABASE_URL=postgres://user:pass@host:5432/dbname stabilize mg-up
246
+
247
+ # Check migration status
248
+ stabilize mg-status
249
+ ```
250
+
251
+ Example mg.yaml:
252
+
253
+ ```yaml
254
+ database:
255
+ host: localhost
256
+ port: 5432
257
+ user: postgres
258
+ password: postgres
259
+ dbname: stabilize
260
+ ```
261
+
262
+ ## CLI Reference
263
+
264
+ ```
265
+ stabilize mg-up [--db-url URL] Apply pending PostgreSQL migrations
266
+ stabilize mg-status [--db-url URL] Show migration status
267
+ stabilize monitor [--db-url URL] Real-time workflow monitoring dashboard
268
+ stabilize prompt Output documentation for pipeline code generation
269
+ ```
270
+
271
+ ## Running Tests
272
+
273
+ ```bash
274
+ # All tests (requires Docker for PostgreSQL)
275
+ pytest tests/ -v
276
+
277
+ # SQLite tests only (no Docker)
278
+ pytest tests/ -v -k sqlite
279
+ ```
280
+
281
+ ## License
282
+
283
+ Apache 2.0