pypeline-runner 1.1.0__py3-none-any.whl → 1.3.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.1.0"
1
+ __version__ = "1.3.0"
@@ -5,12 +5,15 @@ from typing import (
5
5
  Any,
6
6
  Dict,
7
7
  Generic,
8
+ Iterator,
8
9
  List,
9
10
  Optional,
10
11
  OrderedDict,
12
+ Tuple,
11
13
  Type,
12
14
  TypeAlias,
13
15
  TypeVar,
16
+ Union,
14
17
  )
15
18
 
16
19
  from mashumaro import DataClassDictMixin
@@ -39,7 +42,27 @@ class PipelineStepConfig(DataClassDictMixin):
39
42
  config: Optional[Dict[str, Any]] = None
40
43
 
41
44
 
42
- PipelineConfig: TypeAlias = OrderedDict[str, List[PipelineStepConfig]]
45
+ PipelineConfig: TypeAlias = Union[List[PipelineStepConfig], OrderedDict[str, List[PipelineStepConfig]]]
46
+
47
+
48
+ class PipelineConfigIterator:
49
+ """
50
+ Iterates over the pipeline configuration, yielding group name and steps configuration.
51
+
52
+ This class abstracts the iteration logic for PipelineConfig, which can be:
53
+ - A list of steps (group name is None)
54
+ - An OrderedDict with group names as keys and lists of steps as values.
55
+
56
+ The iterator yields tuples of (group_name, steps).
57
+ """
58
+
59
+ def __init__(self, pipeline_config: PipelineConfig) -> None:
60
+ self._items = pipeline_config.items() if isinstance(pipeline_config, OrderedDict) else [(None, pipeline_config)]
61
+
62
+ def __iter__(self) -> Iterator[Tuple[Optional[str], List[PipelineStepConfig]]]:
63
+ """Return an iterator."""
64
+ yield from self._items
65
+
43
66
 
44
67
  TExecutionContext = TypeVar("TExecutionContext", bound=ExecutionContext)
45
68
 
@@ -47,7 +70,7 @@ TExecutionContext = TypeVar("TExecutionContext", bound=ExecutionContext)
47
70
  class PipelineStep(Generic[TExecutionContext], Runnable):
48
71
  """One can create subclasses of PipelineStep that specify the type of ExecutionContext they require."""
49
72
 
50
- def __init__(self, execution_context: TExecutionContext, group_name: str, config: Optional[Dict[str, Any]] = None) -> None:
73
+ def __init__(self, execution_context: TExecutionContext, group_name: Optional[str], config: Optional[Dict[str, Any]] = None) -> None:
51
74
  super().__init__(self.get_needs_dependency_management())
52
75
  self.execution_context = execution_context
53
76
  self.group_name = group_name
@@ -56,7 +79,10 @@ class PipelineStep(Generic[TExecutionContext], Runnable):
56
79
 
57
80
  @property
58
81
  def output_dir(self) -> Path:
59
- return self.execution_context.create_artifacts_locator().build_dir.joinpath(self.group_name)
82
+ output_dir = self.execution_context.create_artifacts_locator().build_dir
83
+ if self.group_name:
84
+ output_dir = output_dir / self.group_name
85
+ return output_dir
60
86
 
61
87
  @abstractmethod
62
88
  def update_execution_context(self) -> None:
@@ -73,7 +99,7 @@ class PipelineStep(Generic[TExecutionContext], Runnable):
73
99
 
74
100
 
75
101
  class PipelineStepReference(Generic[TExecutionContext]):
76
- def __init__(self, group_name: str, _class: Type[PipelineStep[TExecutionContext]], config: Optional[Dict[str, Any]] = None) -> None:
102
+ def __init__(self, group_name: Optional[str], _class: Type[PipelineStep[TExecutionContext]], config: Optional[Dict[str, Any]] = None) -> None:
77
103
  self.group_name = group_name
78
104
  self._class = _class
79
105
  self.config = config
@@ -5,7 +5,7 @@
5
5
 
6
6
  function Invoke-Bootstrap {
7
7
  # Download bootstrap scripts from external repository
8
- Invoke-RestMethod https://raw.githubusercontent.com/avengineers/bootstrap-installer/v1.15.0/install.ps1 | Invoke-Expression
8
+ Invoke-RestMethod https://raw.githubusercontent.com/avengineers/bootstrap-installer/v1.15.1/install.ps1 | Invoke-Expression
9
9
  # Execute bootstrap script
10
10
  . .\.bootstrap\bootstrap.ps1
11
11
  }
@@ -1 +1,7 @@
1
- .\.venv\Scripts\pypeline.exe $args
1
+ Push-Location $PSScriptRoot
2
+ try {
3
+ .\.venv\Scripts\pypeline.exe $args
4
+ }
5
+ finally {
6
+ Pop-Location
7
+ }
@@ -1,12 +1,9 @@
1
1
  pipeline:
2
- venv:
3
- - step: CreateVEnv
4
- module: pypeline.steps.create_venv
5
- config:
6
- bootstrap_script: .bootstrap/bootstrap.py
7
- install:
8
- - step: ScoopInstall
9
- module: pypeline.steps.scoop_install
10
- custom:
11
- - step: MyStep
12
- file: steps/my_step.py
2
+ - step: CreateVEnv
3
+ module: pypeline.steps.create_venv
4
+ config:
5
+ bootstrap_script: .bootstrap/bootstrap.py
6
+ - step: ScoopInstall
7
+ module: pypeline.steps.scoop_install
8
+ - step: MyStep
9
+ file: steps/my_step.py
pypeline/main.py CHANGED
@@ -8,6 +8,7 @@ from py_app_dev.core.logging import logger, setup_logger, time_it
8
8
 
9
9
  from pypeline import __version__
10
10
  from pypeline.domain.execution_context import ExecutionContext
11
+ from pypeline.domain.pipeline import PipelineConfigIterator
11
12
  from pypeline.domain.project_slurper import ProjectSlurper
12
13
  from pypeline.kickstart.create import KickstartProject
13
14
  from pypeline.pypeline import PipelineScheduler, PipelineStepsExecutor
@@ -69,8 +70,9 @@ def run(
69
70
  project_slurper = ProjectSlurper(project_dir)
70
71
  if print:
71
72
  logger.info("Pipeline steps:")
72
- for group, step_configs in project_slurper.pipeline.items():
73
- logger.info(f" Group: {group}")
73
+ for group, step_configs in PipelineConfigIterator(project_slurper.pipeline):
74
+ if group:
75
+ logger.info(f" Group: {group}")
74
76
  for step_config in step_configs:
75
77
  logger.info(f" {step_config.step}")
76
78
  return
pypeline/pypeline.py CHANGED
@@ -17,7 +17,7 @@ from py_app_dev.core.runnable import Executor
17
17
 
18
18
  from .domain.artifacts import ProjectArtifactsLocator
19
19
  from .domain.execution_context import ExecutionContext
20
- from .domain.pipeline import PipelineConfig, PipelineStep, PipelineStepConfig, PipelineStepReference, TExecutionContext
20
+ from .domain.pipeline import PipelineConfig, PipelineConfigIterator, PipelineStep, PipelineStepConfig, PipelineStepReference, TExecutionContext
21
21
 
22
22
 
23
23
  class PipelineLoader(Generic[TExecutionContext]):
@@ -35,13 +35,13 @@ class PipelineLoader(Generic[TExecutionContext]):
35
35
 
36
36
  def load_steps_references(self) -> List[PipelineStepReference[TExecutionContext]]:
37
37
  result = []
38
- for group_name, steps_config in self.pipeline_config.items():
38
+ for group_name, steps_config in PipelineConfigIterator(self.pipeline_config):
39
39
  result.extend(self._load_steps(group_name, steps_config, self.project_root_dir))
40
40
  return result
41
41
 
42
42
  @staticmethod
43
43
  def _load_steps(
44
- group_name: str,
44
+ group_name: Optional[str],
45
45
  steps_config: List[PipelineStepConfig],
46
46
  project_root_dir: Path,
47
47
  ) -> List[PipelineStepReference[TExecutionContext]]:
@@ -19,7 +19,6 @@ class CreateVEnv(PipelineStep[ExecutionContext]):
19
19
  def __init__(self, execution_context: ExecutionContext, group_name: str, config: Optional[Dict[str, Any]] = None) -> None:
20
20
  super().__init__(execution_context, group_name, config)
21
21
  self.logger = logger.bind()
22
- self.logger = logger.bind()
23
22
 
24
23
  @property
25
24
  def install_dirs(self) -> List[Path]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pypeline-runner
3
- Version: 1.1.0
3
+ Version: 1.3.0
4
4
  Summary: Configure and execute pipelines with Python (similar to GitHub workflows or Jenkins pipelines).
5
5
  Home-page: https://github.com/cuinixam/pypeline
6
6
  License: MIT
@@ -18,7 +18,7 @@ Classifier: Programming Language :: Python :: 3.11
18
18
  Classifier: Programming Language :: Python :: 3.12
19
19
  Classifier: Programming Language :: Python :: 3.13
20
20
  Classifier: Topic :: Software Development :: Libraries
21
- Requires-Dist: py-app-dev (>=2.2,<3.0)
21
+ Requires-Dist: py-app-dev (>=2.3.3,<3.0.0)
22
22
  Requires-Dist: pyyaml (>=6.0,<7.0)
23
23
  Requires-Dist: typer[all] (>=0.12,<0.13)
24
24
  Project-URL: Bug Tracker, https://github.com/cuinixam/pypeline/issues
@@ -1,30 +1,30 @@
1
- pypeline/__init__.py,sha256=LGVQyDsWifdACo7qztwb8RWWHds1E7uQ-ZqD8SAjyw4,22
1
+ pypeline/__init__.py,sha256=F5mW07pSyGrqDNY2Ehr-UpDzpBtN-FsYU0QGZWf6PJE,22
2
2
  pypeline/__run.py,sha256=TCdaX05Qm3g8T4QYryKB25Xxf0L5Km7hFOHe1mK9vI0,350
3
3
  pypeline/domain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  pypeline/domain/artifacts.py,sha256=qXshnk9umi0AVGV4m5iEiy_MQ5Ad2LDZwI8OULU-qMk,1355
5
5
  pypeline/domain/config.py,sha256=AlavAaz5hSxa6yaKYnj-x71ClhOtA41yv5Qf2JIE47k,1650
6
6
  pypeline/domain/execution_context.py,sha256=0zc3OgXeIMDpgWWYMaDGub7fY5urLLR79yuCaXVxoTQ,1101
7
- pypeline/domain/pipeline.py,sha256=PlNrRXBaLw3Eu62ytyH3sgbTmt5pKXC4l24GXXhCNII,2925
7
+ pypeline/domain/pipeline.py,sha256=1xhIl1zFr6r8mGeQWn04P2_N5smTu-eyY_6irNZNpWk,3860
8
8
  pypeline/domain/project_slurper.py,sha256=YCho7V1BHjFmC_foxHFaWX8c_VbMJ16XEB4CQBlMrhc,894
9
9
  pypeline/kickstart/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  pypeline/kickstart/create.py,sha256=dWqSdDsqNh7_AnNEsJzsmheR2-xyO6rpUwF-7AwzCYY,2188
11
11
  pypeline/kickstart/templates/project/.gitignore,sha256=y8GJoVvRPez1LBokf1NaDOt2X1XtGwKFMF5yjA8AVS0,24
12
- pypeline/kickstart/templates/project/bootstrap.ps1,sha256=QaK0UmU7DSJdekiSUM9CAX87y0BbcrizrJ0T43Fdom8,766
12
+ pypeline/kickstart/templates/project/bootstrap.ps1,sha256=eR8cyIJwDVt-bA2H3GWmxUew3igJaKYKv4rtg7MqhsY,766
13
13
  pypeline/kickstart/templates/project/poetry.toml,sha256=q5gF2MWexTFIahJ6StUa3y62HDUrRW7t8kGFszZhgp4,34
14
- pypeline/kickstart/templates/project/pypeline.ps1,sha256=tkiXrsMsNM43WJdmWJRhis3TIjwAVUjO2xAP9sT31Fo,36
15
- pypeline/kickstart/templates/project/pypeline.yaml,sha256=RViO09RQsd-jHIwqY80EJFCSipM3pEK-laKjY0nZIYc,283
14
+ pypeline/kickstart/templates/project/pypeline.ps1,sha256=s7CDfnagg8BIO42fpCfLF1l8uK7PNzui-7t9_suokzc,111
15
+ pypeline/kickstart/templates/project/pypeline.yaml,sha256=EV5Tnu3H33gMT3Ov0t14-jKwnv9naSMb0wEDzaG0H2Q,238
16
16
  pypeline/kickstart/templates/project/pyproject.toml,sha256=yc6RCo-bUo1PXF91XfM-dButgfxU16Uud34NidgJ0zQ,225
17
17
  pypeline/kickstart/templates/project/scoopfile.json,sha256=DcfZ8jYf9hmPHM-AWwnPKQJCzRG3fCuYtMeoY01nkag,219
18
18
  pypeline/kickstart/templates/project/steps/my_step.py,sha256=_zx01qAVuwn6IMPBUBwKY-IBjS9Gs2m-d51L9sayGug,733
19
- pypeline/main.py,sha256=20gfpGlYWN3wlAifTkES4VY3lXDQjwKBYd8KkSr33EE,3355
19
+ pypeline/main.py,sha256=GtuOgB9OeNFgbWLHZux80fppYQVwMYNFZoZhDIlJW9c,3457
20
20
  pypeline/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
- pypeline/pypeline.py,sha256=GUEIPtK6TU9yt-izuIqbRUjbxM3JASoj8nNJ63mN388,8756
21
+ pypeline/pypeline.py,sha256=GC4AS8rGKdJJVSNXfxV3-0F94-Rgt-Soth6rl_gZuW8,8806
22
22
  pypeline/steps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
- pypeline/steps/create_venv.py,sha256=hXRklcYR38uUPWRDyhUjWu8WEPIaQPSQggM_ocwG7k8,1971
23
+ pypeline/steps/create_venv.py,sha256=vTPSA0gGGzq_QhI1jAgsGchS2s8_ZpEtnWcb0uL8BHE,1934
24
24
  pypeline/steps/scoop_install.py,sha256=_YdoCMXLON0eIwck8PJOcNhayx_ka1krBAidw_oRuFE,3373
25
25
  pypeline/steps/west_install.py,sha256=hPyr28ksdKsQ0tv0gMNytzupgk1IgjN9CpmaBdX5zps,1947
26
- pypeline_runner-1.1.0.dist-info/LICENSE,sha256=sKxdoqSmW9ezvPvt0ZGJbneyA0SBcm0GiqzTv2jN230,1066
27
- pypeline_runner-1.1.0.dist-info/METADATA,sha256=vjFtXYVItC-mrgTRoM87wGRadb-5e7Z5Trj7bbF-M7A,7207
28
- pypeline_runner-1.1.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
29
- pypeline_runner-1.1.0.dist-info/entry_points.txt,sha256=pe1u0uuhPI_yeQ0KjEw6jK-EvQfPcZwBSajgbAdKz1o,47
30
- pypeline_runner-1.1.0.dist-info/RECORD,,
26
+ pypeline_runner-1.3.0.dist-info/LICENSE,sha256=sKxdoqSmW9ezvPvt0ZGJbneyA0SBcm0GiqzTv2jN230,1066
27
+ pypeline_runner-1.3.0.dist-info/METADATA,sha256=vFgk-TdAPHnMIP4gabBdE_nevAscPi4Vvrl_H6xVhpM,7211
28
+ pypeline_runner-1.3.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
29
+ pypeline_runner-1.3.0.dist-info/entry_points.txt,sha256=pe1u0uuhPI_yeQ0KjEw6jK-EvQfPcZwBSajgbAdKz1o,47
30
+ pypeline_runner-1.3.0.dist-info/RECORD,,