From 1cd7a829d9da1e2d4a9deb284508c8621608078e Mon Sep 17 00:00:00 2001 From: James Ennis Date: Wed, 4 Sep 2019 16:26:33 +0100 Subject: _project.py: Don't only load cached artifacts Previously, before loading artifact refs (ArtifactElements) we were checking that they were cached before loading them. This obviously becomes a problem when we want to try and pull an artifact. This patch removes the check for cached artifacts as we should still be able to contruct an ArtifactElement regardless of whether it is cached or not. --- src/buildstream/_project.py | 5 ----- src/buildstream/_stream.py | 6 ++++-- tests/frontend/buildcheckout.py | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/buildstream/_project.py b/src/buildstream/_project.py index 9cff40868..6cbf3d889 100644 --- a/src/buildstream/_project.py +++ b/src/buildstream/_project.py @@ -478,13 +478,8 @@ class Project(): # 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() diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py index 5d5c355b1..083dc1c43 100644 --- a/src/buildstream/_stream.py +++ b/src/buildstream/_stream.py @@ -414,7 +414,8 @@ class Stream(): selection=selection, ignore_junction_targets=ignore_junction_targets, use_artifact_config=use_config, - artifact_remote_url=remote) + artifact_remote_url=remote, + load_refs=True) if not self._artifacts.has_fetch_remotes(): raise StreamError("No artifact caches available for pulling artifacts") @@ -559,7 +560,8 @@ class Stream(): self._export_artifact(tar, location, compression, target, hardlinks, virdir) except AttributeError as e: raise ArtifactError("Artifact reference '{}' seems to be invalid. " - "Note that an Element name can also be used.".format(artifact))from e + "Note that an Element name can also be used." + .format(artifact._element.get_artifact_name())) from e else: try: with target._prepare_sandbox(scope=scope, directory=None, diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py index 98b179b9e..6281217b7 100644 --- a/tests/frontend/buildcheckout.py +++ b/tests/frontend/buildcheckout.py @@ -358,7 +358,7 @@ def test_build_checkout_invalid_ref(datafiles, cli): checkout_args = ['artifact', 'checkout', '--deps', 'none', '--tar', checkout, non_existent_artifact] result = cli.run(project=project, args=checkout_args) - assert "{}\nis not present in the artifact cache".format(non_existent_artifact) in result.stderr + assert "Artifact reference '{}' seems to be invalid".format(non_existent_artifact) in result.stderr @pytest.mark.datafiles(DATA_DIR) -- cgit v1.2.1