You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by no...@apache.org on 2020/12/29 12:25:20 UTC
[buildstream] 10/13: Remove excluded_subdir/subdir options
This is an automated email from the ASF dual-hosted git repository.
not-in-ldap pushed a commit to branch tpollard/prototemp
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit d8b1ff90339e31daa16cf5c9251f11c14d22d8d6
Author: Raoul Hidalgo Charman <ra...@codethink.co.uk>
AuthorDate: Fri Apr 12 12:08:35 2019 +0100
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
---
buildstream/_artifactcache.py | 9 +++-----
buildstream/_cas/cascache.py | 10 +++-----
buildstream/element.py | 53 +++++++++----------------------------------
3 files changed, 17 insertions(+), 55 deletions(-)
diff --git a/buildstream/_artifactcache.py b/buildstream/_artifactcache.py
index 7dc1aee..2fc3dcf 100644
--- a/buildstream/_artifactcache.py
+++ b/buildstream/_artifactcache.py
@@ -268,9 +268,8 @@ class ArtifactCache(BaseCache):
# element (Element): The element whose artifacts to compare
# key_a (str): The first artifact key
# key_b (str): The second artifact 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):
digest_a = self.get_artifact_proto(element.get_artifact_name(key_a)).files
digest_b = self.get_artifact_proto(element.get_artifact_name(key_b)).files
@@ -326,15 +325,13 @@ 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):
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 0bbeedd..5c1642d 100644
--- a/buildstream/_cas/cascache.py
+++ b/buildstream/_cas/cascache.py
@@ -231,14 +231,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 = []
@@ -261,7 +257,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()
@@ -275,7 +271,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 7b7d2f8..4cf8d89 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -1853,9 +1853,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.__artifacts.contains_buildtree(self, self.__strict_cache_key):
return False
@@ -1895,13 +1895,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
@@ -2840,11 +2840,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
@@ -2865,10 +2865,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
@@ -2880,37 +2880,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