pypeline-runner 1.18.1__py3-none-any.whl → 1.19.0__py3-none-any.whl

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.
pypeline/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.18.1"
1
+ __version__ = "1.19.0"
pypeline/pypeline.py CHANGED
@@ -5,6 +5,8 @@ from typing import (
5
5
  Generic,
6
6
  List,
7
7
  Optional,
8
+ OrderedDict,
9
+ Tuple,
8
10
  Type,
9
11
  )
10
12
 
@@ -14,7 +16,7 @@ from py_app_dev.core.runnable import Executor
14
16
 
15
17
  from .domain.artifacts import ProjectArtifactsLocator
16
18
  from .domain.execution_context import ExecutionContext
17
- from .domain.pipeline import PipelineConfig, PipelineLoader, PipelineStep, PipelineStepConfig, PipelineStepReference, StepClassFactory, TExecutionContext
19
+ from .domain.pipeline import PipelineConfig, PipelineConfigIterator, PipelineLoader, PipelineStep, PipelineStepConfig, PipelineStepReference, StepClassFactory, TExecutionContext
18
20
 
19
21
 
20
22
  class RunCommandClassFactory(StepClassFactory[PipelineStep[TExecutionContext]]):
@@ -116,45 +118,77 @@ class PipelineScheduler(Generic[TExecutionContext]):
116
118
  self.logger = logger.bind()
117
119
 
118
120
  def get_steps_to_run(self, step_names: Optional[List[str]] = None, single: bool = False) -> List[PipelineStepReference[PipelineStep[TExecutionContext]]]:
119
- return self.filter_steps_references(self.create_pipeline_loader(self.pipeline, self.project_root_dir).load_steps_references(), step_names, single)
121
+ return self.create_pipeline_loader(self.filter_steps(self.pipeline, step_names, single), self.project_root_dir).load_steps_references()
120
122
 
121
123
  @staticmethod
122
- def filter_steps_references(
123
- steps_references: List[PipelineStepReference[PipelineStep[TExecutionContext]]],
124
- step_names: Optional[List[str]],
125
- single: Optional[bool],
126
- ) -> List[PipelineStepReference[PipelineStep[TExecutionContext]]]:
124
+ def filter_steps(pipeline_config: PipelineConfig, step_names: Optional[List[str]], single: bool) -> PipelineConfig:
125
+ """
126
+ Filters the pipeline steps based on the provided step names.
127
+
128
+ If no step names are provided, all steps are returned.
129
+ When `single` is True, only the named steps are returned, otherwise all steps up to the last named step are returned.
130
+ """
127
131
  if not step_names:
128
- return steps_references
132
+ return pipeline_config
129
133
 
130
134
  step_names_set = set(step_names)
131
- filtered_steps = []
132
- found_steps = set()
133
-
134
- if single:
135
- # Include only the explicitly named steps, preserving order
136
- filtered_steps = [step for step in steps_references if step.name in step_names_set]
137
- found_steps = {step.name for step in filtered_steps}
138
- else:
139
- # Include all steps until the last explicitly named step is found
140
- for step in steps_references:
141
- filtered_steps.append(step)
142
- if step.name in step_names_set:
143
- found_steps.add(step.name)
144
- if found_steps == step_names_set:
145
- # Once all named steps have been found, stop here
146
- break
147
- else:
148
- # If loop completes without finding all named steps
149
- missing_steps = step_names_set - found_steps
150
- raise UserNotificationException(f"Steps not found in pipeline configuration: {', '.join(missing_steps)}")
135
+ filtered_groups: List[Tuple[Optional[str], List[PipelineStepConfig]]] = []
136
+ found_steps: set[str] = set()
137
+
138
+ for group_name, steps_config in PipelineConfigIterator(pipeline_config):
139
+ filtered_steps = PipelineScheduler._filter_steps_in_group(steps_config, step_names_set, single, found_steps)
140
+
141
+ if filtered_steps:
142
+ filtered_groups.append((group_name, filtered_steps))
143
+
144
+ if not single and found_steps == step_names_set:
145
+ break
151
146
 
152
147
  missing_steps = step_names_set - found_steps
153
148
  if missing_steps:
154
149
  raise UserNotificationException(f"Steps not found in pipeline configuration: {', '.join(missing_steps)}")
155
150
 
151
+ return PipelineScheduler._create_pipeline_config_from_groups(filtered_groups)
152
+
153
+ @staticmethod
154
+ def _filter_steps_in_group(steps_config: List[PipelineStepConfig], step_names_set: set[str], single: bool, found_steps: set[str]) -> List[PipelineStepConfig]:
155
+ """Filter steps within a single group."""
156
+ filtered_steps = []
157
+
158
+ for step_config in steps_config:
159
+ step_name = step_config.class_name or step_config.step
160
+
161
+ if single:
162
+ if step_name in step_names_set:
163
+ filtered_steps.append(step_config)
164
+ found_steps.add(step_name)
165
+ else:
166
+ filtered_steps.append(step_config)
167
+ if step_name in step_names_set:
168
+ found_steps.add(step_name)
169
+ if found_steps == step_names_set:
170
+ break
171
+
156
172
  return filtered_steps
157
173
 
174
+ @staticmethod
175
+ def _create_pipeline_config_from_groups(groups: List[Tuple[Optional[str], List[PipelineStepConfig]]]) -> PipelineConfig:
176
+ """Create a PipelineConfig from filtered groups."""
177
+ if not groups:
178
+ return []
179
+
180
+ # If all groups have None as group_name, return a simple list
181
+ if all(group_name is None for group_name, _ in groups):
182
+ return [step for _, steps in groups for step in steps]
183
+
184
+ # Otherwise, return an OrderedDict
185
+ result: OrderedDict[str, List[PipelineStepConfig]] = OrderedDict()
186
+ for group_name, steps in groups:
187
+ if group_name is not None:
188
+ result[group_name] = steps
189
+
190
+ return result
191
+
158
192
  @staticmethod
159
193
  def create_pipeline_loader(pipeline: PipelineConfig, project_root_dir: Path) -> PipelineLoader[PipelineStep[TExecutionContext]]:
160
194
  return PipelineLoader[PipelineStep[TExecutionContext]](pipeline, project_root_dir, RunCommandClassFactory())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pypeline-runner
3
- Version: 1.18.1
3
+ Version: 1.19.0
4
4
  Summary: Configure and execute pipelines with Python (similar to GitHub workflows or Jenkins pipelines).
5
5
  License: MIT
6
6
  Author: cuinixam
@@ -20,6 +20,7 @@ Classifier: Topic :: Software Development :: Libraries
20
20
  Requires-Dist: py-app-dev (>=2.10,<3.0)
21
21
  Requires-Dist: pyyaml (>=6.0,<7.0)
22
22
  Requires-Dist: typer (>=0,<1)
23
+ Requires-Dist: west (>=1.0,<2.0)
23
24
  Project-URL: Bug Tracker, https://github.com/cuinixam/pypeline/issues
24
25
  Project-URL: Changelog, https://github.com/cuinixam/pypeline/blob/main/CHANGELOG.md
25
26
  Project-URL: Documentation, https://pypeline-runner.readthedocs.io
@@ -1,4 +1,4 @@
1
- pypeline/__init__.py,sha256=54sMzEOXJ7W27qoPLWPsPwh5bgkt77XwgZJbxjD5qB8,23
1
+ pypeline/__init__.py,sha256=RI6iseDSL_qMxFcIV0RKnzR3fZIvguxQK4eA_v0LVwc,23
2
2
  pypeline/__run.py,sha256=TCdaX05Qm3g8T4QYryKB25Xxf0L5Km7hFOHe1mK9vI0,350
3
3
  pypeline/bootstrap/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  pypeline/bootstrap/run.py,sha256=pi9Kyordk4-Hwz8BsLpOTNu-hJV4imPgOrjPSr9_qRA,16446
@@ -19,14 +19,14 @@ pypeline/kickstart/templates/project/steps/my_step.py,sha256=b-JEwF9EyF4G6lgvkk3
19
19
  pypeline/kickstart/templates/project/west.yaml,sha256=ZfVym7M4yzzC-Nm0vESdhqNYs6EaJuMQWGJBht_i0b4,188
20
20
  pypeline/main.py,sha256=2mC2BDB1OWIXhaijBXG6Y1vfT8_yMZ4Dj55w5u7g7-w,4158
21
21
  pypeline/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
- pypeline/pypeline.py,sha256=-mquLfFlEvESk-HORhvjRMESIzdlVAgBLPjwUDOPLqg,7452
22
+ pypeline/pypeline.py,sha256=mDKUnTuMDw8l-kSDJCHRNbn6zrxAfXhAIAqc5HyHd5M,8758
23
23
  pypeline/steps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
24
  pypeline/steps/create_venv.py,sha256=ioL59vC1GbEk_EpUFMRRkWXk8W7z7QCEV-zgcho_lSg,6292
25
25
  pypeline/steps/env_setup_script.py,sha256=u08A6pvMccFQbcnU0xruFvpU30PbDrttnbOjl1gDqog,2340
26
26
  pypeline/steps/scoop_install.py,sha256=DDXBD-5TVaT-u6Yf7A85uWoCgBVmLvj9nPGrZ8OQCz0,3853
27
27
  pypeline/steps/west_install.py,sha256=hPyr28ksdKsQ0tv0gMNytzupgk1IgjN9CpmaBdX5zps,1947
28
- pypeline_runner-1.18.1.dist-info/LICENSE,sha256=sKxdoqSmW9ezvPvt0ZGJbneyA0SBcm0GiqzTv2jN230,1066
29
- pypeline_runner-1.18.1.dist-info/METADATA,sha256=NsuwVs3Z1fw7CffO2EpdNKlOGvjjMRN3llZl1CuCO7Q,7553
30
- pypeline_runner-1.18.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
31
- pypeline_runner-1.18.1.dist-info/entry_points.txt,sha256=pe1u0uuhPI_yeQ0KjEw6jK-EvQfPcZwBSajgbAdKz1o,47
32
- pypeline_runner-1.18.1.dist-info/RECORD,,
28
+ pypeline_runner-1.19.0.dist-info/LICENSE,sha256=sKxdoqSmW9ezvPvt0ZGJbneyA0SBcm0GiqzTv2jN230,1066
29
+ pypeline_runner-1.19.0.dist-info/METADATA,sha256=xM_xPlG5nNTZXIqKWSpZAkdKM6gnIpj_UDpt7ICH1w8,7586
30
+ pypeline_runner-1.19.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
31
+ pypeline_runner-1.19.0.dist-info/entry_points.txt,sha256=pe1u0uuhPI_yeQ0KjEw6jK-EvQfPcZwBSajgbAdKz1o,47
32
+ pypeline_runner-1.19.0.dist-info/RECORD,,