summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarius Makovsky <traveltissues@protonmail.com>2019-11-06 09:29:49 +0000
committerDarius Makovsky <traveltissues@protonmail.com>2019-11-11 13:44:52 +0000
commitc76c918a7febda4ef4253f8a9a957276d8ebb614 (patch)
tree3e3b93870fa395e7ea1c318daafcf6125212aa2d
parente0ec80385502d04bbed8fa879b1e9db0f674018b (diff)
downloadbuildstream-c76c918a7febda4ef4253f8a9a957276d8ebb614.tar.gz
Add _is_trackable() 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.__tracking_scheduled` attribute which is set in `Element._schedule_tracking()`. This is set to `True` if at least one source can be tracked. Also remove some of the tracking handling from `_stream._load` to `_stream.track` where it is more relevant. closes #1186
-rw-r--r--src/buildstream/_stream.py8
-rw-r--r--src/buildstream/element.py18
-rw-r--r--src/buildstream/source.py10
3 files changed, 30 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..5fa8f14df 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -1331,8 +1331,22 @@ class Element(Plugin):
# and reinterrogation of element state after tracking of elements
# succeeds.
#
- def _schedule_tracking(self):
- self.__tracking_scheduled = True
+ # This method should return the value of `__tracking_scheduled` to report
+ # to callers that the element was marked for tracking.
+ #
+ # If `__tracking_scheduled` is not already determined then set it to `True`
+ # if at least one source advertises that it can be tracked.
+ #
+ # Returns:
+ # (bool): value of the `__tracking_scheduled` attribute
+ #
+ def _schedule_tracking(self) -> bool:
+ # if the tracking schedule is already determined then this can be skipped
+ if not self.__tracking_scheduled:
+ # Tracking does not make sense in cases where no sources can be tracked.
+ if any(source._is_trackable() for source in self.__sources):
+ self.__tracking_scheduled = True
+ return self.__tracking_scheduled
# _tracking_done():
#
diff --git a/src/buildstream/source.py b/src/buildstream/source.py
index 5321363a4..05a1ae464 100644
--- a/src/buildstream/source.py
+++ b/src/buildstream/source.py
@@ -1087,6 +1087,16 @@ class Source(Plugin):
return new_ref
+ # _is_trackable()
+ #
+ # Returns:
+ # (bool): Whether this source is trackable
+ #
+ def _is_trackable(self) -> bool:
+ """Report whether this source can be tracked."""
+ # sources that require staging to generate keys cannot be tracked
+ return not self.BST_KEY_REQUIRES_STAGE
+
# _requires_previous_sources()
#
# If a plugin requires access to previous sources at track or fetch time,