summaryrefslogtreecommitdiff
path: root/src/buildstream/_project.py
diff options
context:
space:
mode:
authorJames Ennis <james.ennis@codethink.co.uk>2019-08-15 09:27:02 +0100
committerJames Ennis <james.ennis@codethink.co.uk>2019-08-27 12:12:13 +0100
commitef2015096ac039f541be5401a39cf25477afefca (patch)
treec13530df2af6251023c0b7e828819f2102a7ee90 /src/buildstream/_project.py
parenta8d68c9d313252454a9f92e00b8758a0d2d674ef (diff)
downloadbuildstream-ef2015096ac039f541be5401a39cf25477afefca.tar.gz
Load artifact refs the same way we load element names
Diffstat (limited to 'src/buildstream/_project.py')
-rw-r--r--src/buildstream/_project.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/buildstream/_project.py b/src/buildstream/_project.py
index d3bbc3939..00beebfab 100644
--- a/src/buildstream/_project.py
+++ b/src/buildstream/_project.py
@@ -463,6 +463,38 @@ class Project():
return elements
+ # load_artifacts()
+ #
+ # Loads artifacts from target artifact refs
+ #
+ # Args:
+ # targets (list): Target artifact refs
+ #
+ # Returns:
+ # (list): A list of loaded ArtifactElement
+ #
+ def load_artifacts(self, targets):
+ with self._context.messenger.simple_task("Loading artifacts") as task:
+ # XXX: Here, we are explicitly checking for refs in the artifactdir
+ # for two reasons:
+ # 1. The Project, or the Context, do not currently have
+ # access to the ArtifactCache
+ # 2. The ArtifactCache.contains() method expects an Element
+ # and a key, not a ref.
+ #
+ artifactdir = self._context.artifactdir
+ artifacts = []
+ for ref in targets:
+ if not os.path.exists(os.path.join(artifactdir, ref)):
+ raise LoadError("{}\nis not present in the artifact cache ({})".format(ref, artifactdir),
+ LoadErrorReason.MISSING_FILE)
+
+ artifacts.append(ArtifactElement._new_from_artifact_ref(ref, self._context, task))
+
+ ArtifactElement._clear_artifact_refs_cache()
+
+ return artifacts
+
# ensure_fully_loaded()
#
# Ensure project has finished loading. At first initialization, a