You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by gi...@apache.org on 2020/12/29 13:18:47 UTC

[buildstream] 04/09: artifactcache.py: Allow ArtifactCache to handle pulling/pushing refs

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

github-bot pushed a commit to branch jennis/push_pull_artifacts
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit f609f0a6debd19658498d11cfa13bd597e8900b1
Author: James Ennis <ja...@codethink.com>
AuthorDate: Tue Jan 15 11:17:52 2019 +0000

    artifactcache.py: Allow ArtifactCache to handle pulling/pushing refs
    
    With the addition of the artifact subcommands, which are able to
    process artifact refs, we should not have to rely on CASCache
    internals to handle artifacts. This commit ensures that the
    pulling/pushing of elements (and their cache keys) is handled
    by ArtifactCache.
---
 buildstream/_artifactcache/artifactcache.py | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/buildstream/_artifactcache/artifactcache.py b/buildstream/_artifactcache/artifactcache.py
index af27a1e..383d173 100644
--- a/buildstream/_artifactcache/artifactcache.py
+++ b/buildstream/_artifactcache/artifactcache.py
@@ -661,7 +661,7 @@ class ArtifactCache():
                 display_key = element._get_brief_display_key()
                 element.status("Pulling artifact {} <- {}".format(display_key, remote.spec.url))
 
-                if self.cas.pull(ref, remote, progress=progress, subdir=subdir, excluded_subdirs=excluded_subdirs):
+                if self.pull_ref(ref, remote, progress=progress, subdir=subdir, excluded_subdirs=excluded_subdirs):
                     element.info("Pulled artifact {} <- {}".format(display_key, remote.spec.url))
                     if subdir:
                         # Attempt to extract subdir into artifact extract dir if it already exists
@@ -681,6 +681,22 @@ class ArtifactCache():
 
         return False
 
+    # pull_ref():
+    #
+    # Pull artifact from one of the configured remote repositories.
+    #
+    # Args:
+    #     ref (str): The ref to pull
+    #     progress (callable): The progress callback, if any
+    #     subdir (str): The optional specific subdir to pull
+    #     excluded_subdirs (list): The optional list of subdirs to not pull
+    #
+    # Returns:
+    #   (bool): True if pull was successful, False if artifact was not available
+    #
+    def pull_ref(self, ref, remote, *, progress=None, subdir=None, excluded_subdirs=None):
+        return self.cas.pull(ref, remote, progress=progress, subdir=subdir, excluded_subdirs=excluded_subdirs)
+
     # pull_tree():
     #
     # Pull a single Tree rather than an artifact.