Skip to main content

Python Application

python-workflow

A small framework to do workflows with threadable tasks

Documentation : https://anthonykgross.fr/python-workflow/

Install

From PyPI

pip install python-workflow

From source

rm build/ python_workflow.egg-info dist -Rf
python3 setup.py bdist_wheel
pip3 install -I dist/python_workflow-*-py3-none-any.whl

How it works

sequenceDiagram
    Workflow->>+Step: Step1 is starting ...
    Step->>+Task: Task1 is starting ...
    Step->>+Task: Task2 is starting ...
    Task->>-Step: Task2 is done
    Task->>-Step: Task1 is done
    Step->>+Task: Task3 is starting ...
    Task->>-Step: Task3 is done
    Step->>-Workflow: Step1 is done
    Note right of Step: Tasks are running in concurrency (thread)
    Note right of Workflow: Step is done when all its tasks are done

Each Step is running when the previous one is done. A Step is done when all its tasks are completed or raise exceptions. Workflow will be stopped when a Step crashes or complete them.

kwargs default description
nb_thread 4 The number of tasks to execute simultaneously.
e.g. : 10 tasks on 2 threads = 5 loops
raise_error True If one of tasks crashes, the whole Step is considered as failed.

How to use

from python_workflow import Task, Step, Workflow

class MyTask1(Task):
    def __init__(self):
        super().__init__('my_task_1')

    def run(self):
        return 'It works 1!'
   
class MyTask2(Task):
    def __init__(self):
        super().__init__('my_task_2')

    def run(self):
        return 'It works 2!'

class MyTask3(Task):
    def __init__(self):
        super().__init__('my_task_3')

    def run(self):
        return 'It works 3!'
    
step1 = Step(
    'my_step_1', tasks=[
        MyTask1(),
        MyTask2(),
        MyTask3(),
    ],
    nb_thread=2
)

workflow = Workflow('my_workflow', steps=[step1])
workflow.start()

workflow.duration
# 3
workflow.steps[0].duration
# 3
workflow.steps[0].tasks[0].duration
# 2
workflow.steps[0].tasks[1].duration
# 1
workflow.steps[0].tasks[2].duration
# 1

Contributors

Anthony K GROSS

Copyright and license

Code and documentation copyright 2024. Code released under the MIT license.

Metadata

Release files for python-workflow 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for python-workflow 1.0.3
File Interpreter ABI Platform Actions
python_workflow-1.0.3-py3-none-any.whl Python 3 none any Details for python_workflow-1.0.3-py3-none-any.whl

Release files / python_workflow-1.0.3-py3-none-any.whl

Download URL python_workflow-1.0.3-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7bdaada65912faa1e8ddace994d130370f495dbe0ef895fa55e6095ac367fa81
BLAKE2b-256 checksum
How to use checksums
d508db4a43ed2fb097f5f0e43d93c5f8a9e9e599284523b95f6684ce473d9fa5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.8

Security for python-workflow 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page