Skip to main content

Junban – Simple Sequential Python Workflows

Project description

Junban (順番) – Simple Sequential Python Workflows

Junban (english: order) is a lightweight library for defining and executing sequential (scientific) workflows in Python.

Installation

Junban is available via pypi:

pip install junban

Quick Example

Here is a simple example showing how to define a context and two steps. It showcases how context is passed between steps and how entry/exit assumptions (verification) are handled.

from dataclasses import dataclass
from junban.pipeline import Pipeline
from junban.pipeline_step import PipelineStep
from junban.pipeline_context import PipelineContext


# 1. Define your context by inheriting from PipelineContext
@dataclass
class MyContext(PipelineContext):
    value: int = 0
    is_processed: bool = False


# 2. Create pipeline steps by inheriting from PipelineStep
class IncrementStep(PipelineStep[MyContext]):
    def _check_entry_assumptions(self, context: MyContext) -> bool:
        # Verification before step execution
        return context.value == 0

    def _execute(self, context: MyContext) -> MyContext:
        # Core logic of the step
        context.value += 1
        return context

    def _check_exit_assumptions(self, context: MyContext) -> bool:
        # Verification after step execution
        return context.value == 1

    def get_start_message(self) -> str:
        return "Incrementing value..."

    def get_end_message(self) -> str:
        return "Value incremented."


class ProcessStep(PipelineStep[MyContext]):
    def _check_entry_assumptions(self, context: MyContext) -> bool:
        return context.value > 0

    def _execute(self, context: MyContext) -> MyContext:
        context.is_processed = True
        return context

    def _check_exit_assumptions(self, context: MyContext) -> bool:
        return context.is_processed is True

    def get_start_message(self) -> str:
        return "Processing..."

    def get_end_message(self) -> str:
        return "Processed."


# 3. Initialize and execute the pipeline
if __name__ == "__main__":
    context = MyContext()
    pipeline = Pipeline(
        steps=[IncrementStep(), ProcessStep()],
        name="ExamplePipeline"
    )

    final_context = pipeline.execute(context)
    print(f"Final value: {final_context.value}, Processed: {final_context.is_processed}")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

junban-1.0.2.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

junban-1.0.2-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file junban-1.0.2.tar.gz.

File metadata

  • Download URL: junban-1.0.2.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for junban-1.0.2.tar.gz
Algorithm Hash digest
SHA256 e9aec3f5942ac87950a191369c761f6c569d7f8fb1f65a5762d386aaab55cab0
MD5 26346cce8250697bcbb5010258a0c744
BLAKE2b-256 d4681807384a5907a2c0772d8c9de063af158987541d61b846fca7c23607d198

See more details on using hashes here.

File details

Details for the file junban-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: junban-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for junban-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fc5ea66b78a7afe2072a0bf574cdb7e54dfda21f4c3a09038629885dd1d21c66
MD5 2500017796c82ab1e8f5ec1c21f44532
BLAKE2b-256 8a6abfc6ce239a0fc57ecb499d0a78671e19d3bd7a762c59fa350e1c4e7a91fb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page