diff options
author | Jürg Billeter <j@bitron.ch> | 2017-08-01 14:22:02 +0100 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2017-08-02 11:30:29 +0100 |
commit | 3f0417c9ffbe2e6f86ae180169908e92f9622133 (patch) | |
tree | dfb935dcb8ac3c693582457c3fee009368916926 | |
parent | b86c9a5cbff7335aa45e0a012e82026c41fde033 (diff) | |
download | buildstream-bst-pull.tar.gz |
Add initial `bst pull` commandbst-pull
-rw-r--r-- | buildstream/_frontend/main.py | 31 | ||||
-rw-r--r-- | buildstream/_pipeline.py | 38 |
2 files changed, 69 insertions, 0 deletions
diff --git a/buildstream/_frontend/main.py b/buildstream/_frontend/main.py index 43cdc431f..4eb785107 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: none)') +@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 8092340fc..3c65e0967 100644 --- a/buildstream/_pipeline.py +++ b/buildstream/_pipeline.py @@ -631,6 +631,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 |