[swarming_retry] Skip empty steps

It's confusing to show the "launch" and "process results" steps for
launch/collect iterations that don't launch any tasks or process any
results, respectively.

Change-Id: I7590af90328ebe19be8182d306739c51e79b1ae7
diff --git a/recipe_modules/swarming_retry/api.py b/recipe_modules/swarming_retry/api.py
index d7514b2..5b41d7a 100644
--- a/recipe_modules/swarming_retry/api.py
+++ b/recipe_modules/swarming_retry/api.py
@@ -328,8 +328,17 @@
         self.m.swarming.TaskState.PENDING,
     }
 
-  def _launch_and_collect(self, tasks, max_attempts, collect_timeout,
-                          collect_output_dir):
+  def _launch(self, tasks):
+    for task in tasks:
+      task_name = '%s (attempt %d)' % (task.name, len(task.attempts))
+      with self.m.step.nest(task_name) as presentation:
+        attempt = task.launch()
+        assert attempt.task_id not in self._tasks_by_id
+        self._tasks_by_id[attempt.task_id] = task
+        presentation.links['Swarming task'] = attempt.task_ui_link
+
+  def _launch_and_collect(self, tasks, collect_timeout, collect_output_dir,
+                          summary_presentation):
     """Launch necessary tasks and process those that complete.
 
     Launch any tasks that are not currently running, have not passed,
@@ -347,11 +356,12 @@
 
     Args:
       tasks (list[Task]): tasks to execute
-      max_attempts (int): maximum number of attempts per task
       collect_timeout (str): duration to wait for tasks to complete
         (format: https://golang.org/pkg/time/#ParseDuration)
       collect_output_dir (Path or None): output directory to pass to
         api.swarming.collect()
+      summary_presentation (StepPresentation): where to attach the
+        summary for this round of launch/collect
 
     Returns:
       Number of jobs still running or to be relaunched. As long as this
@@ -359,27 +369,12 @@
     """
 
     summary = []
-    # Launch tasks.
-    with self.m.step.nest('launch'):
-      num_launches = 0
-      for task in tasks:
-        if not task.max_attempts:
-          task.max_attempts = max_attempts
 
-        if not task.should_launch():
-          continue
-
-        task_name = '%s (attempt %d)' % (task.name, len(task.attempts))
-        with self.m.step.nest(task_name) as task_step_presentation:
-          attempt = task.launch()
-          assert attempt.task_id not in self._tasks_by_id
-          self._tasks_by_id[attempt.task_id] = task
-          num_launches += 1
-
-          task_step_presentation.links['Swarming task'] = attempt.task_ui_link
-
-      if num_launches:
-        summary.append('%d launched' % num_launches)
+    to_launch = [task for task in tasks if task.should_launch()]
+    if to_launch:
+      with self.m.step.nest('launch'):
+        self._launch(to_launch)
+      summary.append('%d launched' % len(to_launch))
 
     results = []
     task_ids = [x.attempts[-1].task_id for x in tasks if x.in_progress]
@@ -397,37 +392,40 @@
     # (This also makes testing this module much easier.)
     num_missed_by_collect = len(task_ids) - len(results)
 
-    with self.m.step.nest('process results', status='last'):
-      passed_tasks = []
-      failed_tasks = []
-      incomplete_tasks = []
-      for result in results:
-        task = self._tasks_by_id[result.id]
-        if not self._is_complete(result):
-          incomplete_tasks.append(task)
-          continue
-
+    incomplete_tasks = []
+    complete_tasks = []
+    for result in results:
+      task = self._tasks_by_id[result.id]
+      if self._is_complete(result):
         task.attempts[-1].result = result
+        complete_tasks.append(task)
+      else:
+        incomplete_tasks.append(task)
 
-        try:
-          task.process_result()
-        except recipe_api.StepFailure as e:
-          error_step = self.m.step('exception', None)
-          error_step.presentation.step_summary_text = str(e)
-          error_step.presentation.logs['exception'] = (
-              traceback.format_exc().splitlines())
-          task.attempts[-1].failure_reason = (
-              'exception during result processing')
+    passed_tasks = []
+    failed_tasks = []
+    if complete_tasks:
+      with self.m.step.nest('process results', status='last'):
+        for task in complete_tasks:
+          try:
+            task.process_result()
+          except recipe_api.StepFailure as e:
+            error_step = self.m.step('exception', None)
+            error_step.presentation.step_summary_text = str(e)
+            error_step.presentation.logs['exception'] = (
+                traceback.format_exc().splitlines())
+            task.attempts[-1].failure_reason = (
+                'exception during result processing')
 
-        if task.success:
-          passed_tasks.append(task)
-        else:
-          failed_tasks.append(task)
+          if task.success:
+            passed_tasks.append(task)
+          else:
+            failed_tasks.append(task)
 
-      # Add passing step at end so parent step always passes (since
-      # parent step has status='last'). Any errors will be shown when
-      # presenting results.
-      self.m.step('always pass', None)
+        # Add passing step at end so parent step always passes (since
+        # parent step has status='last'). Any errors will be shown when
+        # presenting results.
+        self.m.step('always pass', None)
 
     for list_name, task_list in [
         ('passed', passed_tasks),
@@ -459,8 +457,7 @@
       summary.append('%d failed after max attempts' %
                      len(failed_after_max_attempts))
 
-    self.m.step.active_result.presentation.step_summary_text = ', '.join(
-        summary)
+    summary_presentation.step_summary_text = ', '.join(summary)
 
     return len(to_be_relaunched) + len(incomplete_tasks) + num_missed_by_collect
 
@@ -493,14 +490,18 @@
     if len(tasks) == 1:
       collect_timeout = None
 
+    for task in tasks:
+      if not task.max_attempts:
+        task.max_attempts = max_attempts
+
     with self.m.step.nest('launch/collect'), self.m.context(infra_steps=True):
       for i in itertools.count(0):
-        with self.m.step.nest(str(i)):
+        with self.m.step.nest(str(i)) as presentation:
           if not self._launch_and_collect(
               tasks=tasks,
-              max_attempts=max_attempts,
               collect_timeout=collect_timeout,
-              collect_output_dir=collect_output_dir):
+              collect_output_dir=collect_output_dir,
+              summary_presentation=presentation):
             break
 
     failed = [x for x in tasks if not x.success]
diff --git a/recipe_modules/swarming_retry/examples/full.expected/full_test.json b/recipe_modules/swarming_retry/examples/full.expected/full_test.json
index 0e2b040..bd1c873 100644
--- a/recipe_modules/swarming_retry/examples/full.expected/full_test.json
+++ b/recipe_modules/swarming_retry/examples/full.expected/full_test.json
@@ -421,13 +421,6 @@
     ]
   },
   {
-    "cmd": [],
-    "name": "launch/collect.2.launch",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
     "cmd": [
       "[CACHE]/swarming_client/swarming",
       "collect",
@@ -474,20 +467,6 @@
   },
   {
     "cmd": [],
-    "name": "launch/collect.2.process results",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [],
-    "name": "launch/collect.2.process results.always pass",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@3@@@"
-    ]
-  },
-  {
-    "cmd": [],
     "name": "launch/collect.2.incomplete tasks",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@",
@@ -505,13 +484,6 @@
     ]
   },
   {
-    "cmd": [],
-    "name": "launch/collect.3.launch",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
     "cmd": [
       "[CACHE]/swarming_client/swarming",
       "collect",
@@ -537,20 +509,6 @@
   },
   {
     "cmd": [],
-    "name": "launch/collect.3.process results",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [],
-    "name": "launch/collect.3.process results.always pass",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@3@@@"
-    ]
-  },
-  {
-    "cmd": [],
     "name": "launch/collect.4",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@",
@@ -558,13 +516,6 @@
     ]
   },
   {
-    "cmd": [],
-    "name": "launch/collect.4.launch",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
     "cmd": [
       "[CACHE]/swarming_client/swarming",
       "collect",
@@ -640,13 +591,6 @@
     ]
   },
   {
-    "cmd": [],
-    "name": "launch/collect.5.launch",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
     "cmd": [
       "[CACHE]/swarming_client/swarming",
       "collect",
@@ -865,20 +809,6 @@
   },
   {
     "cmd": [],
-    "name": "launch/collect.7.process results",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [],
-    "name": "launch/collect.7.process results.always pass",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@3@@@"
-    ]
-  },
-  {
-    "cmd": [],
     "name": "launch/collect.8",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@",
@@ -886,13 +816,6 @@
     ]
   },
   {
-    "cmd": [],
-    "name": "launch/collect.8.launch",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
     "cmd": [
       "[CACHE]/swarming_client/swarming",
       "collect",
@@ -917,20 +840,6 @@
   },
   {
     "cmd": [],
-    "name": "launch/collect.8.process results",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [],
-    "name": "launch/collect.8.process results.always pass",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@3@@@"
-    ]
-  },
-  {
-    "cmd": [],
     "name": "launch/collect.9",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@",
@@ -938,13 +847,6 @@
     ]
   },
   {
-    "cmd": [],
-    "name": "launch/collect.9.launch",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
     "cmd": [
       "[CACHE]/swarming_client/swarming",
       "collect",
@@ -1019,13 +921,6 @@
     ]
   },
   {
-    "cmd": [],
-    "name": "launch/collect.10.launch",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
     "cmd": [
       "[CACHE]/swarming_client/swarming",
       "collect",
diff --git a/recipe_modules/swarming_retry/examples/full.expected/last_task_max_attempts_high.json b/recipe_modules/swarming_retry/examples/full.expected/last_task_max_attempts_high.json
index 0c90e7f..d01d73b 100644
--- a/recipe_modules/swarming_retry/examples/full.expected/last_task_max_attempts_high.json
+++ b/recipe_modules/swarming_retry/examples/full.expected/last_task_max_attempts_high.json
@@ -124,7 +124,7 @@
       "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_SUMMARY_TEXT@something failed@@@",
       "@@@STEP_LOG_LINE@exception@Traceback (most recent call last):@@@",
-      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 413, in _launch_and_collect@@@",
+      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 411, in _launch_and_collect@@@",
       "@@@STEP_LOG_LINE@exception@    task.process_result()@@@",
       "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/examples/full.py\", line 130, in process_result@@@",
       "@@@STEP_LOG_LINE@exception@    raise self._api.step.StepFailure('something failed')@@@",
@@ -233,7 +233,7 @@
       "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_SUMMARY_TEXT@something failed@@@",
       "@@@STEP_LOG_LINE@exception@Traceback (most recent call last):@@@",
-      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 413, in _launch_and_collect@@@",
+      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 411, in _launch_and_collect@@@",
       "@@@STEP_LOG_LINE@exception@    task.process_result()@@@",
       "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/examples/full.py\", line 130, in process_result@@@",
       "@@@STEP_LOG_LINE@exception@    raise self._api.step.StepFailure('something failed')@@@",
@@ -342,7 +342,7 @@
       "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_SUMMARY_TEXT@something failed@@@",
       "@@@STEP_LOG_LINE@exception@Traceback (most recent call last):@@@",
-      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 413, in _launch_and_collect@@@",
+      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 411, in _launch_and_collect@@@",
       "@@@STEP_LOG_LINE@exception@    task.process_result()@@@",
       "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/examples/full.py\", line 130, in process_result@@@",
       "@@@STEP_LOG_LINE@exception@    raise self._api.step.StepFailure('something failed')@@@",
@@ -451,7 +451,7 @@
       "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_SUMMARY_TEXT@something failed@@@",
       "@@@STEP_LOG_LINE@exception@Traceback (most recent call last):@@@",
-      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 413, in _launch_and_collect@@@",
+      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 411, in _launch_and_collect@@@",
       "@@@STEP_LOG_LINE@exception@    task.process_result()@@@",
       "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/examples/full.py\", line 130, in process_result@@@",
       "@@@STEP_LOG_LINE@exception@    raise self._api.step.StepFailure('something failed')@@@",
@@ -560,7 +560,7 @@
       "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_SUMMARY_TEXT@something failed@@@",
       "@@@STEP_LOG_LINE@exception@Traceback (most recent call last):@@@",
-      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 413, in _launch_and_collect@@@",
+      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 411, in _launch_and_collect@@@",
       "@@@STEP_LOG_LINE@exception@    task.process_result()@@@",
       "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/examples/full.py\", line 130, in process_result@@@",
       "@@@STEP_LOG_LINE@exception@    raise self._api.step.StepFailure('something failed')@@@",
diff --git a/recipe_modules/swarming_retry/examples/full.expected/last_task_max_attempts_high_mixed.json b/recipe_modules/swarming_retry/examples/full.expected/last_task_max_attempts_high_mixed.json
index c19875f..daf8cfc 100644
--- a/recipe_modules/swarming_retry/examples/full.expected/last_task_max_attempts_high_mixed.json
+++ b/recipe_modules/swarming_retry/examples/full.expected/last_task_max_attempts_high_mixed.json
@@ -311,7 +311,7 @@
       "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_SUMMARY_TEXT@something failed@@@",
       "@@@STEP_LOG_LINE@exception@Traceback (most recent call last):@@@",
-      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 413, in _launch_and_collect@@@",
+      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 411, in _launch_and_collect@@@",
       "@@@STEP_LOG_LINE@exception@    task.process_result()@@@",
       "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/examples/full.py\", line 130, in process_result@@@",
       "@@@STEP_LOG_LINE@exception@    raise self._api.step.StepFailure('something failed')@@@",
@@ -326,7 +326,7 @@
       "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_SUMMARY_TEXT@something failed@@@",
       "@@@STEP_LOG_LINE@exception@Traceback (most recent call last):@@@",
-      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 413, in _launch_and_collect@@@",
+      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 411, in _launch_and_collect@@@",
       "@@@STEP_LOG_LINE@exception@    task.process_result()@@@",
       "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/examples/full.py\", line 130, in process_result@@@",
       "@@@STEP_LOG_LINE@exception@    raise self._api.step.StepFailure('something failed')@@@",
@@ -341,7 +341,7 @@
       "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_SUMMARY_TEXT@something failed@@@",
       "@@@STEP_LOG_LINE@exception@Traceback (most recent call last):@@@",
-      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 413, in _launch_and_collect@@@",
+      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 411, in _launch_and_collect@@@",
       "@@@STEP_LOG_LINE@exception@    task.process_result()@@@",
       "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/examples/full.py\", line 130, in process_result@@@",
       "@@@STEP_LOG_LINE@exception@    raise self._api.step.StepFailure('something failed')@@@",
@@ -356,7 +356,7 @@
       "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_SUMMARY_TEXT@something failed@@@",
       "@@@STEP_LOG_LINE@exception@Traceback (most recent call last):@@@",
-      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 413, in _launch_and_collect@@@",
+      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 411, in _launch_and_collect@@@",
       "@@@STEP_LOG_LINE@exception@    task.process_result()@@@",
       "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/examples/full.py\", line 130, in process_result@@@",
       "@@@STEP_LOG_LINE@exception@    raise self._api.step.StepFailure('something failed')@@@",
@@ -371,7 +371,7 @@
       "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_SUMMARY_TEXT@something failed@@@",
       "@@@STEP_LOG_LINE@exception@Traceback (most recent call last):@@@",
-      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 413, in _launch_and_collect@@@",
+      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 411, in _launch_and_collect@@@",
       "@@@STEP_LOG_LINE@exception@    task.process_result()@@@",
       "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/examples/full.py\", line 130, in process_result@@@",
       "@@@STEP_LOG_LINE@exception@    raise self._api.step.StepFailure('something failed')@@@",
@@ -386,7 +386,7 @@
       "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_SUMMARY_TEXT@something failed@@@",
       "@@@STEP_LOG_LINE@exception@Traceback (most recent call last):@@@",
-      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 413, in _launch_and_collect@@@",
+      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 411, in _launch_and_collect@@@",
       "@@@STEP_LOG_LINE@exception@    task.process_result()@@@",
       "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/examples/full.py\", line 130, in process_result@@@",
       "@@@STEP_LOG_LINE@exception@    raise self._api.step.StepFailure('something failed')@@@",
@@ -502,7 +502,7 @@
       "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_SUMMARY_TEXT@something failed@@@",
       "@@@STEP_LOG_LINE@exception@Traceback (most recent call last):@@@",
-      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 413, in _launch_and_collect@@@",
+      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 411, in _launch_and_collect@@@",
       "@@@STEP_LOG_LINE@exception@    task.process_result()@@@",
       "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/examples/full.py\", line 130, in process_result@@@",
       "@@@STEP_LOG_LINE@exception@    raise self._api.step.StepFailure('something failed')@@@",
@@ -613,7 +613,7 @@
       "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_SUMMARY_TEXT@something failed@@@",
       "@@@STEP_LOG_LINE@exception@Traceback (most recent call last):@@@",
-      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 413, in _launch_and_collect@@@",
+      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 411, in _launch_and_collect@@@",
       "@@@STEP_LOG_LINE@exception@    task.process_result()@@@",
       "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/examples/full.py\", line 130, in process_result@@@",
       "@@@STEP_LOG_LINE@exception@    raise self._api.step.StepFailure('something failed')@@@",
@@ -724,7 +724,7 @@
       "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_SUMMARY_TEXT@something failed@@@",
       "@@@STEP_LOG_LINE@exception@Traceback (most recent call last):@@@",
-      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 413, in _launch_and_collect@@@",
+      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 411, in _launch_and_collect@@@",
       "@@@STEP_LOG_LINE@exception@    task.process_result()@@@",
       "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/examples/full.py\", line 130, in process_result@@@",
       "@@@STEP_LOG_LINE@exception@    raise self._api.step.StepFailure('something failed')@@@",
@@ -835,7 +835,7 @@
       "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_SUMMARY_TEXT@something failed@@@",
       "@@@STEP_LOG_LINE@exception@Traceback (most recent call last):@@@",
-      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 413, in _launch_and_collect@@@",
+      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 411, in _launch_and_collect@@@",
       "@@@STEP_LOG_LINE@exception@    task.process_result()@@@",
       "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/examples/full.py\", line 130, in process_result@@@",
       "@@@STEP_LOG_LINE@exception@    raise self._api.step.StepFailure('something failed')@@@",
diff --git a/recipe_modules/swarming_retry/examples/full.expected/last_task_max_attempts_low.json b/recipe_modules/swarming_retry/examples/full.expected/last_task_max_attempts_low.json
index dfa2901..d0642b7 100644
--- a/recipe_modules/swarming_retry/examples/full.expected/last_task_max_attempts_low.json
+++ b/recipe_modules/swarming_retry/examples/full.expected/last_task_max_attempts_low.json
@@ -124,7 +124,7 @@
       "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_SUMMARY_TEXT@something failed@@@",
       "@@@STEP_LOG_LINE@exception@Traceback (most recent call last):@@@",
-      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 413, in _launch_and_collect@@@",
+      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 411, in _launch_and_collect@@@",
       "@@@STEP_LOG_LINE@exception@    task.process_result()@@@",
       "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/examples/full.py\", line 130, in process_result@@@",
       "@@@STEP_LOG_LINE@exception@    raise self._api.step.StepFailure('something failed')@@@",
diff --git a/recipe_modules/swarming_retry/examples/full.expected/max_attempts_three.json b/recipe_modules/swarming_retry/examples/full.expected/max_attempts_three.json
index b398132..572dec7 100644
--- a/recipe_modules/swarming_retry/examples/full.expected/max_attempts_three.json
+++ b/recipe_modules/swarming_retry/examples/full.expected/max_attempts_three.json
@@ -124,7 +124,7 @@
       "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_SUMMARY_TEXT@something failed@@@",
       "@@@STEP_LOG_LINE@exception@Traceback (most recent call last):@@@",
-      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 413, in _launch_and_collect@@@",
+      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 411, in _launch_and_collect@@@",
       "@@@STEP_LOG_LINE@exception@    task.process_result()@@@",
       "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/examples/full.py\", line 130, in process_result@@@",
       "@@@STEP_LOG_LINE@exception@    raise self._api.step.StepFailure('something failed')@@@",
@@ -233,7 +233,7 @@
       "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_SUMMARY_TEXT@something failed@@@",
       "@@@STEP_LOG_LINE@exception@Traceback (most recent call last):@@@",
-      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 413, in _launch_and_collect@@@",
+      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 411, in _launch_and_collect@@@",
       "@@@STEP_LOG_LINE@exception@    task.process_result()@@@",
       "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/examples/full.py\", line 130, in process_result@@@",
       "@@@STEP_LOG_LINE@exception@    raise self._api.step.StepFailure('something failed')@@@",
@@ -342,7 +342,7 @@
       "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_SUMMARY_TEXT@something failed@@@",
       "@@@STEP_LOG_LINE@exception@Traceback (most recent call last):@@@",
-      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 413, in _launch_and_collect@@@",
+      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 411, in _launch_and_collect@@@",
       "@@@STEP_LOG_LINE@exception@    task.process_result()@@@",
       "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/examples/full.py\", line 130, in process_result@@@",
       "@@@STEP_LOG_LINE@exception@    raise self._api.step.StepFailure('something failed')@@@",
diff --git a/recipe_modules/swarming_retry/examples/full.expected/raising_process_results.json b/recipe_modules/swarming_retry/examples/full.expected/raising_process_results.json
index ed5908d..5b275aa 100644
--- a/recipe_modules/swarming_retry/examples/full.expected/raising_process_results.json
+++ b/recipe_modules/swarming_retry/examples/full.expected/raising_process_results.json
@@ -124,7 +124,7 @@
       "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_SUMMARY_TEXT@something failed@@@",
       "@@@STEP_LOG_LINE@exception@Traceback (most recent call last):@@@",
-      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 413, in _launch_and_collect@@@",
+      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 411, in _launch_and_collect@@@",
       "@@@STEP_LOG_LINE@exception@    task.process_result()@@@",
       "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/examples/full.py\", line 130, in process_result@@@",
       "@@@STEP_LOG_LINE@exception@    raise self._api.step.StepFailure('something failed')@@@",
@@ -233,7 +233,7 @@
       "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_SUMMARY_TEXT@something failed@@@",
       "@@@STEP_LOG_LINE@exception@Traceback (most recent call last):@@@",
-      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 413, in _launch_and_collect@@@",
+      "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/api.py\", line 411, in _launch_and_collect@@@",
       "@@@STEP_LOG_LINE@exception@    task.process_result()@@@",
       "@@@STEP_LOG_LINE@exception@  File \"RECIPE_REPO[fuchsia]/recipe_modules/swarming_retry/examples/full.py\", line 130, in process_result@@@",
       "@@@STEP_LOG_LINE@exception@    raise self._api.step.StepFailure('something failed')@@@",