diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-04-19 14:46:05 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-04-19 15:11:47 +0900 |
commit | 674378036f5389f319a712a58d0bae753af96067 (patch) | |
tree | 77cb278d92d30eca0629bfb0b12d2208c822f962 | |
parent | 64069c8c0bced53929db7171674991523accd764 (diff) | |
download | buildstream-674378036f5389f319a712a58d0bae753af96067.tar.gz |
_pipeline.py, _frontend/app.py: Added track_selection initialization argument
This informs the pipeline what PipelineSelection mode to use
for constructing the list of elements to track.
-rw-r--r-- | buildstream/_frontend/app.py | 14 | ||||
-rw-r--r-- | buildstream/_pipeline.py | 34 |
2 files changed, 33 insertions, 15 deletions
diff --git a/buildstream/_frontend/app.py b/buildstream/_frontend/app.py index f4336956d..0f614f00f 100644 --- a/buildstream/_frontend/app.py +++ b/buildstream/_frontend/app.py @@ -38,7 +38,7 @@ from .._context import Context from .._project import Project from .._exceptions import BstError, PipelineError, LoadError, LoadErrorReason, AppError from .._message import Message, MessageType, unconditional_messages -from .._pipeline import Pipeline +from .._pipeline import Pipeline, PipelineSelection from .._scheduler import Scheduler from .._profile import Topics, profile_start, profile_end from .._versions import BST_FORMAT_VERSION @@ -229,6 +229,7 @@ class App(): # add_remote_cache (str): The URL for an explicitly mentioned remote cache # track_elements (list of elements): Elements which are to be tracked # track_cross_junctions (bool): Whether tracking is allowed to cross junction boundaries + # track_selection (PipelineSelection): The selection algorithm for track elements # fetch_subprojects (bool): Whether we should fetch subprojects as a part of the # loading process, if they are not yet locally cached # @@ -243,8 +244,12 @@ class App(): @contextmanager def initialized(self, elements, *, session_name=None, except_=tuple(), rewritable=False, - use_configured_remote_caches=False, add_remote_cache=None, - track_elements=None, track_cross_junctions=False, fetch_subprojects=False): + use_configured_remote_caches=False, + add_remote_cache=None, + track_elements=None, + track_cross_junctions=False, + track_selection=PipelineSelection.ALL, + fetch_subprojects=False): profile_start(Topics.LOAD_PIPELINE, "_".join(t.replace(os.sep, '-') for t in elements)) # Start with the early stage init, this enables logging right away @@ -278,7 +283,8 @@ class App(): self.pipeline.initialize(use_configured_remote_caches=use_configured_remote_caches, add_remote_cache=add_remote_cache, track_elements=track_elements, - track_cross_junctions=track_cross_junctions) + track_cross_junctions=track_cross_junctions, + track_selection=track_selection) except BstError as e: self._error_exit(e, "Error initializing pipeline") diff --git a/buildstream/_pipeline.py b/buildstream/_pipeline.py index 540d0715f..80e7d076c 100644 --- a/buildstream/_pipeline.py +++ b/buildstream/_pipeline.py @@ -156,12 +156,14 @@ class Pipeline(): # add_remote_cache (str): The URL for an additional remote artifact cache # track_element (list of Elements): List of elements specified by the frontend for tracking # track_cross_junctions (bool): Whether tracking is allowed to cross junction boundaries + # track_selection (PipelineSelection): The selection algorithm for track elements # def initialize(self, use_configured_remote_caches=False, add_remote_cache=None, track_elements=None, - track_cross_junctions=False): + track_cross_junctions=False, + track_selection=PipelineSelection.ALL): # Preflight directly, before ever interrogating caches or anything. self._preflight() @@ -187,7 +189,7 @@ class Pipeline(): self._track_cross_junctions = track_cross_junctions self._track_elements = [] if track_elements: - self._track_elements = self._get_elements_to_track(track_elements) + self._track_elements = self._get_elements_to_track(track_elements, track_selection) # Now resolve the cache keys once tracking elements have been resolved self._resolve_cache_keys() @@ -620,26 +622,36 @@ class Pipeline(): # _get_elements_to_track(): # - # Work out which elements are going to be tracked + # Work out which elements are going to be tracked. + # + # Currently the 'mode' parameter only accepts + # PipelineSelection.NONE or PipelineSelection.ALL + # + # This makes the assumption that the except elements are + # meant to be removed from tracking element lists. # # Args: - # (list of str): List of target names + # track_targets (list of str): List of target names + # mode (PipelineSelection): The PipelineSelection mode # # Returns: # (list): List of Element objects to track # - def _get_elements_to_track(self, track_targets): + def _get_elements_to_track(self, track_targets, mode=PipelineSelection.ALL): planner = _Planner() # Convert target names to elements - target_elements = [e for e in self.dependencies(Scope.ALL) - if e.name in track_targets] + track_elements = [e for e in self.dependencies(Scope.ALL) + if e.name in track_targets] + + if mode != PipelineSelection.NONE: + assert mode == PipelineSelection.ALL - # Plan them out - track_elements = planner.plan(target_elements, ignore_cache=True) + # Plan them out + track_elements = planner.plan(track_elements, ignore_cache=True) - # Filter out --except elements - track_elements = self.remove_elements(track_elements) + # Filter out --except elements + track_elements = self.remove_elements(track_elements) # Filter out cross junctioned elements if self._track_cross_junctions: |