Skip to main content

pybpmn

Introduction

BPMN is a notation to describe a business process. The implementation and execution of the business process can be done with various technologies. As technologies evolve, the implementation becomes more easier to adopt and maintain. This python module implements some basics BPMN features for cloud to keep the things as simple as possible.

Design approach

  • The bpmn process is backed by a python handler class to realize the desired functionality.
  • Generic on_enter_task and on_exit_task callbacks are available
  • task specific on_enter_<task_name> , on_exit_<task_name> and on_<task_name> could be implemented to get callbacks from the module

Sample code is as shown below

class Handler():
    def on_enter_task(self,**kargs):
        logger.info("Entering task")
    
    def on_exit_task(self,**kargs):
        logger.info("Exiting task")

    def on_enter_task_2(self,**kargs):
        logger.info("Entering task task_2")

    def on_task_2(self,**kargs):
        context = kargs.get("context")
        payload = kargs.get("payload")
        payload["user"] = True
        task_context = kargs.get("task")
        task_context.update({
            "name1" : "value1"
        })
        logger.info("Process task task_2")

    def on_exit_task_2(self,**kargs):
        logger.info("Exiting task task_2")

    def on_enter_task_3(self,**kargs):
        logger.info("Entering task task_3")

    def on_task_3(self,**kargs):
        logger.info("Process task task_3")

    def on_exit_task_3(self,**kargs):
        logger.info("Exiting task task_3")

    def on_enter_task_4(self,**kargs):
        logger.info("Entering task task_4")

    def on_task_4(self,**kargs):
        time.sleep(3)
        logger.info("Process task task_4")

    def on_exit_task_4(self,**kargs):
        logger.info("Exiting task task_4")

    def on_enter_task_5(self,**kargs):
        logger.info("Entering task task_5")

    def on_task_5(self,**kargs):
        time.sleep(5)
        context = kargs.get("context")
        context["user"] = True
        task_context = kargs.get("task")
        task_context.update({
            "name1" : "value1"
        })
        logger.info("Process task task_5")

    def on_exit_task_5(self,**kargs):
        logger.info("Exiting task task_5")

    def on_enter_task_6(self,**kargs):
        logger.info("Entering task task_6")

    def on_exit_task_6(self,**kargs):
        logger.info("Exiting task task_6")


def test_process():

    instance = BpmnProcess()
    instance.start_process(open("tests/data/test_bpmn.xml","r").read(),Handler())
    instance.get_activity_by_name("task_3").complete({"datatoadd":"Valuetoadd"})
    instance.get_activity_by_name("task_5").complete({"datatoadd1":"Valuetoadd2"})

Supported features

Events

The below list of events are currently supported.

  • start
  • end

Tasks

Service Task

These are automated tasks which are pure functions which does desired functionality.

User Task

These are user tasks, the main difference between user and service tasks is, user tasks are required to be completed explicity to move the token in the process. Tasks can be completed by using the code as shown below

instance.get_activity_by_name("task_3").complete({"datatoadd":"Valuetoadd"})

Gateways

Exclusive gateway

Exclusive gateways could be diverging or converging. For diverging gateway, only one path should evaluate to true or first path that gets evaluated to true, will be the path the bpmn process will take. Path's with no conditional expression ( python ) is considered to be 'True'

For converging gateways, atleast one incoming pathways will move the token up the process.

Inclusive gateway

Inclusive gateways again could be diverging or converging. These gateways by definition, will allow more than one pathways to be taken during process execution. All paths whose conditional expression evaluates to true OR doesnt have an expression will be chosen for execution. All paths will be executed in parallel until a blocking task is encountered.

For coverging gateways, the naming convention should be conv_<diverging_pair_name>. The inclusive gateway will await for as many as diverged paths to proceed execution of process.

Parallel gateway

Parallel gateways will execute all diverging paths, and awaits every converging path in the process.

Release files for py-bpmn 0.4.0

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

Source distribution (sdist)

Source distribution for py-bpmn 0.4.0
File Size Uploaded
py_bpmn-0.4.0.tar.gz 10.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-bpmn 0.4.0
File Interpreter ABI Platform
py_bpmn-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 26.6 kB

Release files / py_bpmn-0.4.0.tar.gz

Download URL py_bpmn-0.4.0.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
27e7fc2c92bb6cad731a4e41b0de20354afd37849ce50ccd551d82637d0678c8
BLAKE2b-256 checksum
How to use checksums
323bbd01861d7dae2d99296d093344b75d6f435ab5114e844e654bfecbda8794
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Release files / py_bpmn-0.4.0-py3-none-any.whl

Download URL py_bpmn-0.4.0-py3-none-any.whl
Size 16.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4c7343a38ab69b787ca1f6ed498d6af7c853d67e7cd812a9861f4e83fc65add3
BLAKE2b-256 checksum
How to use checksums
436fb2f3db6ad03660361fb4ccc7b3afff3a9779a2bc0325790838c58299bf0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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