Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 class Attempt(object): | 6 class Attempt(object): |
| 7 """One run of all the Quests on a Change. | 7 """One run of all the Quests on a Change. |
| 8 | 8 |
| 9 Each Change should execute at least one Attempt. The user can request more | 9 Each Change should execute at least one Attempt. The user can request more |
| 10 runs, which creates additional Attempts. The bisect algorithm may also create | 10 runs, which creates additional Attempts. The bisect algorithm may also create |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 return self._last_execution.failed or ( | 41 return self._last_execution.failed or ( |
| 42 self._last_execution.completed and | 42 self._last_execution.completed and |
| 43 len(self._quests) == len(self._executions)) | 43 len(self._quests) == len(self._executions)) |
| 44 | 44 |
| 45 @property | 45 @property |
| 46 def result_values(self): | 46 def result_values(self): |
| 47 assert self.completed | 47 assert self.completed |
| 48 return dict((quest, execution.result_values) | 48 return dict((quest, execution.result_values) |
| 49 for quest, execution in zip(self._quests, self._executions)) | 49 for quest, execution in zip(self._quests, self._executions)) |
| 50 | 50 |
| 51 def AsDictPerQuest(self): | |
|
dtu
2017/08/21 23:52:52
nit: put methods after properties
dtu
2017/08/21 23:52:52
It would be more consistent to provide an Attempt.
shatch
2017/08/22 01:23:55
Done.
shatch
2017/08/22 01:23:55
Done.
| |
| 52 return dict((quest, execution.AsDict()) | |
| 53 for quest, execution in zip(self._quests, self._executions)) | |
| 54 | |
| 51 @property | 55 @property |
| 52 def _last_execution(self): | 56 def _last_execution(self): |
| 53 return self._executions[-1] | 57 return self._executions[-1] |
| 54 | 58 |
| 55 def ScheduleWork(self): | 59 def ScheduleWork(self): |
| 56 """Run this Attempt and update its status.""" | 60 """Run this Attempt and update its status.""" |
| 57 assert not self.completed | 61 assert not self.completed |
| 58 | 62 |
| 59 self._StartNextExecutionIfReady() | 63 self._StartNextExecutionIfReady() |
| 60 self._Poll() | 64 self._Poll() |
| 61 | 65 |
| 62 def _Poll(self): | 66 def _Poll(self): |
| 63 """Update the Attempt status.""" | 67 """Update the Attempt status.""" |
| 64 self._last_execution.Poll() | 68 self._last_execution.Poll() |
| 65 | 69 |
| 66 def _StartNextExecutionIfReady(self): | 70 def _StartNextExecutionIfReady(self): |
| 67 can_start_next_execution = not self._executions or ( | 71 can_start_next_execution = not self._executions or ( |
| 68 self._last_execution.completed and not self.completed) | 72 self._last_execution.completed and not self.completed) |
| 69 if not can_start_next_execution: | 73 if not can_start_next_execution: |
| 70 return | 74 return |
| 71 | 75 |
| 72 next_quest = self._quests[len(self._executions)] | 76 next_quest = self._quests[len(self._executions)] |
| 73 if self._executions: | 77 if self._executions: |
| 74 arguments = self._last_execution.result_arguments | 78 arguments = self._last_execution.result_arguments |
| 75 else: | 79 else: |
| 76 arguments = {'change': self._change} | 80 arguments = {'change': self._change} |
| 77 | 81 |
| 78 self._executions.append(next_quest.Start(**arguments)) | 82 self._executions.append(next_quest.Start(**arguments)) |
| OLD | NEW |