Skip to content

Commit faf859f

Browse files
authored
Merge pull request #414 from sartography/feature/performance-improvements
Feature/performance improvements
2 parents b8e31e4 + 4503799 commit faf859f

File tree

10 files changed

+566
-130
lines changed

10 files changed

+566
-130
lines changed

SpiffWorkflow/bpmn/serializer/default/process_spec.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
# 02110-1301 USA
1919

2020
from ..helpers.bpmn_converter import BpmnConverter
21+
from SpiffWorkflow.bpmn.specs.mixins.multiinstance_task import LoopTask
2122

2223

2324
class BpmnProcessSpecConverter(BpmnConverter):
@@ -71,6 +72,7 @@ def from_dict(self, dct):
7172
# Add messaging related stuff
7273
spec.correlation_keys = dct.pop('correlation_keys', {})
7374

75+
loop_tasks = []
7476
dct['task_specs'].pop('Root', None)
7577
for name, task_dict in dct['task_specs'].items():
7678
# I hate this, but I need to pass in the workflow spec when I create the task.
@@ -80,6 +82,12 @@ def from_dict(self, dct):
8082
task_spec = self.registry.restore(task_dict)
8183
if name == 'Start':
8284
spec.start = task_spec
85+
if isinstance(task_spec, LoopTask):
86+
loop_tasks.append(task_spec)
8387
self.restore_task_spec_extensions(task_dict, task_spec)
8488

89+
for task_spec in loop_tasks:
90+
child_spec = spec.task_specs.get(task_spec.task_spec)
91+
child_spec.completed_event.connect(task_spec.merge_child)
92+
8593
return spec
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
def update_mi_states(dct):
3+
4+
typenames = ['StandardLoopTask', 'SequentialMultiInstanceTask', 'ParallelMultiInstanceTask']
5+
def update(tasks, task_specs):
6+
for task in tasks:
7+
task_spec = task_specs.get(task['task_spec'], {})
8+
if task['state'] == 8 and task_spec['typename'] in typenames:
9+
task['state'] = 32
10+
11+
for up in dct['subprocesses'].values():
12+
update(sp['tasks'].values(), sp['spec']['task_specs'])
13+
update(dct['tasks'].values(), dct['spec']['task_specs'])

SpiffWorkflow/bpmn/serializer/migration/version_migration.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,39 @@
3535
add_new_typenames,
3636
update_data_objects,
3737
)
38+
from .version_1_4 import update_mi_states
39+
40+
def from_version_1_3(dct):
41+
"""Upgrade serialization from v1.3 to v1.4
42+
43+
Multiinstance tasks now rely on events rather than polling to merge children, so once
44+
they are reached, they should be STARTED rather than WAITING.
45+
"""
46+
dct['VERSION'] = "1.3"
47+
update_mi_states(dct)
3848

3949
def from_version_1_2(dct):
50+
"""Upgrade serialization from v.1.2 to v.1.3
51+
52+
The internal/external distinction on event definitions was replaced with the ability to
53+
target a specific workflow.
54+
55+
Boundary event parent gateway tasks ave been replaced with a gateway structure.
56+
57+
The creation of an unnecessary root task was removed; the workflow spec's start task is
58+
used as the root instead.
59+
60+
BpmnWorkflows and BpmnSubworkflows were split into to classes.
61+
62+
Data objects are now stored on the topmost workflow where they are defined.
63+
"""
4064
dct['VERSION'] = "1.3"
4165
update_event_definition_attributes(dct)
4266
remove_boundary_event_parent(dct)
4367
remove_root_task(dct)
4468
add_new_typenames(dct)
4569
update_data_objects(dct)
4670

47-
4871
def from_version_1_1(dct):
4972
"""
5073
Upgrade v1.1 serialization to v1.2.
@@ -98,4 +121,5 @@ def from_version_1_0(dct):
98121
'1.0': from_version_1_0,
99122
'1.1': from_version_1_1,
100123
'1.2': from_version_1_2,
124+
'1.3': from_version_1_3,
101125
}

SpiffWorkflow/bpmn/serializer/workflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from .config import DEFAULT_CONFIG
2626

2727
# This is the default version set on the workflow, it can be overridden in init
28-
VERSION = "1.3"
28+
VERSION = "1.4"
2929

3030

3131
class BpmnWorkflowSerializer:

0 commit comments

Comments
 (0)