qubership-pipelines-declarative-executor 2.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.
- qubership_pipelines_declarative_executor-2.0.0/LICENSE +211 -0
- qubership_pipelines_declarative_executor-2.0.0/PKG-INFO +129 -0
- qubership_pipelines_declarative_executor-2.0.0/README.md +106 -0
- qubership_pipelines_declarative_executor-2.0.0/pyproject.toml +27 -0
- qubership_pipelines_declarative_executor-2.0.0/src/pipelines_declarative_executor/__init__.py +3 -0
- qubership_pipelines_declarative_executor-2.0.0/src/pipelines_declarative_executor/__main__.py +122 -0
- qubership_pipelines_declarative_executor-2.0.0/src/pipelines_declarative_executor/executor/condition_processor.py +28 -0
- qubership_pipelines_declarative_executor-2.0.0/src/pipelines_declarative_executor/executor/context_files_processor.py +135 -0
- qubership_pipelines_declarative_executor-2.0.0/src/pipelines_declarative_executor/executor/params_processor.py +59 -0
- qubership_pipelines_declarative_executor-2.0.0/src/pipelines_declarative_executor/executor/pipeline_executor.py +68 -0
- qubership_pipelines_declarative_executor-2.0.0/src/pipelines_declarative_executor/executor/stage_processor.py +191 -0
- qubership_pipelines_declarative_executor-2.0.0/src/pipelines_declarative_executor/model/exceptions.py +10 -0
- qubership_pipelines_declarative_executor-2.0.0/src/pipelines_declarative_executor/model/pipeline.py +112 -0
- qubership_pipelines_declarative_executor-2.0.0/src/pipelines_declarative_executor/model/report.py +28 -0
- qubership_pipelines_declarative_executor-2.0.0/src/pipelines_declarative_executor/model/stage.py +67 -0
- qubership_pipelines_declarative_executor-2.0.0/src/pipelines_declarative_executor/orchestrator/pipeline_orchestrator.py +182 -0
- qubership_pipelines_declarative_executor-2.0.0/src/pipelines_declarative_executor/orchestrator/retry_orchestrator.py +215 -0
- qubership_pipelines_declarative_executor-2.0.0/src/pipelines_declarative_executor/report/report_collector.py +87 -0
- qubership_pipelines_declarative_executor-2.0.0/src/pipelines_declarative_executor/report/report_uploader.py +189 -0
- qubership_pipelines_declarative_executor-2.0.0/src/pipelines_declarative_executor/utils/archive_utils.py +50 -0
- qubership_pipelines_declarative_executor-2.0.0/src/pipelines_declarative_executor/utils/auth_utils.py +102 -0
- qubership_pipelines_declarative_executor-2.0.0/src/pipelines_declarative_executor/utils/common_utils.py +96 -0
- qubership_pipelines_declarative_executor-2.0.0/src/pipelines_declarative_executor/utils/constants.py +17 -0
- qubership_pipelines_declarative_executor-2.0.0/src/pipelines_declarative_executor/utils/env_var_utils.py +67 -0
- qubership_pipelines_declarative_executor-2.0.0/src/pipelines_declarative_executor/utils/logging_utils.py +87 -0
- qubership_pipelines_declarative_executor-2.0.0/src/pipelines_declarative_executor/utils/sops_utils.py +106 -0
- qubership_pipelines_declarative_executor-2.0.0/src/pipelines_declarative_executor/utils/string_utils.py +124 -0
- qubership_pipelines_declarative_executor-2.0.0/src/pipelines_declarative_executor/x_modules_ops/dict_utils.py +91 -0
- qubership_pipelines_declarative_executor-2.0.0/src/pipelines_declarative_executor/x_modules_ops/job_data_registry.py +127 -0
|
@@ -0,0 +1,211 @@
|
|
|
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
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
This product contains parts of the 7-Zip program.
|
|
208
|
+
7-Zip is free software licensed under the GNU Lesser General Public License (LGPL).
|
|
209
|
+
You can find the source code for 7-Zip at: https://www.7-zip.org/
|
|
210
|
+
And license information at https://www.7-zip.org/license.txt
|
|
211
|
+
Copyright (C) 1999-2024 Igor Pavlov.
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: qubership-pipelines-declarative-executor
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Qubership Pipelines Declarative Executor
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Author: Qubership
|
|
8
|
+
Requires-Python: >=3.11,<4.0
|
|
9
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Requires-Dist: PyYAML (>=6.0,<7.0)
|
|
16
|
+
Requires-Dist: aiofiles (>=24.1.0,<25.0.0)
|
|
17
|
+
Requires-Dist: aiohttp (>=3.12.15,<4.0.0)
|
|
18
|
+
Requires-Dist: click (>=8.1,<9.0)
|
|
19
|
+
Requires-Dist: miniopy-async (>=1.23.4,<2.0.0)
|
|
20
|
+
Requires-Dist: requests (>=2.32.3,<3.0.0)
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
[](https://pypi.org/project/qubership-pipelines-declarative-executor/)
|
|
24
|
+

|
|
25
|
+

|
|
26
|
+

|
|
27
|
+
|
|
28
|
+
# Qubership Pipelines Declarative Executor
|
|
29
|
+
|
|
30
|
+
Open-source python pipelines orchestrator and executor.
|
|
31
|
+
|
|
32
|
+
This application is distributed as a library on PyPI, Docker image on GitHub Packages, and as a Reusable Workflow for your existing GitHub workflows.
|
|
33
|
+
You can use this application in any of the provided forms that best suits your needs.
|
|
34
|
+
|
|
35
|
+
## Structure
|
|
36
|
+
|
|
37
|
+
### Docker image
|
|
38
|
+
|
|
39
|
+
Provided Docker image with this application includes:
|
|
40
|
+
|
|
41
|
+
- Pipelines Declarative Executor app itself
|
|
42
|
+
- [Sample "Python Modules"](https://github.com/Netcracker/qubership-pipelines-cli-command-samples) to execute commands in your "Atlas Pipeline"
|
|
43
|
+
- SOPS binaries to securely process configuration files and output parameters
|
|
44
|
+
|
|
45
|
+
#### Using your own "Python Modules"
|
|
46
|
+
|
|
47
|
+
Sample "Python Modules", included in distributed Docker image, are only showcasing the intended way of working via Execution Commands and Execution Context.
|
|
48
|
+
You might need to have your custom commands executed in "Atlas Pipelines" - then you will need to create and distribute your own implementation.
|
|
49
|
+
There's a [Development Guide](https://github.com/Netcracker/qubership-pipelines-cli-command-samples/blob/main/docs/development.md) available in CLI Samples repository.
|
|
50
|
+
|
|
51
|
+
A few ways you can include your own "Python Modules" into executor Docker image:
|
|
52
|
+
|
|
53
|
+
- Building new [image](./Dockerfile) with required modules, and putting path to them to `PIPELINES_DECLARATIVE_EXECUTOR_PYTHON_MODULE_PATH` env variable
|
|
54
|
+
- Mounting directory with your modules into the image, while also upgrading `PIPELINES_DECLARATIVE_EXECUTOR_PYTHON_MODULE_PATH` env variable to mounted path
|
|
55
|
+
|
|
56
|
+
Multiple "Python Modules" are supported via `stage.path` property ([check syntax guide for more information](docs/atlas_pipeline_syntax.md#module-path))
|
|
57
|
+
|
|
58
|
+
### Python Dependency
|
|
59
|
+
|
|
60
|
+
You can also use this application as a python dependency, by installing it from PyPI:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install qubership-pipelines-declarative-executor
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Or adding it to your dependency list:
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
qubership-pipelines-declarative-executor = "^2.0.0"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Common CI Workflows (GitHub/GitLab)
|
|
73
|
+
|
|
74
|
+
Alternative usage scenario (although much less configurable than creating your own workflow, since we can't pass custom env variables into it) is using provided [Reusable Workflow](.github/workflows/reusable-pipeline.yml) in your repository.
|
|
75
|
+
There is an example of how it can be invoked from GitHub Workflow: [pipeline.yml](.github/workflows/pipeline.yml)
|
|
76
|
+
|
|
77
|
+
There's also an example of a similar implementation [for GitLab](docs/gitlab/.gitlab-ci.yml)
|
|
78
|
+
|
|
79
|
+
When you've created your own Docker image with necessary "Python Modules" (non-sample ones), you might want to create your own workflows using that image.
|
|
80
|
+
Provided workflows serve as a starting point, but custom workflows will allow full control and ability to pass env variables and local files.
|
|
81
|
+
|
|
82
|
+
## Features
|
|
83
|
+
|
|
84
|
+
### Atlas Pipeline definitions
|
|
85
|
+
|
|
86
|
+
"AtlasPipelines" are intended to work via Execution Commands, packed into ["Python Modules"](https://github.com/Netcracker/qubership-pipelines-cli-command-samples/blob/main/docs/development.md).
|
|
87
|
+
|
|
88
|
+
Pipeline itself describes data flow between sequentially executed stages, while also supporting invoking nested pipelines (for reusing configuration) and parallel stages.
|
|
89
|
+
|
|
90
|
+
This repository uses actual "AtlasPipelines" in its tests, you can [check them here](tests/pipeline_configs).
|
|
91
|
+
|
|
92
|
+
Separate article on syntax with examples [is available here](docs/atlas_pipeline_syntax.md).
|
|
93
|
+
|
|
94
|
+
### Reporting
|
|
95
|
+
|
|
96
|
+
Executor collects and can upload report (intended for UI representation) of currently executed pipeline.
|
|
97
|
+
|
|
98
|
+
This feature is configured via env variables in [Report section](docs/env_vars.md#report-params).
|
|
99
|
+
You can select `REPORT_SEND_MODE` (either `ON_COMPLETION` or `PERIODIC`), send intervals, and endpoint configs:
|
|
100
|
+
|
|
101
|
+
Report configuration [example is here](docs/config_examples.md#report_remote_endpoints)
|
|
102
|
+
|
|
103
|
+
### Auth Rules
|
|
104
|
+
|
|
105
|
+
Orchestrator can fetch remote AtlasPipeline and AtlasConfig files from various sources. To access private repositories or authenticated endpoints, you can configure **authentication rules**.
|
|
106
|
+
|
|
107
|
+
Example Auth Rules [are present here](docs/config_examples.md#auth_rules)
|
|
108
|
+
|
|
109
|
+
Rules are processed in order they are defined, and first applicable rule will be used (in case when multiple would've matched).
|
|
110
|
+
|
|
111
|
+
If no rules match, requests are made without authentication.
|
|
112
|
+
|
|
113
|
+
### CI Wrapper configuration
|
|
114
|
+
|
|
115
|
+
You can pass your CI (GitHub, GitLab, Jenkins, etc.) execution instance parameters (user who triggered pipeline, pipeline's URL) to make them available in the report via [environment variables](docs/env_vars.md#executor-wrapper-params)
|
|
116
|
+
|
|
117
|
+
### SOPS Encryption
|
|
118
|
+
|
|
119
|
+
Executor decrypts input files (pipelines and configs) if they are encrypted with [SOPS](https://getsops.io/), and can also encrypt any output secure files.
|
|
120
|
+
This feature is configured via a [set of environment variables](docs/env_vars.md#sops-encryption-params)
|
|
121
|
+
|
|
122
|
+
### ENV Configuration
|
|
123
|
+
|
|
124
|
+
Other parameters are available and documented in the [General section](docs/env_vars.md#general-params)
|
|
125
|
+
|
|
126
|
+
### Performance
|
|
127
|
+
|
|
128
|
+
Performance tests and comparisons of [different ways to invoke imported "Python Modules" will be available here](docs/performance.md)
|
|
129
|
+
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
[](https://pypi.org/project/qubership-pipelines-declarative-executor/)
|
|
2
|
+

|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
# Qubership Pipelines Declarative Executor
|
|
7
|
+
|
|
8
|
+
Open-source python pipelines orchestrator and executor.
|
|
9
|
+
|
|
10
|
+
This application is distributed as a library on PyPI, Docker image on GitHub Packages, and as a Reusable Workflow for your existing GitHub workflows.
|
|
11
|
+
You can use this application in any of the provided forms that best suits your needs.
|
|
12
|
+
|
|
13
|
+
## Structure
|
|
14
|
+
|
|
15
|
+
### Docker image
|
|
16
|
+
|
|
17
|
+
Provided Docker image with this application includes:
|
|
18
|
+
|
|
19
|
+
- Pipelines Declarative Executor app itself
|
|
20
|
+
- [Sample "Python Modules"](https://github.com/Netcracker/qubership-pipelines-cli-command-samples) to execute commands in your "Atlas Pipeline"
|
|
21
|
+
- SOPS binaries to securely process configuration files and output parameters
|
|
22
|
+
|
|
23
|
+
#### Using your own "Python Modules"
|
|
24
|
+
|
|
25
|
+
Sample "Python Modules", included in distributed Docker image, are only showcasing the intended way of working via Execution Commands and Execution Context.
|
|
26
|
+
You might need to have your custom commands executed in "Atlas Pipelines" - then you will need to create and distribute your own implementation.
|
|
27
|
+
There's a [Development Guide](https://github.com/Netcracker/qubership-pipelines-cli-command-samples/blob/main/docs/development.md) available in CLI Samples repository.
|
|
28
|
+
|
|
29
|
+
A few ways you can include your own "Python Modules" into executor Docker image:
|
|
30
|
+
|
|
31
|
+
- Building new [image](./Dockerfile) with required modules, and putting path to them to `PIPELINES_DECLARATIVE_EXECUTOR_PYTHON_MODULE_PATH` env variable
|
|
32
|
+
- Mounting directory with your modules into the image, while also upgrading `PIPELINES_DECLARATIVE_EXECUTOR_PYTHON_MODULE_PATH` env variable to mounted path
|
|
33
|
+
|
|
34
|
+
Multiple "Python Modules" are supported via `stage.path` property ([check syntax guide for more information](docs/atlas_pipeline_syntax.md#module-path))
|
|
35
|
+
|
|
36
|
+
### Python Dependency
|
|
37
|
+
|
|
38
|
+
You can also use this application as a python dependency, by installing it from PyPI:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install qubership-pipelines-declarative-executor
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Or adding it to your dependency list:
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
qubership-pipelines-declarative-executor = "^2.0.0"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Common CI Workflows (GitHub/GitLab)
|
|
51
|
+
|
|
52
|
+
Alternative usage scenario (although much less configurable than creating your own workflow, since we can't pass custom env variables into it) is using provided [Reusable Workflow](.github/workflows/reusable-pipeline.yml) in your repository.
|
|
53
|
+
There is an example of how it can be invoked from GitHub Workflow: [pipeline.yml](.github/workflows/pipeline.yml)
|
|
54
|
+
|
|
55
|
+
There's also an example of a similar implementation [for GitLab](docs/gitlab/.gitlab-ci.yml)
|
|
56
|
+
|
|
57
|
+
When you've created your own Docker image with necessary "Python Modules" (non-sample ones), you might want to create your own workflows using that image.
|
|
58
|
+
Provided workflows serve as a starting point, but custom workflows will allow full control and ability to pass env variables and local files.
|
|
59
|
+
|
|
60
|
+
## Features
|
|
61
|
+
|
|
62
|
+
### Atlas Pipeline definitions
|
|
63
|
+
|
|
64
|
+
"AtlasPipelines" are intended to work via Execution Commands, packed into ["Python Modules"](https://github.com/Netcracker/qubership-pipelines-cli-command-samples/blob/main/docs/development.md).
|
|
65
|
+
|
|
66
|
+
Pipeline itself describes data flow between sequentially executed stages, while also supporting invoking nested pipelines (for reusing configuration) and parallel stages.
|
|
67
|
+
|
|
68
|
+
This repository uses actual "AtlasPipelines" in its tests, you can [check them here](tests/pipeline_configs).
|
|
69
|
+
|
|
70
|
+
Separate article on syntax with examples [is available here](docs/atlas_pipeline_syntax.md).
|
|
71
|
+
|
|
72
|
+
### Reporting
|
|
73
|
+
|
|
74
|
+
Executor collects and can upload report (intended for UI representation) of currently executed pipeline.
|
|
75
|
+
|
|
76
|
+
This feature is configured via env variables in [Report section](docs/env_vars.md#report-params).
|
|
77
|
+
You can select `REPORT_SEND_MODE` (either `ON_COMPLETION` or `PERIODIC`), send intervals, and endpoint configs:
|
|
78
|
+
|
|
79
|
+
Report configuration [example is here](docs/config_examples.md#report_remote_endpoints)
|
|
80
|
+
|
|
81
|
+
### Auth Rules
|
|
82
|
+
|
|
83
|
+
Orchestrator can fetch remote AtlasPipeline and AtlasConfig files from various sources. To access private repositories or authenticated endpoints, you can configure **authentication rules**.
|
|
84
|
+
|
|
85
|
+
Example Auth Rules [are present here](docs/config_examples.md#auth_rules)
|
|
86
|
+
|
|
87
|
+
Rules are processed in order they are defined, and first applicable rule will be used (in case when multiple would've matched).
|
|
88
|
+
|
|
89
|
+
If no rules match, requests are made without authentication.
|
|
90
|
+
|
|
91
|
+
### CI Wrapper configuration
|
|
92
|
+
|
|
93
|
+
You can pass your CI (GitHub, GitLab, Jenkins, etc.) execution instance parameters (user who triggered pipeline, pipeline's URL) to make them available in the report via [environment variables](docs/env_vars.md#executor-wrapper-params)
|
|
94
|
+
|
|
95
|
+
### SOPS Encryption
|
|
96
|
+
|
|
97
|
+
Executor decrypts input files (pipelines and configs) if they are encrypted with [SOPS](https://getsops.io/), and can also encrypt any output secure files.
|
|
98
|
+
This feature is configured via a [set of environment variables](docs/env_vars.md#sops-encryption-params)
|
|
99
|
+
|
|
100
|
+
### ENV Configuration
|
|
101
|
+
|
|
102
|
+
Other parameters are available and documented in the [General section](docs/env_vars.md#general-params)
|
|
103
|
+
|
|
104
|
+
### Performance
|
|
105
|
+
|
|
106
|
+
Performance tests and comparisons of [different ways to invoke imported "Python Modules" will be available here](docs/performance.md)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "qubership-pipelines-declarative-executor"
|
|
3
|
+
version = "2.0.0"
|
|
4
|
+
description = "Qubership Pipelines Declarative Executor"
|
|
5
|
+
authors = ["Qubership"]
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
license = "Apache-2.0"
|
|
8
|
+
packages = [{from = "src", include = "pipelines_declarative_executor"}]
|
|
9
|
+
|
|
10
|
+
[tool.poetry.dependencies]
|
|
11
|
+
python = "^3.11"
|
|
12
|
+
PyYAML = "^6.0"
|
|
13
|
+
click = "^8.1"
|
|
14
|
+
requests = "^2.32.3"
|
|
15
|
+
aiohttp = "^3.12.15"
|
|
16
|
+
aiofiles = "^24.1.0"
|
|
17
|
+
miniopy-async = "^1.23.4"
|
|
18
|
+
|
|
19
|
+
[tool.poetry.group.test.dependencies]
|
|
20
|
+
pytest = "^6.0.0"
|
|
21
|
+
|
|
22
|
+
[tool.poetry.scripts]
|
|
23
|
+
pipelines_declarative_executor = "pipelines_declarative_executor.__main__:cli"
|
|
24
|
+
|
|
25
|
+
[build-system]
|
|
26
|
+
requires = ["poetry-core"]
|
|
27
|
+
build-backend = "poetry.core.masonry.api"
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import sys, asyncio, click, logging
|
|
2
|
+
|
|
3
|
+
from pipelines_declarative_executor.utils.env_var_utils import EnvVar
|
|
4
|
+
from pipelines_declarative_executor.utils.logging_utils import LoggingUtils
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@click.group(chain=True)
|
|
8
|
+
def cli():
|
|
9
|
+
pass
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@cli.command("run")
|
|
13
|
+
@click.option('--pipeline_data', required=True, type=str, help="Pipeline data (pipeline/config file paths)")
|
|
14
|
+
@click.option('--pipeline_vars', required=False, type=str, help="Pipeline vars with high priority")
|
|
15
|
+
@click.option('--pipeline_dir', required=False, type=str, help="Path to directory where pipeline will be executed")
|
|
16
|
+
@click.option('--is_dry_run', default=False, type=bool, help="Path to directory where pipeline will be executed")
|
|
17
|
+
@click.option('--log_level', default='INFO', show_default=True,
|
|
18
|
+
type=click.Choice(['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], case_sensitive=False),
|
|
19
|
+
help="Console logging level")
|
|
20
|
+
def __run_pipeline(pipeline_data: str, pipeline_vars: str, pipeline_dir: str, is_dry_run: bool, log_level: str):
|
|
21
|
+
LoggingUtils.CONSOLE_LOG_LEVEL = getattr(logging, log_level.upper(), logging.INFO)
|
|
22
|
+
LoggingUtils.configure_root_logger()
|
|
23
|
+
logging.info(f'command "RUN" with params:\npipeline_data="{pipeline_data}"\npipeline_vars="{pipeline_vars}"'
|
|
24
|
+
f'\npipeline_dir="{pipeline_dir}"\nis_dry_run="{is_dry_run}"\nlog_level="{log_level}"')
|
|
25
|
+
with (LoggingUtils.time_it(), LoggingUtils.profile_it()):
|
|
26
|
+
asyncio.run(create_and_run_pipeline(pipeline_data, pipeline_vars, pipeline_dir, is_dry_run))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@cli.command("retry")
|
|
30
|
+
@click.option('--pipeline_dir', required=True, type=str, help="Path to directory where pipeline was executed")
|
|
31
|
+
@click.option('--retry_vars', required=False, type=str, help="Retry vars with highest priority")
|
|
32
|
+
@click.option('--log_level', default='INFO', show_default=True,
|
|
33
|
+
type=click.Choice(['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], case_sensitive=False),
|
|
34
|
+
help="Console logging level")
|
|
35
|
+
def __retry_pipeline(pipeline_dir: str, retry_vars: str, log_level: str):
|
|
36
|
+
LoggingUtils.CONSOLE_LOG_LEVEL = getattr(logging, log_level.upper(), logging.INFO)
|
|
37
|
+
LoggingUtils.configure_root_logger()
|
|
38
|
+
logging.info(f'command "RETRY" with params:\npipeline_dir="{pipeline_dir}"\nretry_vars="{retry_vars}"'
|
|
39
|
+
f'\nlog_level="{log_level}"')
|
|
40
|
+
with (LoggingUtils.time_it(), LoggingUtils.profile_it()):
|
|
41
|
+
asyncio.run(retry_pipeline(pipeline_dir, retry_vars))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@cli.command("archive")
|
|
45
|
+
@click.option('--pipeline_dir', required=True, type=str, help="Path to directory where pipeline was executed")
|
|
46
|
+
@click.option('--target_path', required=True, type=str, help="Path to resulting archive")
|
|
47
|
+
def __archive_pipeline(pipeline_dir: str, target_path: str):
|
|
48
|
+
LoggingUtils.configure_root_logger()
|
|
49
|
+
logging.info(f'command "ARCHIVE" with params:\npipeline_dir="{pipeline_dir}"\ntarget_path="{target_path}"')
|
|
50
|
+
from pipelines_declarative_executor.utils.archive_utils import ArchiveUtils
|
|
51
|
+
ArchiveUtils.archive(pipeline_dir, target_path)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@cli.command("unarchive")
|
|
55
|
+
@click.option('--archive_path', required=True, type=str, help="Path to archive with pipeline execution")
|
|
56
|
+
@click.option('--target_path', required=True, type=str, help="Path where it will be extracted")
|
|
57
|
+
def __archive_pipeline(archive_path: str, target_path: str):
|
|
58
|
+
LoggingUtils.configure_root_logger()
|
|
59
|
+
logging.info(f'command "UNARCHIVE" with params:\narchive_path="{archive_path}"\ntarget_path="{target_path}"')
|
|
60
|
+
from pipelines_declarative_executor.utils.archive_utils import ArchiveUtils
|
|
61
|
+
ArchiveUtils.unarchive(archive_path, target_path)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
async def create_and_run_pipeline(pipeline_data: str, pipeline_vars: str, pipeline_dir: str, is_dry_run: bool):
|
|
65
|
+
from pipelines_declarative_executor.orchestrator.pipeline_orchestrator import PipelineOrchestrator
|
|
66
|
+
from pipelines_declarative_executor.executor.pipeline_executor import PipelineExecutor
|
|
67
|
+
from pipelines_declarative_executor.report.report_uploader import ReportUploader
|
|
68
|
+
from pipelines_declarative_executor.model.stage import ExecutionStatus
|
|
69
|
+
try:
|
|
70
|
+
pipeline_execution = PipelineOrchestrator.prepare_pipeline_execution(
|
|
71
|
+
pipeline_data=pipeline_data,
|
|
72
|
+
pipeline_vars=pipeline_vars
|
|
73
|
+
)
|
|
74
|
+
except Exception as e:
|
|
75
|
+
logging.error(f"Exception during orchestration: {e}")
|
|
76
|
+
sys.exit(1)
|
|
77
|
+
async with ReportUploader(execution=pipeline_execution, configs=ReportUploader.load_endpoint_configs()):
|
|
78
|
+
await PipelineExecutor.start(
|
|
79
|
+
execution=pipeline_execution,
|
|
80
|
+
execution_folder_path=pipeline_dir,
|
|
81
|
+
is_dry_run=is_dry_run,
|
|
82
|
+
wait_for_finish=True,
|
|
83
|
+
)
|
|
84
|
+
if pipeline_execution.status != ExecutionStatus.SUCCESS:
|
|
85
|
+
sys.exit(1)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
async def retry_pipeline(pipeline_dir: str, retry_vars: str):
|
|
89
|
+
from pipelines_declarative_executor.orchestrator.retry_orchestrator import PipelineRetryOrchestrator
|
|
90
|
+
from pipelines_declarative_executor.executor.pipeline_executor import PipelineExecutor
|
|
91
|
+
from pipelines_declarative_executor.report.report_uploader import ReportUploader
|
|
92
|
+
from pipelines_declarative_executor.model.stage import ExecutionStatus
|
|
93
|
+
try:
|
|
94
|
+
pipeline_execution = PipelineRetryOrchestrator.prepare_retry_execution(
|
|
95
|
+
pipeline_dir=pipeline_dir,
|
|
96
|
+
retry_vars=retry_vars,
|
|
97
|
+
)
|
|
98
|
+
except Exception as e:
|
|
99
|
+
logging.error(f"Exception during orchestration: {e}")
|
|
100
|
+
sys.exit(1)
|
|
101
|
+
async with ReportUploader(execution=pipeline_execution, configs=ReportUploader.load_endpoint_configs()):
|
|
102
|
+
await PipelineExecutor.start(
|
|
103
|
+
execution=pipeline_execution,
|
|
104
|
+
execution_folder_path=pipeline_dir,
|
|
105
|
+
is_dry_run=pipeline_execution.is_dry_run,
|
|
106
|
+
wait_for_finish=True,
|
|
107
|
+
)
|
|
108
|
+
if pipeline_execution.status != ExecutionStatus.SUCCESS:
|
|
109
|
+
sys.exit(1)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
if __name__ == '__main__':
|
|
113
|
+
if EnvVar.IS_LOCAL_DEBUG:
|
|
114
|
+
# local_setup()
|
|
115
|
+
LoggingUtils.configure_root_logger()
|
|
116
|
+
logging.debug("=" * 60)
|
|
117
|
+
logging.warning("RUNNING IN LOCAL DEBUG MODE!")
|
|
118
|
+
with (LoggingUtils.time_it("Total time"), LoggingUtils.profile_it()):
|
|
119
|
+
logging.info("Local Debug run")
|
|
120
|
+
# asyncio.run(local_full_direct_plus_retry())
|
|
121
|
+
else:
|
|
122
|
+
cli()
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from pipelines_declarative_executor.model.pipeline import PipelineExecution
|
|
2
|
+
from pipelines_declarative_executor.model.stage import When, ExecutionStatus
|
|
3
|
+
from pipelines_declarative_executor.model.exceptions import PipelineExecutorException
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ConditionProcessor:
|
|
7
|
+
@staticmethod
|
|
8
|
+
def need_to_execute(execution: PipelineExecution, when: When) -> bool:
|
|
9
|
+
return ConditionProcessor._check_status(execution, when) and ConditionProcessor._check_condition(execution, when)
|
|
10
|
+
|
|
11
|
+
@staticmethod
|
|
12
|
+
def _check_status(execution: PipelineExecution, when: When) -> bool:
|
|
13
|
+
is_any_stage_failed = any(stage.status == ExecutionStatus.FAILED for stage in execution.pipeline.stages)
|
|
14
|
+
return (is_any_stage_failed and ExecutionStatus.FAILED in when.statuses
|
|
15
|
+
or not is_any_stage_failed and ExecutionStatus.SUCCESS in when.statuses)
|
|
16
|
+
|
|
17
|
+
@staticmethod
|
|
18
|
+
def _check_condition(execution: PipelineExecution, when: When) -> bool:
|
|
19
|
+
if not when.condition:
|
|
20
|
+
return True
|
|
21
|
+
try:
|
|
22
|
+
condition = execution.vars.calculate_expression(when.condition)
|
|
23
|
+
result = eval(condition, execution.vars.all_vars())
|
|
24
|
+
execution.logger.debug(f"Condition ('{condition}') evaluation result: {result if isinstance(result, bool) else result + ' -> ' + bool(result)}")
|
|
25
|
+
return bool(result)
|
|
26
|
+
except Exception as e:
|
|
27
|
+
execution.logger.error(f"Error during calculation of condition - '{when.condition}' - {e}")
|
|
28
|
+
raise PipelineExecutorException(e)
|