WIP trying to get resetting to a task within a subprocess working w/ burnettk

This commit is contained in:
jasquat 2023-03-30 16:30:34 -04:00
parent c73c0dcad1
commit 854b41378f
4 changed files with 24 additions and 13 deletions

View File

@ -1348,6 +1348,7 @@ class ProcessInstanceProcessor:
for task_to_update in tasks_to_update:
# print(f"task_to_update: {task_to_update}")
print(f"task_to_update.state: {task_to_update.state}")
TaskService.reset_task_model(task_to_update, state="FUTURE", commit=commit)
# TaskService.reset_task_model(task_to_update, state=task_to_update.state, commit=commit)
# if task_to_update.task_definition.bpmn_identifier != 'top_level_process_script_after_gate':

View File

@ -72,6 +72,8 @@ class TaskModelSavingDelegate(EngineStepDelegate):
def will_complete_task(self, spiff_task: SpiffTask) -> None:
if self._should_update_task_model():
self.current_task_start_in_seconds = time.time()
# import pdb; pdb.set_trace()
spiff_task.task_spec._predict(spiff_task, mask=TaskState.NOT_FINISHED_MASK)
if self.secondary_engine_step_delegate:
self.secondary_engine_step_delegate.will_complete_task(spiff_task)
@ -108,6 +110,7 @@ class TaskModelSavingDelegate(EngineStepDelegate):
# ):
# self._update_task_model_with_spiff_task(waiting_spiff_task)
if self.last_completed_spiff_task is not None:
import pdb; pdb.set_trace()
self.task_service.process_spiff_task_parents(self.last_completed_spiff_task)
self.task_service.process_spiff_task_children(self.last_completed_spiff_task)

View File

@ -2618,6 +2618,7 @@ class TestProcessApi(BaseTest):
)
assert response.status_code == 200
assert response.json is not None
import pdb; pdb.set_trace()
assert response.json["status"] == "complete"
response = client.get(

View File

@ -347,30 +347,36 @@ class TestProcessInstanceProcessor(BaseTest):
human_task_one = process_instance.active_human_tasks[0]
spiff_manual_task = processor.bpmn_process_instance.get_task_from_id(UUID(human_task_one.task_id))
ProcessInstanceService.complete_form_task(processor, spiff_manual_task, {}, initiator_user, human_task_one)
human_task_one = process_instance.active_human_tasks[0]
spiff_manual_task = processor.bpmn_process_instance.get_task_from_id(UUID(human_task_one.task_id))
ProcessInstanceService.complete_form_task(processor, spiff_manual_task, {}, initiator_user, human_task_one)
### NOTES:
# somehow we are hosing the task state so that when completing tasks of a subprocess, the task AFTER the subprocess task
# is not marked READY but instead stays as FUTURE. Running things like:
# self.last_completed_spiff_task.task_spec._update(self.last_completed_spiff_task)
# and
# self.last_completed_spiff_task.task_spec._predict(self.last_completed_spiff_task, mask=TaskState.NOT_FINISHED_MASK)
# did not help.
processor.suspend()
ProcessInstanceProcessor.reset_process(process_instance, str(spiff_manual_task.id), commit=True)
# import pdb; pdb.set_trace()
task_model_to_reset_to = TaskModel.query.join(TaskDefinitionModel).filter(TaskDefinitionModel.bpmn_identifier == 'top_level_subprocess_script').order_by(TaskModel.id.desc()).first()
assert task_model_to_reset_to is not None
ProcessInstanceProcessor.reset_process(process_instance, task_model_to_reset_to.guid, commit=True)
# import pdb; pdb.set_trace()
process_instance = ProcessInstanceModel.query.filter_by(id=process_instance.id).first()
processor = ProcessInstanceProcessor(process_instance)
processor.resume()
processor.do_engine_steps(save=True)
import pdb; pdb.set_trace()
assert len(process_instance.active_human_tasks) == 1
human_task_one = process_instance.active_human_tasks[0]
spiff_manual_task = processor.bpmn_process_instance.get_task_from_id(UUID(human_task_one.task_id))
ProcessInstanceService.complete_form_task(processor, spiff_manual_task, {}, initiator_user, human_task_one)
process_instance = ProcessInstanceModel.query.filter_by(id=process_instance.id).first()
processor = ProcessInstanceProcessor(process_instance)
human_task_one = process_instance.active_human_tasks[0]
spiff_manual_task = processor.bpmn_process_instance.get_task_from_id(UUID(human_task_one.task_id))
ProcessInstanceService.complete_form_task(processor, spiff_manual_task, {}, initiator_user, human_task_one)
human_task_one = process_instance.active_human_tasks[0]
spiff_manual_task = processor.bpmn_process_instance.get_task_from_id(UUID(human_task_one.task_id))
ProcessInstanceService.complete_form_task(processor, spiff_manual_task, {}, initiator_user, human_task_one)
# recreate variables to ensure all bpmn json was recreated from scratch from the db
process_instance_relookup = ProcessInstanceModel.query.filter_by(id=process_instance.id).first()
assert process_instance_relookup.status == "complete"
assert process_instance.status == "complete"
def test_properly_saves_tasks_when_running(
self,