diff options
author | Raoul Hidalgo Charman <raoul.hidalgocharman@codethink.co.uk> | 2019-04-12 12:08:35 +0100 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-05-15 10:18:26 +0000 |
commit | 14dc7e498f769c71b119036a5fa9dd0b2af4c089 (patch) | |
tree | 65b8c9d4707fa03032bea03c39c8b833af264767 | |
parent | 30e89a6a3cdcea83e0d83e373e50b88c02df3667 (diff) | |
download | buildstream-14dc7e498f769c71b119036a5fa9dd0b2af4c089.tar.gz |
Remove excluded_subdir/subdir options
With artifact as a proto, it doesn't make sense to do it this way, bits
of code can be removed.
Part of #974
-rw-r--r-- | buildstream/_artifactcache.py | 10 | ||||
-rw-r--r-- | buildstream/_cas/cascache.py | 10 | ||||
-rw-r--r-- | buildstream/element.py | 53 |
3 files changed, 17 insertions, 56 deletions
diff --git a/buildstream/_artifactcache.py b/buildstream/_artifactcache.py index aa3d7d463..5abb3b45f 100644 --- a/buildstream/_artifactcache.py +++ b/buildstream/_artifactcache.py @@ -249,9 +249,8 @@ class ArtifactCache(BaseCache): # element (Element): The element whose artifacts to compare # key_a (str): The first artifact strong key # key_b (str): The second artifact strong key - # subdir (str): A subdirectory to limit the comparison to # - def diff(self, element, key_a, key_b, *, subdir=None): + def diff(self, element, key_a, key_b): context = self.context artifact_a = Artifact(element, context, strong_key=key_a) artifact_b = Artifact(element, context, strong_key=key_b) @@ -310,17 +309,14 @@ class ArtifactCache(BaseCache): # element (Element): The Element whose artifact is to be fetched # key (str): The cache key to use # 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 + # pull_buildtrees (bool): Whether to pull buildtrees or not # # Returns: # (bool): True if pull was successful, False if artifact was not available # - def pull(self, element, key, *, progress=None, subdir=None, excluded_subdirs=None): + def pull(self, element, key, *, progress=None, pull_buildtrees=False): display_key = key[:self.context.log_key_length] - project = element._get_project() - pull_buildtrees = "buildtree" not in excluded_subdirs if excluded_subdirs else True for remote in self._remotes[project]: remote.init() diff --git a/buildstream/_cas/cascache.py b/buildstream/_cas/cascache.py index c45f56f83..0bdb2062d 100644 --- a/buildstream/_cas/cascache.py +++ b/buildstream/_cas/cascache.py @@ -232,14 +232,10 @@ class CASCache(): # ref_b (str): The second ref # subdir (str): A subdirectory to limit the comparison to # - def diff(self, ref_a, ref_b, *, subdir=None): + def diff(self, ref_a, ref_b): tree_a = self.resolve_ref(ref_a) tree_b = self.resolve_ref(ref_b) - if subdir: - tree_a = self._get_subdir(tree_a, subdir) - tree_b = self._get_subdir(tree_b, subdir) - added = [] removed = [] modified = [] @@ -262,7 +258,7 @@ class CASCache(): # Returns: # (bool): True if pull was successful, False if ref was not available # - def pull(self, ref, remote, *, progress=None, subdir=None, excluded_subdirs=None): + def pull(self, ref, remote, *, progress=None): try: remote.init() @@ -276,7 +272,7 @@ class CASCache(): self._fetch_directory(remote, tree) # Fetch files, excluded_subdirs determined in pullqueue - required_blobs = self.required_blobs_for_directory(tree, excluded_subdirs=excluded_subdirs) + required_blobs = self.required_blobs_for_directory(tree) missing_blobs = self.local_missing_blobs(required_blobs) if missing_blobs: self.fetch_blobs(remote, missing_blobs) diff --git a/buildstream/element.py b/buildstream/element.py index d6ef22786..382106e8a 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -1881,9 +1881,9 @@ class Element(Plugin): # Check whether the pull has been invoked with a specific subdir requested # in user context, as to complete a partial artifact - subdir, _ = self.__pull_directories() + pull_buildtrees = self._get_context().pull_buildtrees - if self.__strong_cached and subdir == 'buildtree': + if self.__strong_cached and pull_buildtrees: # If we've specified a subdir, check if the subdir is cached locally if self.__artifact.cached_buildtree(): return False @@ -1923,13 +1923,13 @@ class Element(Plugin): # Get optional specific subdir to pull and optional list to not pull # based off of user context - subdir, excluded_subdirs = self.__pull_directories() + pull_buildtrees = context.pull_buildtrees # Attempt to pull artifact without knowing whether it's available - pulled = self.__pull_strong(progress=progress, subdir=subdir, excluded_subdirs=excluded_subdirs) + pulled = self.__pull_strong(progress=progress, pull_buildtrees=pull_buildtrees) if not pulled and not self._cached() and not context.get_strict(): - pulled = self.__pull_weak(progress=progress, subdir=subdir, excluded_subdirs=excluded_subdirs) + pulled = self.__pull_weak(progress=progress, pull_buildtrees=pull_buildtrees) if not pulled: return False @@ -2878,11 +2878,11 @@ class Element(Plugin): # Returns: # (bool): Whether or not the pull was successful # - def __pull_strong(self, *, progress=None, subdir=None, excluded_subdirs=None): + def __pull_strong(self, *, progress=None, pull_buildtrees): weak_key = self._get_cache_key(strength=_KeyStrength.WEAK) key = self.__strict_cache_key - if not self.__artifacts.pull(self, key, progress=progress, subdir=subdir, - excluded_subdirs=excluded_subdirs): + if not self.__artifacts.pull(self, key, progress=progress, + pull_buildtrees=pull_buildtrees): return False # update weak ref by pointing it to this newly fetched artifact @@ -2903,10 +2903,10 @@ class Element(Plugin): # Returns: # (bool): Whether or not the pull was successful # - def __pull_weak(self, *, progress=None, subdir=None, excluded_subdirs=None): + def __pull_weak(self, *, progress=None, pull_buildtrees): weak_key = self._get_cache_key(strength=_KeyStrength.WEAK) - if not self.__artifacts.pull(self, weak_key, progress=progress, subdir=subdir, - excluded_subdirs=excluded_subdirs): + if not self.__artifacts.pull(self, weak_key, progress=progress, + pull_buildtrees=pull_buildtrees): return False # extract strong cache key from this newly fetched artifact @@ -2918,37 +2918,6 @@ class Element(Plugin): return True - # __pull_directories(): - # - # Which directories to include or exclude given the current - # context - # - # Returns: - # subdir (str): The optional specific subdir to include, based - # on user context - # excluded_subdirs (list): The optional list of subdirs to not - # pull, referenced against subdir value - # - def __pull_directories(self): - context = self._get_context() - - # Current default exclusions on pull - excluded_subdirs = ["buildtree"] - subdir = '' - - # If buildtrees are to be pulled, remove the value from exclusion list - # and set specific subdir - if context.pull_buildtrees: - subdir = "buildtree" - excluded_subdirs.remove(subdir) - - # If file contents are not required for this element, don't pull them. - # The directories themselves will always be pulled. - if not context.require_artifact_files and not self._artifact_files_required(): - excluded_subdirs.append("files") - - return (subdir, excluded_subdirs) - # __cache_sources(): # # Caches the sources into the local CAS |