1 / 49

Executing BPMN 2.0 Workflows in Python

Executing BPMN 2.0 Workflows in Python. Matt Hampton PYCONZA 2012. Outline. A Tale of Woe Business Process Model and Notation SpiffWorkflow And the Workflow Patterns initiative SpiffWorkflow + BPMN Recommended Use Case Q & A. Outline. A Tale of Woe

marcy
Télécharger la présentation

Executing BPMN 2.0 Workflows in Python

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Executing BPMN 2.0 Workflows in Python Matt Hampton PYCONZA 2012

  2. Outline • A Tale of Woe • Business Process Model and Notation • SpiffWorkflow • And the Workflow Patterns initiative • SpiffWorkflow + BPMN • Recommended Use Case • Q & A

  3. Outline • A Tale of Woe • Business Process Model and Notation • SpiffWorkflow • And the Workflow Patterns initiative • SpiffWorkflow + BPMN • Recommended Use Case • Q & A

  4. But First - Some Context

  5. Permit to Work

  6. j5 Interface

  7. j5 Interface

  8. The Flow Chart

  9. Completing a Permit Version 2 Version 1

  10. defget_close_button_rights(self): """Whether or not the user has the right to click the Close (Isolations Removed) button""" ifself.statusin ('Complete','Reactivated','Closed (Isolations Maintained)'): session =RequestStack.request_stack.session if session: ifself.approved_by==session.user: permit_work_table=Alchemy.find_recordclass("permit_work") withAlchemy.closing(self.session_class()) assa_session: associated_permits=sa_session.query(permit_work_table).filter(sqlalchemy.and_(permit_work_table.config_logid==self.config_logid,permit_work_table.master_permit=='No', permit_work_table.status=='Closed (Isolations Maintained)')).all() ifself.master_permit=='Yes': ifnotassociated_permitsand (self.num_isolation_pointsin (0, '0') orself.points_deisolated=='True') and (self.check_list_reactivate_complete=='True'orself.num_spec_reactivate_questionsin (0, '0')): ifself.gs_required==u"Yes": ifself.gs_test_due==u"False"orself.gs_button_clicked=="Yes": return'True' else: return'True' elif (notself.num_isolation_pointsin (0, '0') orassociated_permits) andself.check_list_reactivate_complete=='False'andnotself.num_spec_reactivate_questionsin (0, '0'): ifself.gs_required==u"Yes": ifself.gs_test_due==u"False"orself.gs_button_clicked=="Yes": return'True' else: return'True' elif (self.points_deisolated=='True'orself.categoryin ("Vehicle", "Lifting")): ifself.gs_required==u"Yes": ifself.gs_test_due==u"False"orself.gs_button_clicked=="Yes": return'True' else: return'True' elifself.status=='Incomplete': #If the status is Incomplete this button is a Reissue button session =RequestStack.request_stack.session if session: ifself.approved_by==session.user: return'True' return'False' close_button_rights=property(get_close_button_rights)

  11. Gratuitous Gang of Four Quote • Use the State pattern if: • Operations have large, multipart conditional statements that depend on the object’s state. The state is usually represented by one or more enumerated constants. Often, several operations will contain this same conditional structure. • Hmmm.

  12. Why not State Pattern? Version 3 Hmmmm….

  13. OMG!

  14. OMG!

  15. OMG(!) BPMN • Object Management Group • Business Process Modelling Notation (v1) • Business Friendly notation in wide use • Unambiguous semantics • Clear analysis / communication of requirements • Asking the right questions • Business Process Model and Notation (v2) • Executable Process Definitions • http://www.bpmn.org

  16. Start Event

  17. User Task Script Task

  18. Lane Pool Lane

  19. Exclusive Gateway (Diverging)

  20. Parallel Gateway (Diverging)

  21. Intermediate Catching Event (Timer)

  22. Call Activity

  23. Boundary Event (Non-interrupting)

  24. End Event (Terminating) End Event

  25. Annotations for Clarity Facilitates Top-Down Decomposition of Complex Processes

  26. Other BPMN Features • Exception Handling • Compensation • Data Objects • Multiple Instances / Looping

  27. Outline • A Tale of Woe • Business Process Model and Notation • SpiffWorkflow • And the Workflow Patterns initiative • SpiffWorkflow + BPMN • Recommended Use Case • Q & A

  28. SpiffWorkflow • Pure Python Library • Based on the Worklow Patterns initiative • http://www.workflowpatterns.com • Build a ‘Workflow Spec’ • Create a ‘Workflow’ instance • API for getting a list of READY / WAITING tasks • Completing a task, moves the workflow forward • Maintained by Samuel Abels

  29. classMyWorkflowSpec(WorkflowSpec): def__init__(self): WorkflowSpec.__init__(self) # Build one branch. a1 = Simple(self, 'task_a1') self.start.connect(a1) a2 = Simple(self, 'task_a2') a1.connect(a2) # Build another branch. b1 = Simple(self, 'task_b1') self.start.connect(b1) b2 = Simple(self, 'task_b2') b1.connect(b2) # Merge both branches (synchronized). synch_1 = Join(self, 'synch_1') a2.connect(synch_1) b2.connect(synch_1) # If-condition: excl_choice_1 =ExclusiveChoice(self, 'excl_choice_1') synch_1.connect(excl_choice_1) c1 = Simple(self, 'task_c1') excl_choice_1.connect(c1) c2 = Simple(self, 'task_c2') cond= Equal(Attrib('test_attribute1'), Attrib('test_attribute2')) excl_choice_1.connect_if(cond, c2) c3 = Simple(self, 'task_c3') excl_choice_1.connect_if(cond, c3)

  30. Control Flow Features • Sequence • Parallel Split • Exclusive Choice • Simple Merge • Multi-Choice • Structured Synchronizing Merge • …..

  31. Outline • A Tale of Woe • Business Process Model and Notation • SpiffWorkflow • And the Workflow Patterns initiative • SpiffWorkflow + BPMN • Recommended Use Case • Q & A

  32. SpiffWorkflow + BPMN • Pluggable Parser • Extensible Task Spec classes • Allows the use of BPMN extension elements • Pluggable Script Engine • Executes script tasks • Evaluates expressions • Database-friendly Workflow Serialization

  33. Supported BPMN Features • Call Activity • Start Event • End Event (including interrupting) • User and Manual Tasks • Script Task

  34. Supported BPMN Features • Exclusive Gateway • Parallel Gateway • Intermediate Catch Events (Timer and Message) • Boundary Events (Timer and Message, interrupting and non-interrupting)

  35. Eclipse BPMN2 Modeler

  36. Gemsbok (ex-Signavio) Custom ‘Stencil Set’ Custom Properties

  37. Project Status • BPMN extension is currently in a fork: • https://github.com/matthewhampton/SpiffWorkflow • Should be merged in to the base project in the next month • Gemsbok is here: • https://github.com/matthewhampton/Gemsbok • Eclipse BPMN2 Modeler is here: • http://eclipse.org/bpmn2-modeler

  38. Outline • A Tale of Woe • Business Process Model and Notation • SpiffWorkflow • And the Workflow Patterns initiative • SpiffWorkflow + BPMN • Recommended Use Case • Q & A

  39. Is BPMN for you? • Small number of states? • Use the State Pattern, or a similar OO decomposition • Single-threaded & No Actions on Transitions • Table-based State Machine • Complex workflows? • Getting tied up in specification round trips? • Like Pretty Pictures? OMG BPMN!

  40. Outline • A Tale of Woe • Business Process Model and Notation • SpiffWorkflow • And the Workflow Patterns initiative • SpiffWorkflow + BPMN • Recommended Use Case • Q & A

  41. ?

  42. ?

More Related