Skip to content

Commit

Permalink
Update remaining steps upon task completion
Browse files Browse the repository at this point in the history
  • Loading branch information
andchiind committed Apr 18, 2024
1 parent a74ce92 commit f3dd2a8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/isar/state_machine/state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,16 @@ def update_current_step(self):
if self.current_task:
self.current_step = self.current_task.next_step()

def update_remaining_steps(self):
if self.current_task:
for step in self.current_task.steps:
if (
step.status == StepStatus.InProgress
or step.status == StepStatus.NotStarted
):
step.status = self.current_task.status
self.publish_step_status(step=step)

def update_state(self):
"""Updates the current state of the state machine."""
self.current_state = States(self.state)
Expand Down
1 change: 1 addition & 0 deletions src/isar/state_machine/states/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def _run(self) -> None:
self.state_machine.current_task
)
if self.state_machine.current_task.status == TaskStatus.Successful:
self.state_machine.update_remaining_steps()
try:
self.state_machine.current_task = (
self.state_machine.task_selector.next_task()
Expand Down
4 changes: 3 additions & 1 deletion tests/isar/state_machine/states/test_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def test_should_only_upload_if_status_is_completed(
step.status = StepStatus.Successful if is_status_successful else StepStatus.Failed
task: Task = Task(steps=[step])
mission: Mission = Mission(tasks=[task])
mission.status = MissionStatus.Successful if is_status_successful else MissionStatus.Failed
mission.status = (
MissionStatus.Successful if is_status_successful else MissionStatus.Failed
)

monitor.state_machine.current_mission = mission
monitor.state_machine.current_task = task
Expand Down

0 comments on commit f3dd2a8

Please sign in to comment.