You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ak...@apache.org on 2024/05/23 19:46:16 UTC
(buildstream) 01/01: Drop the directory argument from the sandbox
This is an automated email from the ASF dual-hosted git repository.
akitouni pushed a commit to branch abderrahim/sandbox-directory
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 94205f4d99c860d9a404122c4ce30d37f6b7ed64
Author: Abderrahim Kitouni <ab...@codethink.co.uk>
AuthorDate: Thu May 23 20:41:32 2024 +0100
Drop the directory argument from the sandbox
It is currently unused and produces a bogus info message when using remote execution
---
src/buildstream/element.py | 32 +++++++-------------------------
src/buildstream/sandbox/sandbox.py | 2 +-
2 files changed, 8 insertions(+), 26 deletions(-)
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index f70a3fcb9..8313cf398 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -1406,7 +1406,7 @@ class Element(Plugin):
)
# bst shell and bst artifact checkout require a local sandbox.
- with self.__sandbox(None, config=self.__sandbox_config, allow_remote=False) as sandbox:
+ with self.__sandbox(config=self.__sandbox_config, allow_remote=False) as sandbox:
# Configure always comes first, and we need it.
self.__configure_sandbox(sandbox)
@@ -1660,11 +1660,8 @@ class Element(Plugin):
# Explicitly clean it up, keep the build dir around if exceptions are raised
os.makedirs(context.builddir, exist_ok=True)
- with utils._tempdir(
- prefix="{}-".format(self.normal_name), dir=context.builddir
- ) as rootdir, self.__sandbox(
- rootdir, output_file, output_file, self.__sandbox_config
- ) as sandbox: # noqa
+ with self.__sandbox(output_file, output_file, self.__sandbox_config
+ ) as sandbox:
# Ensure that the plugin does not run commands if it said that it wouldn't
#
@@ -2800,7 +2797,7 @@ class Element(Plugin):
# (Sandbox): A usable sandbox
#
@contextmanager
- def __sandbox(self, directory, stdout=None, stderr=None, config=None, allow_remote=True):
+ def __sandbox(self, stdout=None, stderr=None, config=None, allow_remote=True):
context = self._get_context()
project = self._get_project()
platform = context.platform
@@ -2810,14 +2807,11 @@ class Element(Plugin):
else:
output_node_properties = None
- if directory is not None and allow_remote and context.remote_execution_specs:
-
- self.info("Using a remote sandbox for artifact {} with directory '{}'".format(self.name, directory))
-
+ if allow_remote and context.remote_execution_specs:
+ self.info("Using a remote sandbox for artifact {}".format(self.name))
with SandboxRemote(
context,
project,
- directory,
plugin=self,
stdout=stdout,
stderr=stderr,
@@ -2826,13 +2820,12 @@ class Element(Plugin):
) as sandbox:
yield sandbox
- elif directory is not None and os.path.exists(directory):
+ else:
platform = context.platform
sandbox = platform.create_sandbox(
context,
project,
- directory,
plugin=self,
stdout=stdout,
stderr=stderr,
@@ -2842,17 +2835,6 @@ class Element(Plugin):
with sandbox:
yield sandbox
- else:
- os.makedirs(context.builddir, exist_ok=True)
-
- # Recursive contextmanager...
- with utils._tempdir(
- prefix="{}-".format(self.normal_name), dir=context.builddir
- ) as rootdir, self.__sandbox(
- rootdir, stdout=stdout, stderr=stderr, config=config, allow_remote=allow_remote
- ) as sandbox:
- yield sandbox
-
# __initialize_from_yaml()
#
# Normal element initialization procedure.
diff --git a/src/buildstream/sandbox/sandbox.py b/src/buildstream/sandbox/sandbox.py
index ffae82335..d5be1aab3 100644
--- a/src/buildstream/sandbox/sandbox.py
+++ b/src/buildstream/sandbox/sandbox.py
@@ -77,7 +77,7 @@ class Sandbox:
# Minimal set of devices for the sandbox
_dummy_reasons = [] # type: List[str]
- def __init__(self, context: "Context", project: "Project", directory: str, **kwargs):
+ def __init__(self, context: "Context", project: "Project", **kwargs):
self.__context = context
self.__project = project
self.__directories = [] # type: List[str]