junban 1.0.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.
junban/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ from .pipeline import Pipeline
2
+ from .pipeline_step import PipelineStep
3
+ from .pipeline_context import PipelineContext
4
+
5
+ __all__ = ["PipelineStep", "PipelineContext", "Pipeline"]
junban/pipeline.py ADDED
@@ -0,0 +1,53 @@
1
+ import logging
2
+
3
+ from typing import List, Generic, Optional
4
+
5
+ from .pipeline_context import C
6
+ from .pipeline_step import PipelineStep
7
+
8
+
9
+ class Pipeline(Generic[C]):
10
+ def __init__(self, steps: List[PipelineStep[C]], name: Optional[str] = "PIPELINE",
11
+ logger: Optional[logging.Logger] = None):
12
+ """
13
+ Main junban pipeline class.
14
+
15
+ :param steps: Pipeline steps to be executed.
16
+ :param name: Name of the pipeline, defaults to "PIPELINE".
17
+ :param logger: Optional logger to log pipeline steps, defaults to None.
18
+ If no logger is provided, logs will be printed to stdout.
19
+ """
20
+ self.steps: List[PipelineStep[C]] = steps
21
+ self.name = name
22
+ self._log_info = lambda msg: self._log_info_func(msg, logger)
23
+ self._log_error = lambda msg: self._log_error_func(msg, logger)
24
+
25
+ @staticmethod
26
+ def _log_info_func(message: str, logger: logging.Logger = None):
27
+ if logger is None:
28
+ print(message)
29
+ else:
30
+ logger.info(message)
31
+
32
+ @staticmethod
33
+ def _log_error_func(message: str, logger: logging.Logger = None):
34
+ if logger is None:
35
+ print(message)
36
+ else:
37
+ logger.error(message)
38
+
39
+ def execute(self, context: C) -> C:
40
+ """ Run the pipeline steps with the given initial context."""
41
+ current_context = context
42
+ for step in self.steps:
43
+ try:
44
+ self._log_info(f"[{self.name}] {step.get_start_message()}")
45
+ current_context = step.run(current_context)
46
+ self._log_info(f"[{self.name}] {step.get_end_message()}")
47
+ except AssertionError as e:
48
+ self._log_error(f"[{self.name}] Assertion error in step {step.__class__.__name__}: {str(e)}")
49
+ raise
50
+ except Exception as e:
51
+ self._log_error(f"[{self.name}] Error in step {step.__class__.__name__}: {str(e)}")
52
+ raise
53
+ return current_context
@@ -0,0 +1,7 @@
1
+ from typing import TypeVar
2
+
3
+ class PipelineContext:
4
+ """ Large struct to hold pipeline context during execution """
5
+ pass
6
+
7
+ C = TypeVar("C", bound=PipelineContext)
@@ -0,0 +1,44 @@
1
+ from typing import Generic
2
+ from abc import ABC, abstractmethod
3
+
4
+ from .pipeline_context import C
5
+
6
+
7
+ class PipelineStep(ABC, Generic[C]):
8
+
9
+ @abstractmethod
10
+ def _check_entry_assumptions(self, context: C) -> bool:
11
+ """ You can use this method to check if the pipeline step can be executed.
12
+ Depending on your use case, you can use assert statements, raise exceptions, or return a boolean.
13
+ """
14
+ return True
15
+
16
+ @abstractmethod
17
+ def _check_exit_assumptions(self, context: C) -> bool:
18
+ """ You can use this method to check if the pipeline step executed successfully.
19
+ Depending on your use case, you can use assert statements, raise exceptions, or return a boolean.
20
+ """
21
+ return True
22
+
23
+ @abstractmethod
24
+ def get_start_message(self) -> str:
25
+ raise NotImplementedError
26
+
27
+ @abstractmethod
28
+ def get_end_message(self) -> str:
29
+ raise NotImplementedError
30
+
31
+ @abstractmethod
32
+ def _execute(self, context: C) -> C:
33
+ raise NotImplementedError
34
+
35
+ def run(self, context: C) -> C:
36
+ if not self._check_entry_assumptions(context):
37
+ assert False, "Entry assumptions not met"
38
+
39
+ context = self._execute(context)
40
+
41
+ if not self._check_exit_assumptions(context):
42
+ assert False, "Exit assumptions not met"
43
+
44
+ return context
@@ -0,0 +1,7 @@
1
+ Metadata-Version: 2.4
2
+ Name: junban
3
+ Version: 1.0.0
4
+ Summary: Junban – Simple Sequential Python Workflows
5
+ Requires-Python: >=3.11
6
+ License-File: LICENSE
7
+ Dynamic: license-file
@@ -0,0 +1,9 @@
1
+ junban/__init__.py,sha256=H1IsqTUJoaO_KZ08u2HFtBYxced9Klq79dbSxwVcROQ,176
2
+ junban/pipeline.py,sha256=xB6CeFFQ9a9rqwqlrNK1YJfaxR8RwEG-vEDo3hqOTWg,1996
3
+ junban/pipeline_context.py,sha256=z_UejwGxjEMrD_Fe5VJ2KGWgp7CcOObHy07zT1yXNf0,168
4
+ junban/pipeline_step.py,sha256=th7ui4mXaXvAMmQsL1O9Lrg9RA1DDbkSnB6fwgKIIVg,1348
5
+ junban-1.0.0.dist-info/licenses/LICENSE,sha256=zJ6mT-z4aLQS5xpN3OcdyKehHd2Xc_xFVqHErj8bexs,1067
6
+ junban-1.0.0.dist-info/METADATA,sha256=J0l5iYfC6qgGEY1-R1FAMtIxFyB3j1ytrV3RXEaSdcc,173
7
+ junban-1.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
8
+ junban-1.0.0.dist-info/top_level.txt,sha256=ZRqoSNgloxnaqyPEFEPg5ZRPc14W5yQ6uV33CZHJnSc,7
9
+ junban-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 biocentral
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ junban