juergbi commented on code in PR #2129:
URL: https://github.com/apache/buildstream/pull/2129#discussion_r4105435777
##########
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)
+
+ self._check_buildtree(element)
+
+ try:
+ artifact = element._get_artifact()
+ virdir = artifact.get_buildroot() if buildroot else
artifact.get_buildtree()
Review Comment:
There is a difference between `_buildtree_exists()` and
`_cached_buildtree()`. The former means that the artifact was originally
created with a buildtree but it's still possible that the buildtree is not
cached even if the artifact is otherwise cached (as pulling/pushing buildtrees
is configurable). The cached checks seem to be missing. Take a look at the end
of `Stream.shell()` for the possible cases and error messages.
--
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]