This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch 
valentindavid/remote_execution_configuration_command_line
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit a02fc6963b977da825a69dac388bc8652fdf5634
Author: Valentin David <[email protected]>
AuthorDate: Thu Dec 20 13:02:09 2018 +0100

    Allow selecting user or project configuration for remote execution
---
 buildstream/_context.py          |  3 +++
 buildstream/_frontend/app.py     |  3 ++-
 buildstream/_frontend/cli.py     |  3 +++
 buildstream/_project.py          | 19 +++++++++++++++----
 tests/completions/completions.py |  1 +
 5 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/buildstream/_context.py b/buildstream/_context.py
index c62755c..b3c01f7 100644
--- a/buildstream/_context.py
+++ b/buildstream/_context.py
@@ -121,6 +121,9 @@ class Context():
         # Whether or not to attempt to pull build trees globally
         self.pull_buildtrees = None
 
+        # Which configured remote execution server to use
+        self.remote_execution = 'any'
+
         # Boolean, whether we double-check with the user that they meant to
         # remove a workspace directory.
         self.prompt_workspace_close_remove_dir = None
diff --git a/buildstream/_frontend/app.py b/buildstream/_frontend/app.py
index 96e3c60..66bb975 100644
--- a/buildstream/_frontend/app.py
+++ b/buildstream/_frontend/app.py
@@ -183,7 +183,8 @@ class App():
             'builders': 'sched_builders',
             'pushers': 'sched_pushers',
             'network_retries': 'sched_network_retries',
-            'pull_buildtrees': 'pull_buildtrees'
+            'pull_buildtrees': 'pull_buildtrees',
+            'remote_execution': 'remote_execution'
         }
         for cli_option, context_attr in override_map.items():
             option_value = self._main_options.get(cli_option)
diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py
index 29fc4cf..1d19408 100644
--- a/buildstream/_frontend/cli.py
+++ b/buildstream/_frontend/cli.py
@@ -239,6 +239,9 @@ def print_version(ctx, param, value):
               help="The mirror to fetch from first, before attempting other 
mirrors")
 @click.option('--pull-buildtrees', is_flag=True, default=None,
               help="Include an element's build tree when pulling remote 
element artifacts")
[email protected]('--remote-execution', default='any',
+              type=click.Choice(['any', 'user', 'project', 'none']),
+              help='Select which remote execution server to use')
 @click.pass_context
 def cli(context, **kwargs):
     """Build and manipulate BuildStream projects
diff --git a/buildstream/_project.py b/buildstream/_project.py
index 1492fde..fc3fb50 100644
--- a/buildstream/_project.py
+++ b/buildstream/_project.py
@@ -511,12 +511,23 @@ class Project():
         override_specs = SandboxRemote.specs_from_config_node(
             self._context.get_overrides(self.name), self.directory)
 
-        if override_specs is not None:
-            self.remote_execution_specs = override_specs
-        elif project_specs is not None:
+        if self._context.remote_execution == 'any':
+            if override_specs is not None:
+                self.remote_execution_specs = override_specs
+            elif project_specs is not None:
+                self.remote_execution_specs = project_specs
+            else:
+                self.remote_execution_specs = 
self._context.remote_execution_specs
+        elif self._context.remote_execution == 'user':
+            if override_specs is not None:
+                self.remote_execution_specs = override_specs
+            else:
+                self.remote_execution_specs = 
self._context.remote_execution_specs
+        elif self._context.remote_execution == 'project':
             self.remote_execution_specs = project_specs
         else:
-            self.remote_execution_specs = self._context.remote_execution_specs
+            assert self._context.remote_execution == 'none'
+            self.remote_execution_specs = None
 
         # Load sandbox environment variables
         self.base_environment = _yaml.node_get(config, Mapping, 'environment')
diff --git a/tests/completions/completions.py b/tests/completions/completions.py
index 372ed78..3f6a4d4 100644
--- a/tests/completions/completions.py
+++ b/tests/completions/completions.py
@@ -42,6 +42,7 @@ MAIN_OPTIONS = [
     "--option ",
     "--on-error ",
     "--pull-buildtrees ",
+    "--remote-execution ",
     "--pushers ",
     "--strict ",
     "--verbose ",

Reply via email to