juergbi commented on code in PR #2129:
URL: https://github.com/apache/buildstream/pull/2129#discussion_r4105490397


##########
src/buildstream/_stream.py:
##########
@@ -916,6 +901,74 @@ def artifact_delete(self, targets, *, 
selection=_PipelineSelection.NONE):
         if not ref_removed:
             self._context.messenger.info("No artifacts were removed")
 
+
+    # buildtree_checkout()
+    #
+    # Checkout target buildtree artifact to the specified location
+    #
+    # Args:
+    #    target: Target to checkout
+    #    location: Location to checkout the artifact to
+    #    force: Whether files can be overwritten if necessary
+    #    hardlinks: Whether checking out files hardlinked to
+    #               their artifacts is acceptable
+    #    tar: If true, a tarball from the artifact contents will
+    #         be created, otherwise the file tree of the artifact
+    #         will be placed at the given location. If true and
+    #         location is '-', the tarball will be dumped on the
+    #         standard output.
+    #    artifact_remotes: Artifact cache remotes specified on the commmand 
line
+    #    ignore_project_artifact_remotes: Whether to ignore artifact remotes 
specified by projects
+    #
+    def buildtree_checkout(
+        self,
+        target: str,
+        *,
+        location: Optional[str] = None,
+        buildroot: bool = False,
+        force: bool = False,
+        hardlinks: bool = False,
+        compression: str = "",
+        tar: bool = False,
+        artifact_remotes: Iterable[RemoteSpec] = (),
+        ignore_project_artifact_remotes: bool = False,
+    ):
+
+        elements = self._load(
+            (target,),
+            selection=_PipelineSelection.NONE,
+            load_artifacts=True,
+            attempt_artifact_metadata=True,
+            connect_artifact_cache=True,
+            artifact_remotes=artifact_remotes,
+            ignore_project_artifact_remotes=ignore_project_artifact_remotes,
+        )
+
+        # self.targets contains a list of the loaded target objects
+        # if we specify --deps build, Stream._load() will return a list
+        # of build dependency objects, however, we need to prepare a sandbox
+        # with the target (which has had its appropriate dependencies loaded)
+        element: Element = self.targets[0]
+
+        self._check_location_writable(location, force=force, tar=tar)
+
+        # Check whether the required elements are cached, and then
+        # try to pull them if they are not already cached.
+        #
+        self.query_cache(elements)
+        self._pull_missing_artifacts(elements)

Review Comment:
   Regarding Abderrahim's second paragraph, for `bst shell --use-buildtree` we 
mention "pull-buildtrees configuration is needed if the buildtree is not 
available locally" in the help text and don't override the `pull-buildtrees` 
configuration. We could argue which behavior makes more sense but, at least for 
this PR, buildtree checkout should match `bst shell --use-buildtree`.
   
   I.e., no need to add a `pull-buildtrees` configuration override, but we 
should at least mention it somewhere in the help text or in the error message 
when the buildtree exists but is not cached (see my other comment for the 
distinction).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to