Skip to content

Commit 4bb65ba

Browse files
integrated CandidateEvaluation
1 parent 041a4d8 commit 4bb65ba

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

src/orchestrator/orchestrator.py

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
import bugzoo
99
import bugzoo.client
1010
import darjeeling
11+
import darjeeling.outcome
1112
from bugzoo.core.fileline import FileLine, FileLineSet
1213
from darjeeling.problem import Problem
1314
from darjeeling.searcher import Searcher
1415
from darjeeling.candidate import Candidate
1516

16-
1717
__ALL__ = ['Orchestrator', 'OrchestratorState', 'OrchestratorOutcome']
1818

1919
BASE_IMAGE_NAME = 'mars:base'
@@ -48,12 +48,36 @@ class OrchestratorOutcome(Enum):
4848
NO_REPAIR = 2
4949

5050

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+
5175
class Orchestrator(object):
5276
def __init__(self,
5377
url_hulk: str,
5478
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],
5781
callback_error: Callable[[str, str], None]
5882
) -> None:
5983
"""
@@ -81,7 +105,7 @@ def __init__(self,
81105
# adaptation).
82106
self.__lock = threading.Lock()
83107

84-
self.__patches = [] # type: List[Candidate]
108+
self.__patches = [] # type: List[CandidateEvaluation]
85109
self.__state = OrchestratorState.READY_TO_PERTURB
86110
self.__client_hulk = hulk.Client(url_hulk, timeout_connection=120)
87111
self.__client_bugzoo = bugzoo.Client(url_bugzoo, timeout_connection=120)
@@ -172,7 +196,7 @@ def lines(self) -> FileLineSet:
172196
return lines
173197

174198
@property
175-
def patches(self) -> List[darjeeling.candidate.Candidate]:
199+
def patches(self) -> List[CandidateEvaluation]:
176200
"""
177201
A list of all of the patches that have been discovered thus far by
178202
during the search process. If the search process has not begun, an
@@ -339,8 +363,10 @@ def search():
339363
num_candidates=attempts,
340364
time_limit=time_limit)
341365
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)
344370

345371
# FIXME extract log of attempted patches from darjeeling
346372
log = []

0 commit comments

Comments
 (0)