in src/buildstream/_artifactcache.py [0:0]
def pull(self, element, key, *, pull_buildtrees=False):
artifact_digest = None
display_key = key[: self.context.log_key_length]
project = element._get_project()
artifact_name = element.get_artifact_name(key=key)
uri = REMOTE_ASSET_ARTIFACT_URN_TEMPLATE.format(artifact_name)
index_remotes, storage_remotes = self.get_remotes(project.name, False)
errors = []
# Start by pulling our artifact proto, so that we know which
# blobs to pull
for remote in index_remotes:
remote.init()
try:
element.status("Pulling artifact {} <- {}".format(display_key, remote))
response = remote.fetch_blob([uri])
if response:
artifact_digest = response.blob_digest
break
element.info("Remote ({}) does not have artifact {} cached".format(remote, display_key))
except AssetCacheError as e:
element.warn("Could not pull from remote {}: {}".format(remote, e))
errors.append(e)
if errors and not artifact_digest:
raise ArtifactError(
"Failed to pull artifact {}".format(display_key),
detail="\n".join(str(e) for e in errors),
temporary=True,
)
# If we don't have an artifact, we can't exactly pull our
# artifact
if not artifact_digest:
return False
errors = []
# If we do, we can pull it!
for remote in storage_remotes:
remote.init()
try:
element.status("Pulling data for artifact {} <- {}".format(display_key, remote))
if self._pull_artifact_storage(element, key, artifact_digest, remote, pull_buildtrees=pull_buildtrees):
element.info("Pulled artifact {} <- {}".format(display_key, remote))
return True
element.info("Remote ({}) does not have artifact {} cached".format(remote, display_key))
except BlobNotFound as e:
# Not all blobs are available on this remote
element.info("Remote cas ({}) does not have blob {} cached".format(remote, e.blob))
continue
except CASError as e:
element.warn("Could not pull from remote {}: {}".format(remote, e))
errors.append(e)
if errors:
raise ArtifactError(
"Failed to pull artifact {}".format(display_key),
detail="\n".join(str(e) for e in errors),
temporary=True,
)
return False