Code Monkey home page Code Monkey logo

processpiper's Introduction

release Wheel Downloads Platforms license CodeFactor code size python version stars CI Twitter Follow

ProcessPiper (Business Process Diagram as Code)

ProcessPiper is an open source python library to generate business process diagram using python code or PiperFlow syntax.


Method 1: Generate business process diagram using English like PiperFlow syntax

This is a sample code to generate a business process diagram using PiperFlow syntax.

from processpiper.text2diagram import render

input_syntax = """
title: Sample Test Process
colourtheme: BLUEMOUNTAIN
    lane: End User
        (start) as start
        [Enter Keyword] as enter_keyword
        (end) as end
pool: System Search
    lane: Database System
        [Login] as login
        [Search Records] as search_records
        <Result Found?> as result_found
        [Display Result] as display_result
        [Logout] as logout
    lane: Log System
        [Log Error] as log_error

start->login: User \\nAuthenticate
login->enter_keyword: Authenticated
enter_keyword->search_records: Search Criteria
search_records->result_found: Result
result_found->display_result: Yes
display_result->logout->end
result_found->log_error: No
log_error->display_result

footer: Generated by ProcessPiper
"""

render(input_syntax, "my_process_map.png")

Method 2: Generate business process diagram using Python code

This is a sample code to generate a business process diagram using Python code. The code is self-explanatory. The diagram is generated using the default colour theme.

from processpiper import ProcessMap, EventType, ActivityType, GatewayType

with ProcessMap(
    "Sample Test Process", colour_theme="BLUEMOUNTAIN") as my_process_map:
    with my_process_map.add_lane("End User") as lane1:
        start = lane1.add_element("Start", EventType.START)
        enter_keyword = lane1.add_element("Enter Keyword", ActivityType.TASK)

    with my_process_map.add_pool("System Search") as pool1:
        with pool1.add_lane("Database System") as lane2:
            login = lane2.add_element("Login", ActivityType.TASK)
            search_records = lane2.add_element("Search Records", ActivityType.TASK)
            result_found = lane2.add_element("Result Found?", GatewayType.EXCLUSIVE)
            display_result = lane2.add_element("Display Result", ActivityType.TASK)
            logout = lane2.add_element("Logout", ActivityType.TASK)
            end = lane2.add_element("End", EventType.END)

        with pool1.add_lane("Log System") as lane3:
            log_error = lane3.add_element("Log Error", ActivityType.TASK)

    start.connect(login, "User \nAuthenticates").connect(
        enter_keyword, "Authenticated"
    ).connect(search_records, "Search Criteria")
    search_records.connect(result_found, "Result").connect(display_result, "Yes")
    display_result.connect(logout).connect(end)
    result_found.connect(log_error, "No").connect(display_result)

    my_process_map.set_footer("Generated by ProcessPiper")
    my_process_map.draw()
    my_process_map.save("my_process_map.png")

The generated diagram is as follows: Process Map

Features

  • Generate business process diagrams with Python code
  • Alternatively business process diagram can be generated by using PiperFlow
  • Business process diagrams contains
    • Diagram title
    • Pool(s)
    • Lane(s)
    • Elements:
      • Event: Start, End, Timer, Intermediate, Message, Signal, Conditional and Link
      • Activity: Task, Subprocess
      • Gateway: Inclusive, Exclusive, Parallel, Event
  • Support for different colour themes (See gallery) :
    • Default
    • GREYWOOF
    • BLUEMOUNTAIN
    • ORANGEPEEL
    • GREENTURTLE
    • SUNFLOWER
    • PURPLERAIN
    • RUBYRED
    • TEALWATERS
    • SEAFOAMS
  • Diagrams can be saved to PNG or SVG formats

Frontend Application

Two frontend applications have been developed to showcase ProcessPiper capability.

Support and Community

ProcessPiper is still in the early days of development, if you have any problem, I will try my best to resolve it.

  • 📄 Find a solution in our Wiki
  • ⚠️ Open an issue right here on GitHub

Any ideas or suggestions, please send it to me via GitHub Discussions.

How to Contribute

If you'd like to contribute, start by reading our Contribution Guide.

Lets build great software together.

processpiper's People

Contributors

csgoh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

processpiper's Issues

[feat] Output in BPMN format

Hi,

I was looking through the source code to figure out if it is possible to change the output from PNG to BPMN format. However, I did not spot the part where it is converted to the PNG. This would be very nice for keeping the diagram editable.

Is this already supported functionality, or easy to implement?

Thanks

the last part of the generated diagram won't be shown is the diagram is too long

Hi there,

This library is very cool, and I'm using it for my thesis. Yet, if the generated diagram is too long, then the last part of the diagram is not shown but is displayed in grey colour.

I'm using macOS 13.4
my python version is 3.10

for example,
I used such text to render

title: debug01
colourtheme: BLUEMOUNTAIN
lane: customer
(start) as start
[brings a defective computer] as activity_9
lane: crs
[checks the defect] as activity_10
[hand out a repair cost calculation] as activity_11
as gateway_1
[are acceptable] as activity_3
[continues] as activity_4
[takes her computer] as activity_5
[consists of two activities] as activity_12
[execute two activities in an arbitrary order] as activity_13
[is] as activity_14
[check the hardware] as activity_15
[repair the hardware] as activity_16
[checks the software] as activity_17
[configure the software] as activity_18
[test the proper system functionality after each of these activities] as activity_19
as gateway_6
[execute another arbitrary repair activity] as activity_8
(end) as end

start->activity_9->activity_10->activity_11->gateway_1
gateway_1->activity_3->activity_4->activity_12
gateway_1->activity_5->activity_12
activity_12->activity_13->activity_14->activity_15->activity_16->activity_17->activity_18->activity_19->gateway_6
gateway_6->activity_8->end
gateway_6->end

and the output looks like this
text01_test 16 42 27

ModuleNotFoundError: No module named 'processpiper'

I have installed it, updated it and also checked that all the dependencies are installed, and still receive the error in the title.

I know it must not be a path problem or an installation problem of my Python bcs all other packages work.

Exporting diagram to XML

Hi! Awesome library! Thank you for the contribution. I wanted to know if you were thinking of adding an XML export / import to the library. Thank you!

Error in find_nearest_points_same_pool_diff_lanes

Hi there again,

I'm using this great library for my bachelor's thesis, which is about automatic BPMN generation using NLP. (therefore, the input is sort of messy). I majorly used the "render" function, and I got interesting error messages when the diagram became larger.

for example, the input syntax as

title: debug
width: 10000
colourtheme: BLUEMOUNTAIN
lane: any employee
(start) as start
[the process of an office supply request starts] as activity_01
[submits an office supply request] as activity_02
<register the requirement?> as gateway_1
lane: immediate supervisor
[receive the request] as activity_03
<> as gateway_1_end
lane: supervisor
[approve a change] as activity_04
[ask for a change] as activity_05
[reject the request] as activity_06
<> as gateway_2
[the process end] as activity_07
[make a change] as activity_08
[return it to the petitioner employee] as activity_09
lane: petitioner employee
[review the comments for the change request] as activity_10
[request go to the purchase department] as activity_11
[making quotations] as activity_12
[select a vendor] as activity_13
lane: purchase department
[have] as activity_14
[choose a different vendor] as activity_15
<> as gateway_2_end
[select a vendor] as activity_16
[confirm a vendor] as activity_17
[the system generate a purchase order] as activity_18
[the system send a purchase order] as activity_19
[the system wait a purchase order] as activity_20
[deliver the product] as activity_21
[the invoice received] as activity_22
<the system in any case send a notification?> as gateway_3
lane: user
[know] as activity_23
<> as gateway_3_end
[approval rejection or change in any of the cases required] as activity_24
(end) as end

start->activity_01->activity_02->gateway_1
gateway_1-"yes"->activity_03->gateway_1_end
gateway_1-"no"->gateway_1_end
gateway_1_end->activity_04->activity_05->activity_06->gateway_2
gateway_2-"reject the request"->activity_07->gateway_2_end
gateway_2-"ask the request"->activity_08->activity_09->activity_10->gateway_2_end
gateway_2-"approve the request"->activity_11->activity_12->activity_13->gateway_2_end
gateway_2-"the vendor is not valid"->activity_14->activity_15->gateway_2_end
gateway_2_end->activity_16->activity_17->activity_18->activity_19->activity_20->activity_21->activity_22->gateway_3
gateway_3-"yes"->activity_23->gateway_3_end
gateway_3-"no"->gateway_3_end
gateway_3_end->activity_24->end

will lead to an error message as

/usr/local/bin/python3.10 /Users/shuaiwei_yu/Desktop/bachelor-thesis/project/BPMNrenderer.py
Traceback (most recent call last):
File "/Users/shuaiwei_yu/Desktop/bachelor-thesis/project/BPMNrenderer.py", line 60, in
render(input_syntax, "/Users/shuaiwei_yu/Desktop/output/text06_test.png")
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/processpiper/text2diagram.py", line 303, in render
exec(generated_code)
File "", line 77, in
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/processpiper/processmap.py", line 385, in draw
lane.draw_connection(all_shapes)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/processpiper/lane.py", line 221, in draw_connection
shape.draw_connection(self.painter, all_shapes)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/processpiper/shape.py", line 729, in draw_connection
) = self.find_nearest_points_same_pool_diff_lanes(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/processpiper/shape.py", line 436, in find_nearest_points_same_pool_diff_lanes
del points_source[nearest_points["source_name"]]
KeyError: 'source_name'

sometimes when you can just change the order a bit, and this will fix the problem, but with such a large diagram, this trick doesn't work. Can you give me some hints about this? Thank you very much!

OSError: cannot open resource for README example

After running pip install processpiper I tried this string example from the README:

from processpiper.text2diagram import render

input_syntax = """
title: Sample Test Process
colourtheme: BLUEMOUNTAIN
    lane: End User
        (start) as start
        [Enter Keyword] as enter_keyword
        (end) as end
pool: System Search
    lane: Database System
        [Login] as login
        [Search Records] as search_records
        <Result Found?> as result_found
        [Display Result] as display_result
        [Logout] as logout
    lane: Log System
        [Log Error] as log_error

start->login->enter_keyword->search_records->result_found->display_result->logout->end
result_found->log_error->display_result

footer: Generated by ProcessPiper
"""

render(input_syntax, "my_process_map.png")

Here is the traceback:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/galen/.local/lib/python3.10/site-packages/processpiper/text2diagram.py", line 259, in render
    exec(generated_code)
  File "<string>", line 26, in <module>
  File "/home/galen/.local/lib/python3.10/site-packages/processpiper/processmap.py", line 451, in draw
    self.set_draw_position(self.__painter)
  File "/home/galen/.local/lib/python3.10/site-packages/processpiper/processmap.py", line 320, in set_draw_position
    self._title.set_draw_position(
  File "/home/galen/.local/lib/python3.10/site-packages/processpiper/title.py", line 46, in set_draw_position
    self.width, self.height = painter.get_text_dimension(
  File "/home/galen/.local/lib/python3.10/site-packages/processpiper/painter.py", line 945, in get_text_dimension
    image_font = ImageFont.truetype(self.get_font_path(font), font_size)
  File "/home/galen/.local/lib/python3.10/site-packages/PIL/ImageFont.py", line 996, in truetype
    return freetype(font)
  File "/home/galen/.local/lib/python3.10/site-packages/PIL/ImageFont.py", line 993, in freetype
    return FreeTypeFont(font, size, index, encoding, layout_engine)
  File "/home/galen/.local/lib/python3.10/site-packages/PIL/ImageFont.py", line 248, in __init__
    self.font = core.getfont(
OSError: cannot open resource

My version of pillow is 9.5.0.

Here is my OS info:
Linux Ganymede 5.15.0-71-generic #78-Ubuntu SMP Tue Apr 18 09:00:29 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

I am running Python 3.10.6.

Diagram not printing correctly

First of all its a very great library you built! My issue is that when I save my diagram it misses content on the right. The output image is 3642x1095

Difficulties in drawing generation.

Hello CsGoh,
The Processpiper library is working only for 4 connections irrespective of the incoming and outgoing paths. In my case, I have 5 connections for the single task [B] for which it is failing to draw. Regarding this issue I made few changes in the shape.py file [shortest_source_coord.connected = False] which is drawing fine but the two tasks [E, F] are overlapping after these changes. So, kindly guide me with solution. Please refer the diagram.
Screenshot 2024-04-01 164658

Thanks

[Feat] Render SVG from text input

Hi @csgoh, thank you for your work on processpiper.
It's the best OSS Diagram-as-Code solution for BPMN that I've found so far.

I have a feature idea that I believe would add value to the project.

I noticed that the render() function in text2diagram.py relies on PIL, while the SVGPainter class uses DrawSVG.
Then, I understand that currently there is no way to create an SVG diagram from text:

From Text From Code
PNG ✔️ ✔️
SVG ✔️

Do you think the implementation of a text2SVGdiagram solution is feasible?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.