From 000365c30ffeb9ec167a324676a25931fc96adef Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Mon, 7 Mar 2016 18:32:08 +0000 Subject: Start trying to build Change-Id: I7889cc73339038859a646e76b037bbd1a866d954 --- gear/client.py | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/gear/client.py b/gear/client.py index ad1b0fc4..34cfacf9 100644 --- a/gear/client.py +++ b/gear/client.py @@ -75,6 +75,43 @@ class theController(): components) return [a for a in artifacts if is_ready_to_build(a)] + def _queue_worker_builds(self, artifacts): + '''Send a set of chunks to the WorkerBuildQueuer class for building.''' + distbuild.crash_point() + + logging.debug('Queuing more worker-builds to run') + while len(artifacts) > 0: + artifact = artifacts.pop() + + logging.debug( + 'Requesting worker-build of %s (%s)' % + (artifact.name, artifact.cache_key)) + # TODO: launch build client + artifact.state = BUILDING + if artifact.kind == 'chunk': + # Chunk artifacts are not built independently + # so when we're building any chunk artifact + # we're also building all the chunk artifacts + # in this source + same_chunk_artifacts = [a for a in artifacts + if a.cache_key == artifact.cache_key] + for a in same_chunk_artifacts: + a.state = BUILDING + artifacts.remove(a) + + def _find_artifact(self, cache_key): + artifacts, _ = map_build_graph(self._artifact, lambda a: a, + self._components) + wanted = [a for a in artifacts if a.cache_key == cache_key] + if wanted: + return wanted[0] + else: + return None + + + def controller._mark_artifact_as_built(self, packet) + artifacts = _find_artifacts(packet[-1]) + # Do something like _maybe_check_result_and_queue_more_builds class BuildGraphClient(gear.Client): @@ -111,6 +148,17 @@ class BuildGraphClient(gear.Client): +class BuilderClient(gear.Client): + def __init__(self, controller): + super(BuilderClient, self).__init__() + self.controller = controller + self.finished = False + + def handleWorkComplete(self, packet): + job = super(BuilderClient, self).handleWorkComplete(packet) + print "workcomplete" + self.controller._mark_artifact_as_built(packet) + return job controller = theController() @@ -139,4 +187,4 @@ while True: if controller.artifact != None: to_build = controller.find_artifacts_that_are_ready_to_build(controller.artifact) print to_build - exit(0) + controller._queue_worker_builds(to_build) -- cgit v1.2.1