Skip to content

Commit

Permalink
Merge pull request #414 from sartography/feature/performance-improvem…
Browse files Browse the repository at this point in the history
…ents

Feature/performance improvements
  • Loading branch information
essweine committed May 30, 2024
2 parents b8e31e4 + 4503799 commit faf859f
Show file tree
Hide file tree
Showing 10 changed files with 566 additions and 130 deletions.
8 changes: 8 additions & 0 deletions SpiffWorkflow/bpmn/serializer/default/process_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# 02110-1301 USA

from ..helpers.bpmn_converter import BpmnConverter
from SpiffWorkflow.bpmn.specs.mixins.multiinstance_task import LoopTask


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

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

for task_spec in loop_tasks:
child_spec = spec.task_specs.get(task_spec.task_spec)
child_spec.completed_event.connect(task_spec.merge_child)

return spec
13 changes: 13 additions & 0 deletions SpiffWorkflow/bpmn/serializer/migration/version_1_4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

def update_mi_states(dct):

typenames = ['StandardLoopTask', 'SequentialMultiInstanceTask', 'ParallelMultiInstanceTask']
def update(tasks, task_specs):
for task in tasks:
task_spec = task_specs.get(task['task_spec'], {})
if task['state'] == 8 and task_spec['typename'] in typenames:
task['state'] = 32

for up in dct['subprocesses'].values():
update(sp['tasks'].values(), sp['spec']['task_specs'])
update(dct['tasks'].values(), dct['spec']['task_specs'])
26 changes: 25 additions & 1 deletion SpiffWorkflow/bpmn/serializer/migration/version_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,39 @@
add_new_typenames,
update_data_objects,
)
from .version_1_4 import update_mi_states

def from_version_1_3(dct):
"""Upgrade serialization from v1.3 to v1.4
Multiinstance tasks now rely on events rather than polling to merge children, so once
they are reached, they should be STARTED rather than WAITING.
"""
dct['VERSION'] = "1.3"
update_mi_states(dct)

def from_version_1_2(dct):
"""Upgrade serialization from v.1.2 to v.1.3
The internal/external distinction on event definitions was replaced with the ability to
target a specific workflow.
Boundary event parent gateway tasks ave been replaced with a gateway structure.
The creation of an unnecessary root task was removed; the workflow spec's start task is
used as the root instead.
BpmnWorkflows and BpmnSubworkflows were split into to classes.
Data objects are now stored on the topmost workflow where they are defined.
"""
dct['VERSION'] = "1.3"
update_event_definition_attributes(dct)
remove_boundary_event_parent(dct)
remove_root_task(dct)
add_new_typenames(dct)
update_data_objects(dct)


def from_version_1_1(dct):
"""
Upgrade v1.1 serialization to v1.2.
Expand Down Expand Up @@ -98,4 +121,5 @@ def from_version_1_0(dct):
'1.0': from_version_1_0,
'1.1': from_version_1_1,
'1.2': from_version_1_2,
'1.3': from_version_1_3,
}
2 changes: 1 addition & 1 deletion SpiffWorkflow/bpmn/serializer/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from .config import DEFAULT_CONFIG

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


class BpmnWorkflowSerializer:
Expand Down
Loading

0 comments on commit faf859f

Please sign in to comment.