Skip to content

Commit

Permalink
integrated CandidateEvaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisTimperley committed Apr 27, 2018
1 parent 041a4d8 commit 4bb65ba
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions src/orchestrator/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
import bugzoo
import bugzoo.client
import darjeeling
import darjeeling.outcome
from bugzoo.core.fileline import FileLine, FileLineSet
from darjeeling.problem import Problem
from darjeeling.searcher import Searcher
from darjeeling.candidate import Candidate


__ALL__ = ['Orchestrator', 'OrchestratorState', 'OrchestratorOutcome']

BASE_IMAGE_NAME = 'mars:base'
Expand Down Expand Up @@ -48,12 +48,36 @@ class OrchestratorOutcome(Enum):
NO_REPAIR = 2


class CandidateEvaluation(object):
"""
Describes a candidate patch evaluation.
"""
def __init__(self,
patch: darjeeling.candidate.Candidate,
outcome: darjeeling.outcome.CandidateOutcome
) -> None:
self.__patch = patch
self.__outcome = outcome

@property
def diff(self) -> str:
return "NOT YET IMPLEMENTED"

@property
def tests(self) -> darjeeling.outcome.TestOutcomeSet:
return self.__outcome.tests

@property
def build(self) -> darjeeling.outcome.BuildOutcome:
return self.__outcome.build


class Orchestrator(object):
def __init__(self,
url_hulk: str,
url_bugzoo: str,
callback_progress: Callable[[Candidate, List[Candidate]], None],
callback_done: Callable[[List[Candidate], int, OrchestratorOutcome, float], None],
callback_progress: Callable[[CandidateEvaluation, List[CandidateEvaluation]], None],
callback_done: Callable[[List[CandidateEvaluation], int, OrchestratorOutcome, float], None],
callback_error: Callable[[str, str], None]
) -> None:
"""
Expand Down Expand Up @@ -81,7 +105,7 @@ def __init__(self,
# adaptation).
self.__lock = threading.Lock()

self.__patches = [] # type: List[Candidate]
self.__patches = [] # type: List[CandidateEvaluation]
self.__state = OrchestratorState.READY_TO_PERTURB
self.__client_hulk = hulk.Client(url_hulk, timeout_connection=120)
self.__client_bugzoo = bugzoo.Client(url_bugzoo, timeout_connection=120)
Expand Down Expand Up @@ -172,7 +196,7 @@ def lines(self) -> FileLineSet:
return lines

@property
def patches(self) -> List[darjeeling.candidate.Candidate]:
def patches(self) -> List[CandidateEvaluation]:
"""
A list of all of the patches that have been discovered thus far by
during the search process. If the search process has not begun, an
Expand Down Expand Up @@ -339,8 +363,10 @@ def search():
num_candidates=attempts,
time_limit=time_limit)
for patch in self.__searcher:
self.__patches.append(patch)
self.__callback_progress(patch, self.patches)
outcome = self.__searcher.outcomes[patch]
evaluation = CandidateEvaluation(patch, outcome)
self.__patches.append(evaluation)
self.__callback_progress(evaluation, self.patches)

# FIXME extract log of attempted patches from darjeeling
log = []
Expand Down

0 comments on commit 4bb65ba

Please sign in to comment.