diff options
author | Darius Makovsky <traveltissues@protonmail.com> | 2019-11-06 09:29:49 +0000 |
---|---|---|
committer | Darius Makovsky <traveltissues@protonmail.com> | 2019-11-07 11:56:13 +0000 |
commit | 7364a5b966a17d669d7a765e0e5ad3408fc9e8de (patch) | |
tree | e55f0cdbb6edfdc2dc2c485108fbe1ccf863a02d | |
parent | a283f02ce9f5d72f03c783d516d69d8f57069ef4 (diff) | |
download | buildstream-7364a5b966a17d669d7a765e0e5ad3408fc9e8de.tar.gz |
Add is_trackable() public method to Source()
This method reports whether the source can be tracked. This would be
false for sources advertising BST_KEY_REQUIRES_STAGE.
Element tracking can be skipped if none of the held sources can be
tracked. This is determined by the value of the
`Element.__has_trackable_sources` attribute which is set in
`Element._schedule_tracking()`.
Also remove some of the tracking handling from `_stream._load`.
closes #1186
-rw-r--r-- | src/buildstream/_stream.py | 8 | ||||
-rw-r--r-- | src/buildstream/element.py | 23 | ||||
-rw-r--r-- | src/buildstream/source.py | 7 |
3 files changed, 32 insertions, 6 deletions
diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py index a9c1c7261..91f37cbf3 100644 --- a/src/buildstream/_stream.py +++ b/src/buildstream/_stream.py @@ -377,6 +377,10 @@ class Stream(): track_except_targets=except_targets, track_cross_junctions=cross_junctions) + # FIXME: this can be refactored after element._update_state is simplified/removed + elements = [element for element in elements if element._schedule_tracking()] + self._pipeline.resolve_elements(elements) + self._scheduler.clear_queues() track_queue = TrackQueue(self._scheduler) self._add_queue(track_queue, track=True) @@ -1248,11 +1252,7 @@ class Stream(): track_selected, track_except_elements) - for element in track_selected: - element._schedule_tracking() - if not targets: - self._pipeline.resolve_elements(track_selected) return [], track_selected # ArtifactCache.setup_remotes expects all projects to be fully loaded diff --git a/src/buildstream/element.py b/src/buildstream/element.py index 9a0a71a97..ab4cad69c 100644 --- a/src/buildstream/element.py +++ b/src/buildstream/element.py @@ -257,6 +257,8 @@ class Element(Plugin): self.__cached_remotely = None # Whether the element is cached remotely # List of Sources self.__sources = [] # type: List[Source] + # At least one of the sources can be tracked (bool) + self.__has_trackable_sources = None # type: ignore self.__weak_cache_key = None # Our cached weak cache key self.__strict_cache_key = None # Our cached cache key for strict builds self.__artifacts = context.artifactcache # Artifact cache @@ -1331,8 +1333,25 @@ class Element(Plugin): # and reinterrogation of element state after tracking of elements # succeeds. # - def _schedule_tracking(self): - self.__tracking_scheduled = True + # If `__has_trackable_sources` is not set, then we haven't yet determined + # if this element has sources that can be tracked. Set it to True if + # at least one source advertises that it can be tracked and False + # otherwise. If it is True then also set `__tracking_scheduled` to True. + # + # Return the value `__has_trackable_sources` to communicate this to callers. + # + # Returns: + # (bool): value of self.__has_trackable_sources + # + def _schedule_tracking(self) -> bool: + # Scheduling tracking does not make sense in cases where no sources + # can be tracked. + if self.__has_trackable_sources is None: + self.__has_trackable_sources = any(source.is_trackable() for source in self.__sources) + + if self.__has_trackable_sources: + self.__tracking_scheduled = True + return self.__has_trackable_sources # _tracking_done(): # diff --git a/src/buildstream/source.py b/src/buildstream/source.py index 5321363a4..25c205acc 100644 --- a/src/buildstream/source.py +++ b/src/buildstream/source.py @@ -563,6 +563,13 @@ class Source(Plugin): ############################################################# # Public Methods # ############################################################# + def is_trackable(self) -> bool: + """Report whether this source can be tracked.""" + # sources that require staging to generate keys cannot be tracked + if self.BST_KEY_REQUIRES_STAGE: + return False + return True + def get_mirror_directory(self) -> str: """Fetches the directory where this source should store things |