Skip to content

Commit

Permalink
force skip/run by tag
Browse files Browse the repository at this point in the history
  • Loading branch information
wisechengyi committed Dec 17, 2018
1 parent faedb4b commit dc9777e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 20 deletions.
10 changes: 0 additions & 10 deletions src/python/pants/backend/jvm/tasks/rewrite_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,6 @@ def execute(self):
"""Runs the tool on all source files that are located."""
relevant_targets = self._get_non_synthetic_targets(self.get_targets())

# force_run_tag = 'no-{}.skip'.format(self.options_scope)
# force_run_targets = set(t for t in relevant_targets if force_run_tag in t.tags)
# force_skip_tag = '{}.skip'.format(self.options_scope)
# force_skip_targets = set(t for t in relevant_targets if force_skip_tag in t.tags)
#
# final_targets = set(relevant_targets).union(force_run_targets).difference(force_skip_targets)
#
# self.context.log.debug("Force skipping targets by tag: {}\n{}".format(force_skip_tag, force_skip_targets))
# self.context.log.debug("Force running targets by tag: {}\n{}".format(force_run_tag, force_run_targets))

if self.sideeffecting:
# Always execute sideeffecting tasks without invalidation.
self._execute_for(relevant_targets)
Expand Down
2 changes: 0 additions & 2 deletions src/python/pants/engine/round_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ def attempt(self, explain):
with self._context.new_workunit(name=name, labels=[WorkUnitLabel.TASK], log_config=log_config):
if explain:
self._context.log.debug('Skipping execution of {} in explain mode'.format(name))
# elif task.skip_execution:
# self._context.log.info('Skipping {}'.format(name))
else:
task.execute()

Expand Down
1 change: 0 additions & 1 deletion src/python/pants/task/target_restriction_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def supports_skipping_target_by_tag(self):
return True



class SkipOptionRegistrar(object):
"""Registrar of --skip."""

Expand Down
24 changes: 17 additions & 7 deletions src/python/pants/task/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,15 @@ def skip_execution(self):
"""
return False

@property
def supports_skipping_target_by_tag(self):
"""
Whether this task supports forced skip/non-skip on targets based on tags.
:API: public
"""
return False

@property
def act_transitively(self):
"""Whether this task should act on the transitive closure of the target roots.
Expand All @@ -222,10 +231,6 @@ def act_transitively(self):
"""
return True

@property
def supports_skipping_target_by_tag(self):
return False

def get_targets(self, predicate=None):
"""Returns the candidate targets this task should act on.
Expand All @@ -249,15 +254,20 @@ def get_targets(self, predicate=None):
force_run_tag = 'no-{}.skip'.format(self.options_scope)
force_run_targets = set(t for t in relevant_targets if force_run_tag in t.tags)

if not force_run_targets and self.skip_execution:
self.context.log.info('Skipping by returning empty targets '
'because task level is skipped and there is no forced run targets')
return []

force_skip_tag = '{}.skip'.format(self.options_scope)
force_skip_targets = set(t for t in relevant_targets if force_skip_tag in t.tags)

if force_run_targets:
self.context.log.debug("Force skipping targets by tag: {}\n{}".format(force_skip_tag, force_skip_targets))
if force_skip_targets:
self.context.log.debug("Force skipping targets by tag: {}\n{}".format(force_skip_tag, force_skip_targets))
if force_run_targets:
self.context.log.debug("Force running targets by tag: {}\n{}".format(force_run_tag, force_run_targets))

final_targets = set(relevant_targets).union(force_run_targets).difference(force_skip_targets)
final_targets = list(set(relevant_targets).union(force_run_targets).difference(force_skip_targets))

return final_targets

Expand Down

0 comments on commit dc9777e

Please sign in to comment.