|
8 | 8 | import bugzoo
|
9 | 9 | import bugzoo.client
|
10 | 10 | import darjeeling
|
| 11 | +import darjeeling.outcome |
11 | 12 | from bugzoo.core.fileline import FileLine, FileLineSet
|
12 | 13 | from darjeeling.problem import Problem
|
13 | 14 | from darjeeling.searcher import Searcher
|
14 | 15 | from darjeeling.candidate import Candidate
|
15 | 16 |
|
16 |
| - |
17 | 17 | __ALL__ = ['Orchestrator', 'OrchestratorState', 'OrchestratorOutcome']
|
18 | 18 |
|
19 | 19 | BASE_IMAGE_NAME = 'mars:base'
|
@@ -48,12 +48,36 @@ class OrchestratorOutcome(Enum):
|
48 | 48 | NO_REPAIR = 2
|
49 | 49 |
|
50 | 50 |
|
| 51 | +class CandidateEvaluation(object): |
| 52 | + """ |
| 53 | + Describes a candidate patch evaluation. |
| 54 | + """ |
| 55 | + def __init__(self, |
| 56 | + patch: darjeeling.candidate.Candidate, |
| 57 | + outcome: darjeeling.outcome.CandidateOutcome |
| 58 | + ) -> None: |
| 59 | + self.__patch = patch |
| 60 | + self.__outcome = outcome |
| 61 | + |
| 62 | + @property |
| 63 | + def diff(self) -> str: |
| 64 | + return "NOT YET IMPLEMENTED" |
| 65 | + |
| 66 | + @property |
| 67 | + def tests(self) -> darjeeling.outcome.TestOutcomeSet: |
| 68 | + return self.__outcome.tests |
| 69 | + |
| 70 | + @property |
| 71 | + def build(self) -> darjeeling.outcome.BuildOutcome: |
| 72 | + return self.__outcome.build |
| 73 | + |
| 74 | + |
51 | 75 | class Orchestrator(object):
|
52 | 76 | def __init__(self,
|
53 | 77 | url_hulk: str,
|
54 | 78 | url_bugzoo: str,
|
55 |
| - callback_progress: Callable[[Candidate, List[Candidate]], None], |
56 |
| - callback_done: Callable[[List[Candidate], int, OrchestratorOutcome, float], None], |
| 79 | + callback_progress: Callable[[CandidateEvaluation, List[CandidateEvaluation]], None], |
| 80 | + callback_done: Callable[[List[CandidateEvaluation], int, OrchestratorOutcome, float], None], |
57 | 81 | callback_error: Callable[[str, str], None]
|
58 | 82 | ) -> None:
|
59 | 83 | """
|
@@ -81,7 +105,7 @@ def __init__(self,
|
81 | 105 | # adaptation).
|
82 | 106 | self.__lock = threading.Lock()
|
83 | 107 |
|
84 |
| - self.__patches = [] # type: List[Candidate] |
| 108 | + self.__patches = [] # type: List[CandidateEvaluation] |
85 | 109 | self.__state = OrchestratorState.READY_TO_PERTURB
|
86 | 110 | self.__client_hulk = hulk.Client(url_hulk, timeout_connection=120)
|
87 | 111 | self.__client_bugzoo = bugzoo.Client(url_bugzoo, timeout_connection=120)
|
@@ -172,7 +196,7 @@ def lines(self) -> FileLineSet:
|
172 | 196 | return lines
|
173 | 197 |
|
174 | 198 | @property
|
175 |
| - def patches(self) -> List[darjeeling.candidate.Candidate]: |
| 199 | + def patches(self) -> List[CandidateEvaluation]: |
176 | 200 | """
|
177 | 201 | A list of all of the patches that have been discovered thus far by
|
178 | 202 | during the search process. If the search process has not begun, an
|
@@ -339,8 +363,10 @@ def search():
|
339 | 363 | num_candidates=attempts,
|
340 | 364 | time_limit=time_limit)
|
341 | 365 | for patch in self.__searcher:
|
342 |
| - self.__patches.append(patch) |
343 |
| - self.__callback_progress(patch, self.patches) |
| 366 | + outcome = self.__searcher.outcomes[patch] |
| 367 | + evaluation = CandidateEvaluation(patch, outcome) |
| 368 | + self.__patches.append(evaluation) |
| 369 | + self.__callback_progress(evaluation, self.patches) |
344 | 370 |
|
345 | 371 | # FIXME extract log of attempted patches from darjeeling
|
346 | 372 | log = []
|
|
0 commit comments