summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2017-08-01 14:22:02 +0100
committerJürg Billeter <j@bitron.ch>2017-08-02 09:53:20 +0100
commit64a951b4bbf0d4184ed07ea068ec16d04d7cf4ba (patch)
tree613910bfea4180721ae039295b2f4e514efb8da8
parent94560778e68f399655a7417559e0a18077a7ac57 (diff)
downloadbuildstream-64a951b4bbf0d4184ed07ea068ec16d04d7cf4ba.tar.gz
Add initial `bst pull` command
-rw-r--r--buildstream/_frontend/main.py31
-rw-r--r--buildstream/_pipeline.py38
-rw-r--r--buildstream/element.py3
3 files changed, 71 insertions, 1 deletions
diff --git a/buildstream/_frontend/main.py b/buildstream/_frontend/main.py
index aaf625e01..ab3c81501 100644
--- a/buildstream/_frontend/main.py
+++ b/buildstream/_frontend/main.py
@@ -209,6 +209,37 @@ def track(app, target, variant, deps, except_):
##################################################################
+# Pull Command #
+##################################################################
+@cli.command(short_help="Pull a built artifact")
+@click.option('--variant',
+ help='A variant of the specified target')
+@click.option('--deps', '-d', default='none',
+ type=click.Choice(['none', 'all']),
+ help='The dependencies to fetch (default: plan)')
+@click.argument('target')
+@click.pass_obj
+def pull(app, target, variant, deps):
+ """Pull a built artifact from the configured remote artifact cache.
+
+ Specify `--deps` to control which artifacts to pull:
+
+ \b
+ none: No dependencies, just the element itself
+ all: All dependencies
+ """
+ app.initialize(target, variant)
+ try:
+ to_pull = app.pipeline.deps_elements(deps)
+ app.pipeline.pull(app.scheduler, to_pull)
+ click.echo("")
+ except _BstError as e:
+ click.echo("")
+ click.echo("ERROR: {}".format(e))
+ sys.exit(-1)
+
+
+##################################################################
# Push Command #
##################################################################
@cli.command(short_help="Push a built artifact")
diff --git a/buildstream/_pipeline.py b/buildstream/_pipeline.py
index dc71afa1f..1e2ffcb03 100644
--- a/buildstream/_pipeline.py
+++ b/buildstream/_pipeline.py
@@ -630,6 +630,44 @@ class Pipeline():
self.open_workspace(scheduler, workspace_dir, source_index, no_checkout,
track, False)
+ # pull()
+ #
+ # Pulls elements from the pipeline
+ #
+ # Args:
+ # scheduler (Scheduler): The scheduler to run this pipeline on
+ # elements (list): List of elements to pull
+ #
+ def pull(self, scheduler, elements):
+
+ if not self.artifacts.can_fetch():
+ self.message(self.target, MessageType.FAIL, "Not configured for pulling artifacts")
+
+ plan = elements
+ self.assert_consistent(plan)
+ self.session_elements = len(plan)
+
+ pull = PullQueue()
+ pull.enqueue(plan)
+ queues = [pull]
+
+ self.message(self.target, MessageType.START, "Pulling {} artifacts".format(len(plan)))
+ elapsed, status = scheduler.run(queues)
+ pulled = len(pull.processed_elements)
+
+ if status == SchedStatus.ERROR:
+ self.message(self.target, MessageType.FAIL, "Pull failed", elapsed=elapsed)
+ raise PipelineError()
+ elif status == SchedStatus.TERMINATED:
+ self.message(self.target, MessageType.WARN,
+ "Terminated after pulling {} elements".format(pulled),
+ elapsed=elapsed)
+ raise PipelineError()
+ else:
+ self.message(self.target, MessageType.SUCCESS,
+ "Pulled {} complete".format(pulled),
+ elapsed=elapsed)
+
# push()
#
# Pushes elements in the pipeline
diff --git a/buildstream/element.py b/buildstream/element.py
index 84cd9a577..09ead8264 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -1149,7 +1149,8 @@ class Element(Plugin):
# (bool): True if this element should not be pushed
#
def _skip_push(self):
- self._assert_cached()
+ if not self._cached(recalculate=None):
+ return True
# Do not push tained artifact
if self._tainted():