Hello,
I am facing multiple issues regarding the data object and its reference. I am using either Camunda or Modelio to model my BPMN, which is a simple user task that output a decision DataObject and an exclusive gate that either go to the end or redo the user task based on the Decision DataObject.
I checked both examples (cli and ducks) and tests, but everything is based on Camunda Forms, which isn't a route I want to go. Keeping with BPMN only, I was thinking of using DataObject as a trigger to my python app that something must be provided to the process.
I currently use a standalone script based on your CLI example (hardcoded the BPMN files, forced the debug and changed the user task to set the value of the data output) to figure out how to work with BPMN and your library. You'll find below relevant part of codes. To summarize, here my issues.
- The parser and specs uses BPMN ID as the name, which is a value auto-generated and not exposed in either Modelio or Camunda. This is not very friendly as it require the end-user that will make the process to open the raw XML and find out the BPMN ID of the DataObject and either change it everywhere in the XML to some meaningful value; or go back to the conditional expression and use the non-meaningful BPMN ID as the condition checker.
- Even after changing the conditional expression to match the name (BPMN ID), I still get that this name is not defined (maybe the PythonScriptEngine is not considering those DataObject?).
Thanks for reading me, and hopefully you'll have some idea how to sort this out!
BTW, I am using a editable from source installation of the package, since the latest released version does not have support for those data object.
Here is where you use the ID as the name.
https://github.com/sartography/SpiffWorkflow/blob/0fa2048ef2d9dd5fe856f2e476df77966bdab892/SpiffWorkflow/bpmn/specs/BpmnProcessSpec.py#L73-L82
Here is where you use the same ID to check if it exist as a data object.
https://github.com/sartography/SpiffWorkflow/blob/0fa2048ef2d9dd5fe856f2e476df77966bdab892/SpiffWorkflow/bpmn/parser/node_parser.py#L30-L48
Here is how I changed the complete_user_task(task)
. It is hardcoded for now, assuming only one output requested.
def complete_user_task(task):
display_task(task)
if task.data is None:
task.data = {}
if len(task.task_spec.data_output_associations) > 0:
task.data[task.task_spec.data_output_associations[0].name] = "redo"
Here is the error I got that the name is not defined.
Set the value of `DataObject_17prm6c` to `redo`
{'DataObject_17prm6c': 'redo'}
Traceback (most recent call last):
File "C:\Users\sa830268\Documents\dev\projects\be_tracker.backend\.venv\src\spiffworkflow\SpiffWorkflow\bpmn\PythonScriptEngine.py", line 196, in evaluate
return self._evaluate(expression, task.data, task=task)
File "C:\Users\sa830268\Documents\dev\projects\be_tracker.backend\.venv\src\spiffworkflow\SpiffWorkflow\bpmn\PythonScriptEngine.py", line 223, in _evaluate
return eval(expression, globals, lcls)
File "<string>", line 1, in <module>
NameError: name 'DataObject_17prm6c' is not defined
During handling of the above exception, another exception occurred:
File "C:\Users\sa830268\Documents\dev\bin\pyenv\pyenv-win\versions\3.10.5\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\sa830268\Documents\dev\bin\pyenv\pyenv-win\versions\3.10.5\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\sa830268\Documents\dev\projects\be_tracker.backend\app\workflow\workflow.py", line 188, in <module>
run(myWorkflow, True)
File "C:\Users\sa830268\Documents\dev\projects\be_tracker.backend\app\workflow\workflow.py", line 167, in run
workflow.do_engine_steps()
File "C:\Users\sa830268\Documents\dev\projects\be_tracker.backend\.venv\src\spiffworkflow\SpiffWorkflow\bpmn\workflow.py", line 187, in do_engine_steps
task.complete()
File "C:\Users\sa830268\Documents\dev\projects\be_tracker.backend\.venv\src\spiffworkflow\SpiffWorkflow\task.py", line 783, in complete
return self.task_spec._on_complete(self)
File "C:\Users\sa830268\Documents\dev\projects\be_tracker.backend\.venv\src\spiffworkflow\SpiffWorkflow\specs\base.py", line 405, in _on_complete
self._on_complete_hook(my_task)
File "C:\Users\sa830268\Documents\dev\projects\be_tracker.backend\.venv\src\spiffworkflow\SpiffWorkflow\specs\ExclusiveChoice.py", line 82, in _on_complete_hook
if condition is None or condition._matches(my_task):
File "C:\Users\sa830268\Documents\dev\projects\be_tracker.backend\.venv\src\spiffworkflow\SpiffWorkflow\bpmn\specs\BpmnSpecMixin.py", line 33, in _matches
return task.workflow.script_engine.evaluate(task, self.args[0])
File "C:\Users\sa830268\Documents\dev\projects\be_tracker.backend\.venv\src\spiffworkflow\SpiffWorkflow\bpmn\PythonScriptEngine.py", line 198, in evaluate
raise WorkflowTaskExecException(task,
SpiffWorkflow.bpmn.exceptions.WorkflowTaskExecException: Gateway_1i6bkpl: Error evaluating expression 'DataObject_17prm6c=='redo'', name 'DataObject_17prm6c' is not defined
Here my BPMN process from Camunda. It will fail to evaluate decision="redo"
because it is stored as DataObject_17prm6c
.
<bpmn:process id="process" name="process" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:extensionElements />
<bpmn:outgoing>Flow_0xkz2ar</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="Flow_0xkz2ar" sourceRef="StartEvent_1" targetRef="Activity_1repqrz" />
<bpmn:userTask id="Activity_1repqrz" name="Init">
<bpmn:extensionElements />
<bpmn:incoming>Flow_0xkz2ar</bpmn:incoming>
<bpmn:incoming>Flow_0zwwzf9</bpmn:incoming>
<bpmn:outgoing>Flow_08d7vel</bpmn:outgoing>
<bpmn:dataOutputAssociation id="DataOutputAssociation_1s559c4">
<bpmn:targetRef>DataObjectReference_05w9q7s</bpmn:targetRef>
</bpmn:dataOutputAssociation>
</bpmn:userTask>
<bpmn:exclusiveGateway id="Gateway_1i6bkpl" name="Check Decision?" default="Flow_0tgoifw">
<bpmn:incoming>Flow_08d7vel</bpmn:incoming>
<bpmn:outgoing>Flow_0tgoifw</bpmn:outgoing>
<bpmn:outgoing>Flow_0zwwzf9</bpmn:outgoing>
</bpmn:exclusiveGateway>
<bpmn:sequenceFlow id="Flow_08d7vel" sourceRef="Activity_1repqrz" targetRef="Gateway_1i6bkpl" />
<bpmn:endEvent id="Event_0v8tu84">
<bpmn:incoming>Flow_0tgoifw</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_0tgoifw" name="Go" sourceRef="Gateway_1i6bkpl" targetRef="Event_0v8tu84" />
<bpmn:sequenceFlow id="Flow_0zwwzf9" name="Redo" sourceRef="Gateway_1i6bkpl" targetRef="Activity_1repqrz">
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">decision=='redo'</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:dataObjectReference id="DataObjectReference_05w9q7s" name="Decision" dataObjectRef="DataObject_17prm6c" />
<bpmn:dataObject id="DataObject_17prm6c" />
</bpmn:process>
Here the same process as generated by Modelio
<process isClosed="false" isExecutable="true" processType="Public" name="CR_Process" id="bbc9568e-4664-4a24-929e-bd3854857707">
<dataObject name="decision" id="REF-af032a66-519a-4e2f-93db-b85804d3dd47"/>
<startEvent isInterrupting="false" parallelMultiple="false" name="" id="modelio-80b31935-5e9b-4607-b08d-34fca404aa05">
<ns5:outgoing xmlns:ns5="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns="">modelio-6af02fe6-8c7c-4ce6-b581-ef5b0217d60f</ns5:outgoing>
</startEvent>
<sequenceFlow sourceRef="modelio-80b31935-5e9b-4607-b08d-34fca404aa05" targetRef="modelio-6331c10a-3991-4fe9-9153-8b705ca1484e" name="" id="modelio-6af02fe6-8c7c-4ce6-b581-ef5b0217d60f"/>
<userTask implementation="##WebService" isForCompensation="false" startQuantity="1" completionQuantity="1" name="Init" id="modelio-6331c10a-3991-4fe9-9153-8b705ca1484e">
<ns5:incoming xmlns:ns5="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns="">modelio-6af02fe6-8c7c-4ce6-b581-ef5b0217d60f</ns5:incoming>
<ns5:incoming xmlns:ns5="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns="">modelio-15cba2c4-c161-4612-b70a-0d30521ecd5e</ns5:incoming>
<ns5:outgoing xmlns:ns5="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns="">modelio-1641545c-6422-4639-9ad9-8b4fbff74f28</ns5:outgoing>
<ioSpecification>
<dataOutput id="modelio-6331c10a-3991-4fe9-9153-8b705ca1484e-af032a66-519a-4e2f-93db-b85804d3dd47"/>
<inputSet id="InputSet_modelio-6331c10a-3991-4fe9-9153-8b705ca1484e"/>
<outputSet id="OutputSet_modelio-6331c10a-3991-4fe9-9153-8b705ca1484e">
<dataOutputRefs>modelio-6331c10a-3991-4fe9-9153-8b705ca1484e-af032a66-519a-4e2f-93db-b85804d3dd47</dataOutputRefs>
</outputSet>
</ioSpecification>
<dataOutputAssociation id="modelio-64e43a05-949f-44f0-9912-7f0cb6712af3">
<sourceRef>modelio-6331c10a-3991-4fe9-9153-8b705ca1484e-af032a66-519a-4e2f-93db-b85804d3dd47</sourceRef>
<targetRef>af032a66-519a-4e2f-93db-b85804d3dd47</targetRef>
</dataOutputAssociation>
</userTask>
<sequenceFlow sourceRef="modelio-6331c10a-3991-4fe9-9153-8b705ca1484e" targetRef="f5552950-c5a9-43c8-b203-b81ab0ddb8ec" name="Sequence Flow" id="modelio-1641545c-6422-4639-9ad9-8b4fbff74f28"/>
<exclusiveGateway default="e38cee12-2744-48a0-85f6-81280c4b4aa6" gatewayDirection="Unspecified" name="Check Decision?" id="f5552950-c5a9-43c8-b203-b81ab0ddb8ec">
<ns5:incoming xmlns:ns5="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns="">modelio-1641545c-6422-4639-9ad9-8b4fbff74f28</ns5:incoming>
<ns5:outgoing xmlns:ns5="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns="">e38cee12-2744-48a0-85f6-81280c4b4aa6</ns5:outgoing>
<ns5:outgoing xmlns:ns5="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns="">modelio-15cba2c4-c161-4612-b70a-0d30521ecd5e</ns5:outgoing>
</exclusiveGateway>
<endEvent name="" id="e3f80147-cf6f-47f4-92f0-9f94e83e1455">
<ns5:incoming xmlns:ns5="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns="">e38cee12-2744-48a0-85f6-81280c4b4aa6</ns5:incoming>
</endEvent>
<dataObjectReference dataObjectRef="REF-af032a66-519a-4e2f-93db-b85804d3dd47" name="decision" id="af032a66-519a-4e2f-93db-b85804d3dd47"/>
<sequenceFlow sourceRef="f5552950-c5a9-43c8-b203-b81ab0ddb8ec" targetRef="e3f80147-cf6f-47f4-92f0-9f94e83e1455" name="Sequence Flow1" id="e38cee12-2744-48a0-85f6-81280c4b4aa6"/>
<sequenceFlow sourceRef="f5552950-c5a9-43c8-b203-b81ab0ddb8ec" targetRef="modelio-6331c10a-3991-4fe9-9153-8b705ca1484e" name="Sequence Flow2" id="modelio-15cba2c4-c161-4612-b70a-0d30521ecd5e">
<conditionExpression>decision=="redo"</conditionExpression>
</sequenceFlow>
</process>