### Install Processpiper from PyPI Source: https://github.com/csgoh/processpiper/wiki/Installation Use this command to install the Processpiper library from the Python Package Index. ```bash pip install processpiper ``` -------------------------------- ### Generate a Detailed Shipment Process Map Source: https://github.com/csgoh/processpiper/wiki/Usage-Documentation This example demonstrates creating a complex process map for a hardware retailer's shipment process, including multiple pools, lanes, activities, and gateways. It utilizes various ProcessPiper elements and connections to define the workflow. The map is then rendered and saved to a file. ```python with ProcessMap( "Shipment Process of a Hardware Retailer", colour_theme="BLUEMOUNTAIN" ) as my_process_map: with my_process_map.add_pool("Hardware Retailer") as pool1: with pool1.add_lane("Logistics Manager") as lane1: take_insurance = lane1.add_element("Take Insurance", ActivityType.TASK) with pool1.add_lane("Clerk") as lane2: start = lane2.add_element("Goods to ship", EventType.START) branching1 = lane2.add_element("", GatewayType.PARALLEL) decide = lane2.add_element( "Decide if normal post or special shipment", ActivityType.TASK ) branching2 = lane2.add_element( "Mode of Delivery", GatewayType.EXCLUSIVE ) check_extra_insurance = lane2.add_element( "Check if extra insurance is needed", ActivityType.TASK ) branching3 = lane2.add_element("", GatewayType.INCLUSIVE) fill_in_post = lane2.add_element( "Fill in a Post label", ActivityType.TASK ) branching4 = lane2.add_element("", GatewayType.INCLUSIVE) request_quote = lane2.add_element( "Request quotes from carriers", ActivityType.TASK ) assign_carrier = lane2.add_element( "Assign carrier & prepare paper work", ActivityType.TASK ) branching5 = lane2.add_element("", GatewayType.EXCLUSIVE) with pool1.add_lane("Warehouse Worker") as lane3: package_goods = lane3.add_element("Package goods", ActivityType.TASK) branching6 = lane3.add_element("", GatewayType.PARALLEL) add_paperwork = lane3.add_element( "Add paperwork to move package to pick area", ActivityType.TASK ) end = lane3.add_element("Goods available for pick up", EventType.END) start.connect(branching1) branching1.connect(decide).connect(branching2) branching1.connect(package_goods).connect(branching6) branching2.connect(check_extra_insurance).connect(branching3) branching2.connect(request_quote).connect(assign_carrier). branching3.connect(take_insurance).connect(branching4) branching3.connect(fill_in_post).connect(branching4) branching4.connect(branching5).connect(branching6) branching6.connect(add_paperwork).connect(end) my_process_map.set_footer("Generated by ProcessPiper") my_process_map.draw() my_process_map.save(output_file) ``` -------------------------------- ### Verify Processpiper Installation Source: https://github.com/csgoh/processpiper/wiki/Installation Execute this Python code to confirm that Processpiper has been installed correctly and to check its version. ```python from processpiper import version version.__version__ ``` -------------------------------- ### Upgrade Processpiper to Latest Version Source: https://github.com/csgoh/processpiper/wiki/Installation Run this command to upgrade an existing installation of Processpiper to the most recent release. ```bash pip install --upgrade processpiper ``` -------------------------------- ### Generate Diagram using PiperFlow Syntax Source: https://github.com/csgoh/processpiper/blob/main/README.md Use this method to generate a business process diagram by defining the process flow using an English-like syntax called PiperFlow. Ensure the 'processpiper' library is installed. ```python 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 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") ``` -------------------------------- ### Add Lane and Elements to Process Map Source: https://github.com/csgoh/processpiper/wiki/Usage-Documentation Adds a lane to the process map and then adds various elements (start event, tasks, gateway, end event) to that lane using specified types. ```python with my_process_map.add_lane("Application User") as lane1: start = lane1.add_element("Start", EventType.START) login = lane1.add_element("Login", ActivityType.TASK) search_records = lane1.add_element("Search Records", ActivityType.TASK) result_found = lane1.add_element("Result Found?", GatewayType.EXCLUSIVE) display_result = lane1.add_element("Display Result", ActivityType.TASK) logout = lane1.add_element("Logout", ActivityType.TASK) end = lane1.add_element("End", EventType.END) ``` -------------------------------- ### Create a Process Map (Default PNG) Source: https://github.com/csgoh/processpiper/wiki/Usage-Documentation Initializes a ProcessMap object. By default, diagrams are saved in PNG format. Use a 'with' statement for proper resource management. ```python with ProcessMap("Sample Process Map") as my_process_map: ``` -------------------------------- ### Render Process Diagram from Syntax Source: https://github.com/csgoh/processpiper/wiki/Usage-Documentation Renders a process diagram from a given syntax string and returns the generated code and a PIL Image object. The diagram can be saved to a file. ```python input_syntax = """ title: Test Process colourtheme: GREENTURTLE pool: Pool A lane: Lane A (start) as start [Task 1] as task1 as branch1 [@subprocess Sub process 1] as subprocess1 <@parallel branch 2> as branch2 <@inclusive branch 3> as branch3 (end) as end pool: Pool B lane: Lane B (@timer schedule 1) as timer_schedule (@intermediate schedule 2) as intermediate_schedule start->task1->branch1->subprocess1->branch2->branch3->end branch1->timer_schedule->intermediate_schedule->end footer: Generated by Process Piper """ ``` ```python gen_code, img = render(input_syntax) print(f"Generated code:\n{gen_code}") img.save("my_diagram.png") ``` ```python gen_code, img = render(input_syntax, show_code=True) ``` ```python render(input_syntax, output_file = "my_diagram.svg") ``` ```python render(input_syntax, output_file = "my_diagram.svg", export_to_bpmn = True) ``` -------------------------------- ### Create a Process Map (SVG Output) Source: https://github.com/csgoh/processpiper/wiki/Usage-Documentation Initializes a ProcessMap object and configures it to save diagrams in SVG format by specifying the painter type. ```python with ProcessMap("Sample Process Map", painter_type = "SVG") as my_process_map: ``` -------------------------------- ### Draw and Save Process Diagram Source: https://github.com/csgoh/processpiper/wiki/Usage-Documentation Draws the process diagram to the screen and saves it as a PNG file. Ensure the ProcessMap object is properly initialized and elements are added before calling these methods. ```python my_process_map.draw() my_process_map.save("my_diagram.png") ``` -------------------------------- ### v0.6: Specify Connection Points and Label Source: https://github.com/csgoh/processpiper/wiki/Breaking-Changes Version 0.6 allows specifying connection points (e.g., bottom, left) along with the connection label for more detailed diagram control. ```python start-(bottom, left)->login: Enter Credentials ``` -------------------------------- ### Connect Elements in Process Map Source: https://github.com/csgoh/processpiper/wiki/Usage-Documentation Establishes connections between elements in the process map to define the flow. Multiple connections can be chained. ```python start.connect(login).connect(search_records).connect(result_found) result_found.connect(display_result).connect(logout).connect(end) result_found.connect(search_records) ``` -------------------------------- ### Import ProcessPiper Classes Source: https://github.com/csgoh/processpiper/wiki/Usage-Documentation Imports necessary classes for creating process maps programmatically. Ensure these imports are present before using ProcessPiper. ```python from processpiper import ProcessMap, EventType, ActivityType, GatewayType ``` -------------------------------- ### Generate BPMN Diagram using PiperFlow Syntax Source: https://github.com/csgoh/processpiper/wiki/Usage-Documentation Use this snippet to generate a BPMN diagram from a string defining the process flow in PiperFlow syntax. Ensure the 'render' function is imported from 'processpiper.text2diagram'. ```python from processpiper.text2diagram import render input_syntax = """ title: Sample Test Process colourtheme: GREENTURTLE 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 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_diagram.png") ``` -------------------------------- ### Save Diagram as SVG Source: https://github.com/csgoh/processpiper/wiki/HOW-TO:-Save-Diagram-in-Scalable-Vector-Graphics-(SVG)-format Specify `painter_type='SVG'` when initializing ProcessMap to save diagrams in SVG format. Ensure the filename has an `.svg` extension when calling the save method. ```python with ProcessMap( "My Process", painter_type="SVG" ) as my_process_map: ... my_process_map.save("my_process.svg") ``` -------------------------------- ### Manually Select Connection Sides for Elements Source: https://github.com/csgoh/processpiper/wiki/How-To Manually specify the source and target connection sides when connecting elements using the connect() method. This allows for precise control over how shapes are linked, overriding the default automatic connection logic. ```python source_element.connect(target_element, source_connection_point=Side.BOTTOM, target_connection_point=Side.LEFT) ``` -------------------------------- ### Export Diagram to BPMN Format Source: https://github.com/csgoh/processpiper/wiki/How-To Export a diagram to BPMN (XML) format by calling the export_to_bpmn() method after drawing the diagram. For PiperFlow syntax, set export_to_bpmn=True during rendering. ```python my_process_map.draw() my_process_map.export_to_bpmn("my_process.bpmn") ``` ```python text2diagram.render(input_syntax, output_file, export_to_bpmn=True) ``` -------------------------------- ### v0.6: Add Label to Connection Source: https://github.com/csgoh/processpiper/wiki/Breaking-Changes In version 0.6 and later, connection labels are specified after the arrow, enabling the definition of connection points. ```python start->login: Enter Credentials ``` -------------------------------- ### Prior v0.6: Add Label to Connection Source: https://github.com/csgoh/processpiper/wiki/Breaking-Changes Before version 0.6, connection labels were specified using a different syntax within PiperFlow diagrams. ```python start-"Enter Credentials"->login ``` -------------------------------- ### Add Label to Connection Source: https://github.com/csgoh/processpiper/wiki/Usage-Documentation Adds a descriptive label to a connection between two elements in the process map. This clarifies the transition. ```python start.connect(login, "Enter Credentials") ``` -------------------------------- ### Generate Diagram using Python Code Source: https://github.com/csgoh/processpiper/blob/main/README.md This method generates a business process diagram directly using Python code. It allows for programmatic definition of lanes, pools, activities, events, and gateways. The diagram is generated using the default colour theme unless specified otherwise. ```python 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") ``` -------------------------------- ### Change Process Map Color Theme Source: https://github.com/csgoh/processpiper/wiki/Usage-Documentation Specify the desired color theme when initializing a ProcessMap object to change the diagram's appearance. Several themes are available. ```python with ProcessMap("Sample Process Map", colour_theme="GREENTURTLE") as my_process_map: ``` -------------------------------- ### Connect Elements from Right to Right Side Source: https://github.com/csgoh/processpiper/wiki/How-To Use this method to draw a connection specifically from the right connection point of the source element to the right connection point of the target element. If only one side is specified, the library automatically determines the nearest point for the other element. ```python source_element.connect(target_element, source_connection_point=Side.RIGHT, target_connection_point=Side.RIGHT) ``` -------------------------------- ### Add Pool to Process Map Source: https://github.com/csgoh/processpiper/wiki/Usage-Documentation Adds a pool to the process map using a 'with' statement. Pools help organize related elements within the diagram. ```python with ProcessMap("Sample Process Map") as my_process_map: with my_process_map.add_pool("Application") as my_pool: ``` -------------------------------- ### Display Generated Code with Line Numbers Source: https://github.com/csgoh/processpiper/wiki/How-To Display the generated code for a diagram with line numbers by using the text2diagram.show_code_with_line_number() function on the rendered code. This is useful for debugging and understanding the generated output. ```python input_syntax = """""" gen_code, img = text2diagram.render(input_syntax) text2diagram.show_code_with_line_number(gen_code) ``` ```python 1 from processpiper import ProcessMap, EventType, ActivityType, GatewayType 2 with ProcessMap("debug", colour_theme="BLUEMOUNTAIN", width=10000) as my_process_map: 3 with my_process_map.add_pool("Pool") as pool1: 4 with pool1.add_lane("") as lane1: 5 start = lane1.add_element("start", EventType.START) 6 activity_14 = lane1.add_element("the customer receives feedback from the assessor or approver", ActivityType.TASK) 7 end = lane1.add_element("end", EventType.END) 8 activity_13 = lane1.add_element("assess the request", ActivityType.TASK) 9 gateway_1 = lane1.add_element("", GatewayType.EXCLUSIVE) 10 gateway_2 = lane1.add_element("", GatewayType.EXCLUSIVE) 11 deny_the_loan = lane1.add_element("deny the loan", ActivityType.TASK) 12 approve_the_loan = lane1.add_element("approve the loan", ActivityType.TASK) 13 send_the_request = lane1.add_element("send the request", ActivityType.TASK) 14 gateway_2_end = lane1.add_element("", GatewayType.EXCLUSIVE) 15 gateway_1_end = lane1.add_element("", GatewayType.EXCLUSIVE) 16 start.connect(activity_13) 17 activity_13.connect(gateway_1) 18 gateway_1.connect(gateway_2) 19 gateway_1.connect(approve_the_loan, "the loan is \nsmall, the \ncustomer is") 20 approve_the_loan.connect(gateway_1_end) 21 gateway_2.connect(deny_the_loan) 22 gateway_2.connect(send_the_request, "the customer is") 23 send_the_request.connect(gateway_2_end) 24 deny_the_loan.connect(gateway_2_end) 25 gateway_2_end.connect(gateway_1_end) 26 gateway_1_end.connect(activity_14) 27 activity_14.connect(end) 28 my_process_map.draw() 29 my_process_map.save("piper_20230813_144818.png") ``` -------------------------------- ### Customize Font Sizes for Diagram Components Source: https://github.com/csgoh/processpiper/wiki/How-To Adjust the font sizes for the diagram title, individual elements, and the footer before drawing the diagram. The footer can also be set with custom text and font size. ```python process_map.set_title_font_size(30) process_map.set_element_font_size(10) process_map.set_footer("My footer", font_size=20) process_map.draw() process_map.save("my-diagram.png") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.