Skip to content

Commit

Permalink
return results of reset_branch when migrating
Browse files Browse the repository at this point in the history
  • Loading branch information
essweine committed Jul 16, 2024
1 parent 91b623c commit cd9c3eb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion SpiffWorkflow/bpmn/util/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ def migrate_workflow(diff, workflow, spec, reset_mask=None):
Keyword Args:
reset_mask (`TaskState`): reset and repredict tasks in this state
Returns
a list of deleted `Task`
The default rest_mask is TaskState.READY|TaskState.WAITING but can be overridden.
"""
workflow.spec = spec
Expand All @@ -230,11 +233,14 @@ def migrate_workflow(diff, workflow, spec, reset_mask=None):
task.task_spec = diff.alignment.get(task)

default_mask = TaskState.READY|TaskState.WAITING
removed_tasks = []
for task in list(workflow.get_tasks(state=reset_mask or default_mask, skip_subprocesses=True)):
# In some cases, completed tasks with ready or waiting children could get removed
# (for example, in cycle timer). If a task has already been removed from the tree, ignore it.
if task.id in workflow.tasks:
task.reset_branch(None)
removed_tasks.extend(task.reset_branch(None))

if workflow.last_task not in workflow.tasks:
workflow.last_task = None

return removed_tasks

0 comments on commit cd9c3eb

Please sign in to comment.