diff options
author | bst-marge-bot <marge-bot@buildstream.build> | 2019-11-11 14:16:59 +0000 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-11-11 14:16:59 +0000 |
commit | b3270030b5a9e520fd6a2d9f7acd923e27e10139 (patch) | |
tree | d5e78c0118a8682a31112af2e29dc44299ba5ddd | |
parent | e0ec80385502d04bbed8fa879b1e9db0f674018b (diff) | |
parent | 4d3f0cace0a56dbe9aff0f2c73cffcca93883337 (diff) | |
download | buildstream-b3270030b5a9e520fd6a2d9f7acd923e27e10139.tar.gz |
Merge branch 'traveltissues/1186-3' into 'master'
skip tracking elements without trackable sources
Closes #1186
See merge request BuildStream/buildstream!1689
-rw-r--r-- | src/buildstream/_stream.py | 18 | ||||
-rw-r--r-- | src/buildstream/element.py | 18 | ||||
-rw-r--r-- | src/buildstream/source.py | 10 |
3 files changed, 30 insertions, 16 deletions
diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py index a9c1c7261..f09a46185 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) @@ -1209,16 +1213,6 @@ class Stream(): # Hold on to the targets self.targets = elements + artifacts - # Here we should raise an error if the track_elements targets - # are not dependencies of the primary targets, this is not - # supported. - # - # This can happen with `bst build --track` - # - if targets and not self._pipeline.targets_include(elements, track_elements): - raise StreamError("Specified tracking targets that are not " - "within the scope of primary targets") - # First take care of marking tracking elements, this must be # done before resolving element states. # @@ -1248,11 +1242,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, |