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:55:47 UTC

[buildstream] 03/12: Convert call-sites of Element._cached() that assume success

This is an automated email from the ASF dual-hosted git repository.

not-in-ldap pushed a commit to branch richardmaw/wip/log-show
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 3c58ac98ea63b532e79952cf9c0357dd184c8953
Author: Richard Maw <ri...@codethink.co.uk>
AuthorDate: Mon Jun 4 18:06:40 2018 +0100

    Convert call-sites of Element._cached() that assume success
    
    When we later add cached failures it needs to not treat them as successes.
---
 buildstream/_frontend/widget.py             | 2 +-
 buildstream/_pipeline.py                    | 4 ++--
 buildstream/_scheduler/queues/buildqueue.py | 2 +-
 buildstream/element.py                      | 8 ++++----
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/buildstream/_frontend/widget.py b/buildstream/_frontend/widget.py
index dab8cab..5967b0d 100644
--- a/buildstream/_frontend/widget.py
+++ b/buildstream/_frontend/widget.py
@@ -368,7 +368,7 @@ class LogLine(Widget):
             if consistency == Consistency.INCONSISTENT:
                 line = p.fmt_subst(line, 'state', "no reference", fg='red')
             else:
-                if element._cached():
+                if element._cached_success():
                     line = p.fmt_subst(line, 'state', "cached", fg='magenta')
                 elif consistency == Consistency.RESOLVED:
                     line = p.fmt_subst(line, 'state', "fetch needed", fg='red')
diff --git a/buildstream/_pipeline.py b/buildstream/_pipeline.py
index 852abf7..800a331 100644
--- a/buildstream/_pipeline.py
+++ b/buildstream/_pipeline.py
@@ -489,7 +489,7 @@ class _Planner():
             self.plan_element(dep, depth)
 
         # Dont try to plan builds of elements that are cached already
-        if not element._cached():
+        if not element._cached_success():
             for dep in element.dependencies(Scope.BUILD, recurse=False):
                 self.plan_element(dep, depth + 1)
 
@@ -501,4 +501,4 @@ class _Planner():
             self.plan_element(root, 0)
 
         depth_sorted = sorted(self.depth_map.items(), key=itemgetter(1), reverse=True)
-        return [item[0] for item in depth_sorted if plan_cached or not item[0]._cached()]
+        return [item[0] for item in depth_sorted if plan_cached or not item[0]._cached_success()]
diff --git a/buildstream/_scheduler/queues/buildqueue.py b/buildstream/_scheduler/queues/buildqueue.py
index 376ef5a..691b9ff 100644
--- a/buildstream/_scheduler/queues/buildqueue.py
+++ b/buildstream/_scheduler/queues/buildqueue.py
@@ -43,7 +43,7 @@ class BuildQueue(Queue):
             # Keep it in the queue.
             return QueueStatus.WAIT
 
-        if element._cached():
+        if element._cached_success():
             return QueueStatus.SKIP
 
         if not element._buildable():
diff --git a/buildstream/element.py b/buildstream/element.py
index d4a70e6..efb646c 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -1013,7 +1013,7 @@ class Element(Plugin):
             # if the pull job is still pending as the remote cache may have an artifact
             # that matches the strict cache key, which is preferred over a locally
             # cached artifact with a weak cache key match.
-            if not dependency._cached() or not dependency._get_cache_key(strength=_KeyStrength.STRONG):
+            if not dependency._cached_success() or not dependency._get_cache_key(strength=_KeyStrength.STRONG):
                 return False
 
         if not self.__assemble_scheduled:
@@ -1119,7 +1119,7 @@ class Element(Plugin):
             # are sufficient. However, don't update the `cached` attributes
             # until the full cache query below.
             if (not self.__assemble_scheduled and not self.__assemble_done and
-                    not self.__is_cached(keystrength=_KeyStrength.WEAK) and
+                    not self.__cached_success(keystrength=_KeyStrength.WEAK) and
                     not self._pull_pending() and self._is_required()):
                 self._schedule_assemble()
                 return
@@ -1145,7 +1145,7 @@ class Element(Plugin):
                 self.__weak_cached = self.__artifacts.contains(self, self.__weak_cache_key)
 
         if (not self.__assemble_scheduled and not self.__assemble_done and
-                not self.__cached and not self._pull_pending() and self._is_required()):
+                not self._cached_success() and not self._pull_pending() and self._is_required()):
             # Workspaced sources are considered unstable if a build is pending
             # as the build will modify the contents of the workspace.
             # Determine as early as possible if a build is pending to discard
@@ -1487,7 +1487,7 @@ class Element(Plugin):
     def _assemble(self):
 
         # Assert call ordering
-        assert not self._cached()
+        assert not self._cached_success()
 
         context = self._get_context()
         with self._output_file() as output_file: