Skip to content

Commit

Permalink
Merge pull request #18 from csgoh/dev-processpiper
Browse files Browse the repository at this point in the history
Dev processpiper
  • Loading branch information
csgoh authored Jul 23, 2023
2 parents 3d6d790 + c5d062e commit 1ca4fce
Show file tree
Hide file tree
Showing 32 changed files with 582 additions and 308 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,5 @@ dotted*
font_demo*
test01.png
pizza*.png
.vscode/
.vscode/
*.txt
107 changes: 45 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,68 +11,22 @@
[![Twitter Follow](https://img.shields.io/twitter/follow/CSGohNZ?style=social)](https://twitter.com/CSGohNZ)

# ProcessPiper (Business Process Diagram as Code)
A python library to generate business process diagram using code.
ProcessPiper is an open source python library to generate business process diagram using python code or [PiperFlow](https://github.com/csgoh/processpiper/wiki/Usage-Documentation#syntax) syntax.

## Why ProcessPiper?
1. Generate professional business process diagrams with Python code, eliminating the need for manual drawing and complex tools.
2. Improve teamwork by utilising source code repositories for change monitoring, collaboration, and diagram history.
3. Enhance precision by generating diagrams with code, sharing/exporting them in PNG format, and integrating them with Python tools.
<h3 align="center">
<b><a href="https://github.com/csgoh/processpiper/wiki/installation">Installation</a></b>
<b><a href="https://github.com/csgoh/processpiper/wiki/Usage-Documentation">Usage Guide</a></b>
<b><a href="https://github.com/csgoh/processpiper/wiki/Change-Logs">Changelogs</a></b>
</h3>


# Features
* Generate business process diagrams with Python code
* Alternatively business process diagram can be generated by using plain text
* 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
* Default
* GREYWOOF
* BLUEMOUNTAIN
* ORANGEPEEL
* GREENTURTLE
* Save diagram as PNG file

## Change Logs
Refer to this [Change Logs](https://github.com/csgoh/processpiper/wiki/Change-Logs) page for the latest updates.



## Installation
### Install from PyPI
```bash
pip install processpiper
```
<br>

## Frontend Application
Two frontend applications have been developed to showcase ProcessPiper capability.
* [Piperoni](https://github.com/csgoh/Piperoni) - A desktop application
* [Piperita](https://piperita.streamlit.app/) - A Streamlit web application
<br>

### Python version requirements:
* Python 3.10, 3.11

### Library Dependencies
* Pillow 9.5.0

### Supported Platforms
* Windows
* Ubuntu
* MacOS

## Documentation
Please refer to [Processpiper Wiki](https://github.com/csgoh/processpiper/wiki) for more information on how to use this library.

## Examples
### (Method 1) Generate diagram using English like PiperFlow syntax
This is a sample code to generate a business process diagram using 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](https://github.com/csgoh/processpiper/wiki/Usage-Documentation#syntax) syntax.
```python
from processpiper.text2diagram import render

Expand Down Expand Up @@ -103,7 +57,7 @@ render(input_syntax, "my_process_map.png")

```

### (Method 2) Generate diagram using Python code
### 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.

```python
Expand Down Expand Up @@ -144,16 +98,45 @@ with ProcessMap(
The generated diagram is as follows:
![Process Map](https://github.com/csgoh/processpiper/blob/main/images/test/test_auto_case1.png)

# 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
* Default
* GREYWOOF
* BLUEMOUNTAIN
* ORANGEPEEL
* GREENTURTLE
* Save diagram as PNG file


## Frontend Application
Two frontend applications have been developed to showcase ProcessPiper capability.
* [Piperoni](https://github.com/csgoh/Piperoni) - A desktop application
* [Piperita](https://piperita.streamlit.app/) - A Streamlit web application

## Development Status
Initial first release would only cover the following basic business process elements. Other element types will be introduced in subsequence releases.
## Support and Community

* Event: Start, End, Timer, Intermediate, Message, Signal, Conditional, Link
* Activity: Task, Subprocess
* Gateway: Inclusive, Exclusive, Parallel, Event
If you have any problem, I will try my best to resolve it.<br>

* 📄 Find a solution in our [Wiki](https://github.com/csgoh/processpiper/wiki)
* ⚠️ Open an issue right here on [GitHub](https://github.com/csgoh/processpiper/issues)<br>

Any ideas or suggestions, please send it to me via [GitHub Discussions](https://github.com/csgoh/processmapper/discussions).

## How to Contribute

If you'd like to contribute, start by reading our [Contribution Guide](https://github.com/csgoh/processpiper/tree/main/contributions/CONTRIBUTING.md).<br>

Lets build great software together.



22 changes: 22 additions & 0 deletions contributions/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Contributing to ProcessPiper

Thank you for your interest in ProcessPiper and for taking the time to contribute to this project. 🙌
ProcessPiper is a project by developers for developers and there are a lot of ways you can contribute.
If you don't know where to start contributing, drop me a DM on [Twitter](https://twitter.com/CSGohNZ).


## How can I contribute?

There are many ways in which you can contribute to ProcessPiper.

#### 🐛 Report a bug
Report all issues through GitHub Issues. To help resolve your issue as quickly as possible, please provide the following information:
* Your Operating System
* Your code to reproduce the error

#### 🛠 File a feature request
We welcome all feature requests, whether it's to add new functionality to an existing extension or to offer an idea for a brand new extension. File your feature request through ideas under [GitHub Discussion](https://github.com/csgoh/processpiper/discussions/categories/ideas) page.


#### ⚙️ Close a Bug / Feature issue
We welcome contributions that help make ProcessPiper bug free & improve the experience of our users. You can also find [open issues](https://github.com/csgoh/processpiper/issues). Check out our [Code Contribution Guide](contributions/CodeContributionsGuidelines.md) to begin.
23 changes: 23 additions & 0 deletions contributions/CodeContributionsGuidelines.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Contributing code

### Getting Started

All submissions, including submissions by project members, require review. We use GitHub pull requests for this purpose. Consult GitHub Help for more information on using pull requests.
Before raising a pull request, ensure you have raised a corresponding issue and discussed a possible solution with a maintainer. This gives your pull request the highest chance of getting merged quickly.

### Good First Issues

Looking for issues to contribute? Check out the [GitHub Issue](https://github.com/csgoh/processpiper/issues) page.

### 🍴 Git Workflow

We use [Github Flow](https://guides.github.com/introduction/flow/index.html), so all code changes happen through pull requests.

1. Fork the repo and create a new branch from the `main` branch.
2. Branches are named as `fix/fix-name` or `feature/feature-name`
3. Please add tests for your changes.
4. Once you are confident in your code changes, create a pull request in your fork to the release branch in the appsmithorg/appsmith base repository.
5. If you've changed any functions, please call this out in the pull request and ensure backward compatibility.
6. Link the issue of the base repository in your Pull request description. [Guide](https://docs.github.com/en/free-pro-team@latest/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue)
7. When you raise a pull request, we automatically run tests on our CI. Please ensure that all the tests are passing for your code change. We will not be able to accept your change if the test suite doesn't pass.

Binary file added images/test/piper_20230722_211046.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/test/test_auto_case1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/test/test_case10-BLUEMOUNTAIN.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/test/test_case10-DEFAULT.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/test/test_case10-GREENTURTLE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/test/test_case10-GREYWOOF.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/test/test_case10-ORANGEPEEL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/test/test_case11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/test/test_case17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/test/test_case2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/test/test_case3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/test/test_case4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/test/test_case5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/test/test_case8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/test/test_diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/test/test_diagramX.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/test/test_sample02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ classifiers = [
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
dependencies = ['Pillow>=9.5.0']
dependencies = ['Pillow>=9.5.0', 'rich>=13.4.2']

[project.urls]
"Homepage" = "https://github.com/csgoh/processpiper"
Expand Down
7 changes: 5 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
Pillow==9.5.0
pytest==7.3.2
Pillow>=9.5.0
pytest>=7.3.2
rich>=13.4.2
build>=0.10.0
twine>=4.0.2
21 changes: 17 additions & 4 deletions src/processpiper/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import logging
from rich.console import Console
from rich.panel import Panel


class Helper:
Expand All @@ -28,13 +30,18 @@ class Helper:
show_x_position = False
show_y_position = False
show_draw_position = False
show_draw_connection = False
show_draw = False
show_draw_connection = False
show_general = False

@staticmethod
def printc(
message: str, color: str = "30", end: str = "\n", show_level: str = "general"
message: str,
color: str = "30",
reverse: bool = False,
end: str = "\n",
rich_type: str = "text",
show_level: str = "general",
):
"""Print text in color"""

Expand All @@ -50,7 +57,12 @@ def printc(
or (show_level == "draw" and Helper.show_draw)
or (show_level == "general" and Helper.show_general)
):
print(f"\033[1;{color}m{message}\033[0m", end=end)
console = Console()
if rich_type == "text":
style_attribute = "reverse" if reverse else ""
console.print(message, end=end, style=style_attribute)
elif rich_type == "panel":
console.print(Panel(message), style="blue")

@staticmethod
def print_info(message: str, color: str = "30", end: str = "\n"):
Expand All @@ -59,7 +71,8 @@ def print_info(message: str, color: str = "30", end: str = "\n"):
root_logger = logging.getLogger()

if root_logger.getEffectiveLevel() == logging.INFO:
print(f"\033[1;{color}m{message}\033[0m", end=end)
console = Console()
console.print(f"\033[1;{color}m{message}\033[0m", end=end)

@staticmethod
def debug_log(message: str):
Expand Down
41 changes: 24 additions & 17 deletions src/processpiper/lane.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,6 @@ def add_element(
fill_colour: str = "",
text_alignment: str = "",
) -> Shape:
"""Add an element to the lane"""
# if font == "":
# font = self.painter.element_font
# if font_size == 0:
# font_size = self.painter.element_font_size
# if font_colour == "":
# font_colour = self.painter.element_font_colour
# if fill_colour == "":
# fill_colour = self.painter.element_fill_colour
# if text_alignment == "":
# text_alignment = self.painter.element_text_alignment

font = font or self.painter.element_font
font_size = font_size or self.painter.element_font_size
font_colour = font_colour or self.painter.element_font_colour
Expand Down Expand Up @@ -209,22 +197,41 @@ def draw_shape(self) -> None:
if self.shapes:
for shape in self.shapes:
Helper.printc(
f" Drawing shape: {shape.name}, x={shape.x}, y={shape.y}, w={shape.width}, h={shape.height}",
f" Drawing shape: [bold][red]\[{shape.name}][/red][/bold], x={shape.x}, y={shape.y}, w={shape.width}, h={shape.height}",
rich_type="text",
show_level="draw",
)

shape.draw(self.painter)

# def _find_start_shape(self) -> Shape:
# """Find the start shape in the process map"""
# if self.shapes:
# for pool in self._pools:
# for lane in pool.lanes:
# for shape in lane.shapes:
# ### If the shape has no connection_from, it is the start shape
# Helper.printc(
# f"{shape.name} - {len(shape.connection_from)}",
# show_level="layout_grid",
# )
# if len(shape.connection_from) == 0:
# return shape
# return None

def draw_connection(self, all_shapes: list) -> None:
"""Draw the connections in the lane"""

Helper.printc(
f"Lane: {self.name}", show_level="draw_connection", rich_type="panel"
)
if self.shapes:
for shape in self.shapes:
shape.draw_connection(self.painter, all_shapes)
shape = self.shapes[0]
shape.draw_connection(self.painter, all_shapes)

def set_draw_position(self, x: int, y: int, layout_grid: Grid) -> None:
"""Set the draw position of the lane"""

# self.painter = painter

### Determine the number of rows for the lane
lane_row_count = layout_grid.get_lane_row_count(self.id)

Expand Down
Loading

0 comments on commit 1ca4fce

Please sign in to comment.