From 750a21ef19030da31ba7f336ef55cbe7132d6fbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Billeter?= Date: Tue, 23 Jan 2018 12:16:08 +0000 Subject: Add Element._pull_pending() method This moves the pull status logic from PullQueue to Element. As PullQueue.process() simply calls Element._pull(), it doesn't make sense to keep the status logic in PullQueue. This is also required to use the pull status in other places without code duplication. --- buildstream/_scheduler/pullqueue.py | 11 +---------- buildstream/element.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/buildstream/_scheduler/pullqueue.py b/buildstream/_scheduler/pullqueue.py index 38de9cf09..e879b4689 100644 --- a/buildstream/_scheduler/pullqueue.py +++ b/buildstream/_scheduler/pullqueue.py @@ -46,18 +46,9 @@ class PullQueue(Queue): if element._get_strict_cache_key() is None: return QueueStatus.WAIT - if element._cached(strength=_KeyStrength.STRONG): - return QueueStatus.SKIP - elif element._remotely_cached(strength=_KeyStrength.STRONG): - # pull artifact using strong key - return QueueStatus.READY - elif element._cached(): - return QueueStatus.SKIP - elif element._remotely_cached(): - # pull artifact using weak key + if element._pull_pending(): return QueueStatus.READY else: - # nothing to pull return QueueStatus.SKIP def done(self, element, result, returncode): diff --git a/buildstream/element.py b/buildstream/element.py index 138096caf..ab6713861 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -1362,6 +1362,24 @@ class Element(Plugin): context = self._get_context() return context._get_strict(project.name) + # _pull_pending() + # + # Check whether the artifact will be pulled. + # + # Returns: + # (bool): Whether a pull operation is pending + # + def _pull_pending(self): + if not self.__strong_cached and self.__remotely_strong_cached: + # Pull pending using strict cache key + return True + elif not self.__cached and self.__remotely_cached: + # Pull pending using weak cache key + return True + else: + # No pull pending + return False + # _update_state() # # Keep track of element state. Calculate cache keys if possible and -- cgit v1.2.1