summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alvarez <pedro.alvarez@codethink.co.uk>2016-03-07 18:32:08 +0000
committerPedro Alvarez <pedro.alvarez@codethink.co.uk>2016-03-27 11:53:02 +0000
commit000365c30ffeb9ec167a324676a25931fc96adef (patch)
tree855a4b3bb7afb5cfdb4be72393e0a2941fbf8d0a
parent90404c48e011f0cf9e715359290ce1b4f7c9e02b (diff)
downloadmorph-000365c30ffeb9ec167a324676a25931fc96adef.tar.gz
Start trying to build
Change-Id: I7889cc73339038859a646e76b037bbd1a866d954
-rw-r--r--gear/client.py50
1 files changed, 49 insertions, 1 deletions
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)