diff options
author | Tristan van Berkom <tristan@codethink.co.uk> | 2020-08-30 18:41:48 +0900 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2020-08-30 17:25:07 +0000 |
commit | b758505b6f1d82d839cee4b870a7fa5a8ce7422b (patch) | |
tree | 9b49ecb988c018e64b88691282edfc11d860cf1a /src/buildstream/_artifact.py | |
parent | fd80d4903eb28845ca9a67d5730254d93dbd0c24 (diff) | |
download | buildstream-b758505b6f1d82d839cee4b870a7fa5a8ce7422b.tar.gz |
Remove unused Scope argument from artifact name related APIs.tristan/artifact-dependency-names
Additionally, this reverts terminology back to calling these "artifact names",
and not "artifact refs", which is a terminology which crept in from various
underlying implementations.
Summary of changes:
* _artifact.py:
- get_dependency_refs() renamed to get_dependency_artifact_names()
- get_dependency_artifact_names() loses the Scope argument
- Consequently, a huge and needless XXX comment is removed
* _artifactelement.py:
- _new_from_artifact_ref() renamed to _new_from_artifact_name()
- get_dependency_refs() renamed to get_dependency_artifact_names()
- get_dependency_artifact_names() loses the Scope argument
* _project.py:
- Now call _new_from_artifact_name()
- Removes a legacy XXX comment which is not particularly relevant
* element.py:
- __get_dependency_refs() renamed to __get_dependency_artifact_names()
- Adapt __get_last_build_artifact() to updated API names.
Diffstat (limited to 'src/buildstream/_artifact.py')
-rw-r--r-- | src/buildstream/_artifact.py | 43 |
1 files changed, 12 insertions, 31 deletions
diff --git a/src/buildstream/_artifact.py b/src/buildstream/_artifact.py index ac33f041c..f74f3f9ff 100644 --- a/src/buildstream/_artifact.py +++ b/src/buildstream/_artifact.py @@ -30,7 +30,6 @@ artifact composite interaction away from Element class import os -from ._exceptions import ArtifactError from ._protos.buildstream.v2.artifact_pb2 import Artifact as ArtifactProto from . import _yaml from . import utils @@ -362,46 +361,28 @@ class Artifact: return self._metadata_workspaced_dependencies - # get_dependency_refs() + # get_dependency_artifact_names() # - # Retrieve the artifact refs of the artifact's dependencies - # - # Args: - # deps (Scope): The scope of dependencies + # Retrieve the artifact names of all of the dependencies in Scope.BUILD # # Returns: # (list [str]): A list of refs of all build dependencies in staging order. # - def get_dependency_refs(self, deps=Scope.BUILD): + def get_dependency_artifact_names(self): # XXX: The pylint disable is necessary due to upstream issue: # https://github.com/PyCQA/pylint/issues/850 from .element import _get_normal_name # pylint: disable=cyclic-import - # Extract the proto artifact = self._get_proto() - - if deps == Scope.BUILD: - try: - dependency_refs = [ - os.path.join(dep.project_name, _get_normal_name(dep.element_name), dep.cache_key) - for dep in artifact.build_deps - ] - except AttributeError: - # If the artifact has no dependencies - dependency_refs = [] - elif deps == Scope.NONE: - dependency_refs = [self._element.get_artifact_name()] - else: - # XXX: We can only support obtaining the build dependencies of - # an artifact. This is because this is the only information we store - # in the proto. If we were to add runtime deps to the proto, we'd need - # to include these in cache key calculation. - # - # This would have some undesirable side effects: - # 1. It might trigger unnecessary rebuilds. - # 2. It would be impossible to support cyclic runtime dependencies - # in the future - raise ArtifactError("Dependency scope: {} is not supported for artifacts".format(deps)) + try: + dependency_refs = [ + os.path.join(dep.project_name, _get_normal_name(dep.element_name), dep.cache_key) + for dep in artifact.build_deps + ] + except AttributeError: + # If the artifact has no dependencies, the build_deps attribute + # will be missing from the proto. + dependency_refs = [] return dependency_refs |