summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-10-31 13:27:54 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-11-11 18:37:07 +0000
commitafaff94f97e00e5cdff0b01358abedbeb54ba52f (patch)
treeb71d4519feb0b000d8d317b10abc2ac7bb44ee48
parenta3a7b33fb92b5a7e6d9a5f029ecf2bc8aa55971c (diff)
downloadbuildstream-afaff94f97e00e5cdff0b01358abedbeb54ba52f.tar.gz
sandbox: Add abstract SandboxREAPI class
This provides a skeleton for sandbox implementations based on the Remote Execution API.
-rw-r--r--src/buildstream/sandbox/_sandboxreapi.py29
-rw-r--r--src/buildstream/sandbox/_sandboxremote.py9
2 files changed, 32 insertions, 6 deletions
diff --git a/src/buildstream/sandbox/_sandboxreapi.py b/src/buildstream/sandbox/_sandboxreapi.py
new file mode 100644
index 000000000..ca7fbd827
--- /dev/null
+++ b/src/buildstream/sandbox/_sandboxreapi.py
@@ -0,0 +1,29 @@
+#
+# Copyright (C) 2018-2019 Bloomberg Finance LP
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+from .sandbox import Sandbox
+
+
+# SandboxREAPI()
+#
+# Abstract class providing a skeleton for sandbox implementations based on
+# the Remote Execution API.
+#
+class SandboxREAPI(Sandbox):
+
+ def _use_cas_based_directory(self):
+ # Always use CasBasedDirectory for REAPI
+ return True
diff --git a/src/buildstream/sandbox/_sandboxremote.py b/src/buildstream/sandbox/_sandboxremote.py
index 2288e7ddb..f62de77c3 100644
--- a/src/buildstream/sandbox/_sandboxremote.py
+++ b/src/buildstream/sandbox/_sandboxremote.py
@@ -29,7 +29,8 @@ import grpc
from .. import utils
from ..node import Node
from .._message import Message, MessageType
-from .sandbox import Sandbox, SandboxCommandError, _SandboxBatch
+from .sandbox import SandboxCommandError, _SandboxBatch
+from ._sandboxreapi import SandboxREAPI
from ..storage._casbaseddirectory import CasBasedDirectory
from .. import _signals
from .._protos.build.bazel.remote.execution.v2 import remote_execution_pb2, remote_execution_pb2_grpc
@@ -50,7 +51,7 @@ class RemoteExecutionSpec(namedtuple('RemoteExecutionSpec', 'exec_service storag
# This isn't really a sandbox, it's a stub which sends all the sources and build
# commands to a remote server and retrieves the results from it.
#
-class SandboxRemote(Sandbox):
+class SandboxRemote(SandboxREAPI):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@@ -521,10 +522,6 @@ class SandboxRemote(Sandbox):
def _create_batch(self, main_group, flags, *, collect=None):
return _SandboxRemoteBatch(self, main_group, flags, collect=collect)
- def _use_cas_based_directory(self):
- # Always use CasBasedDirectory for remote execution
- return True
-
# _SandboxRemoteBatch()
#