taskgraph.optimize package#

Submodules#

taskgraph.optimize.base module#

The objective of optimization is to remove as many tasks from the graph as possible, as efficiently as possible, thereby delivering useful results as quickly as possible. For example, ideally if only a test script is modified in a push, then the resulting graph contains only the corresponding test suite task.

See taskcluster/docs/optimization.rst for more information.

class taskgraph.optimize.base.Alias(strategy)#

Bases: CompositeStrategy

Provides an alias to an existing strategy.

This can be useful to swap strategies in and out without needing to modify the task transforms.

property description#

A textual description of the combined substrategies.

reduce(results)#

Given all substrategy results as a generator, return the overall result.

class taskgraph.optimize.base.All(*substrategies, **kwargs)#

Bases: CompositeStrategy

Given one or more optimization strategies, remove or replace a task if all of them says to.

Replacement will use the value returned by the first strategy passed in. Note the values used for replacement need not be the same, as long as they all say to replace.

property description#

A textual description of the combined substrategies.

classmethod reduce(results)#

Given all substrategy results as a generator, return the overall result.

class taskgraph.optimize.base.Always#

Bases: OptimizationStrategy

should_remove_task(task, params, arg)#

Determine whether to optimize this task by removing it. Returns True to remove.

class taskgraph.optimize.base.Any(*substrategies, **kwargs)#

Bases: CompositeStrategy

Given one or more optimization strategies, remove or replace a task if any of them says to.

Replacement will use the value returned by the first strategy that says to replace.

property description#

A textual description of the combined substrategies.

classmethod reduce(results)#

Given all substrategy results as a generator, return the overall result.

class taskgraph.optimize.base.CompositeStrategy(*substrategies, **kwargs)#

Bases: OptimizationStrategy

abstract property description#

A textual description of the combined substrategies.

abstract reduce(results)#

Given all substrategy results as a generator, return the overall result.

should_remove_task(*args)#

Determine whether to optimize this task by removing it. Returns True to remove.

should_replace_task(*args)#

Determine whether to optimize this task by replacing it. Returns a taskId to replace this task, True to replace with nothing, or False to keep the task.

class taskgraph.optimize.base.Not(strategy)#

Bases: CompositeStrategy

Given a strategy, returns the opposite.

property description#

A textual description of the combined substrategies.

reduce(results)#

Given all substrategy results as a generator, return the overall result.

class taskgraph.optimize.base.OptimizationStrategy#

Bases: object

should_remove_task(task, params, arg)#

Determine whether to optimize this task by removing it. Returns True to remove.

should_replace_task(task, params, deadline, arg)#

Determine whether to optimize this task by replacing it. Returns a taskId to replace this task, True to replace with nothing, or False to keep the task.

taskgraph.optimize.base.get_subgraph(target_task_graph, removed_tasks, replaced_tasks, label_to_taskid, decision_task_id)#

Return the subgraph of target_task_graph consisting only of non-optimized tasks and edges between them.

To avoid losing track of taskIds for tasks optimized away, this method simultaneously substitutes real taskIds for task labels in the graph, and populates each task definition’s dependencies key with the appropriate taskIds. Task references are resolved in the process.

taskgraph.optimize.base.optimize_task_graph(target_task_graph, requested_tasks, params, do_not_optimize, decision_task_id, existing_tasks=None, strategy_override=None)#

Perform task optimization, returning a taskgraph and a map from label to assigned taskId, including replacement tasks.

taskgraph.optimize.base.register_strategy(name, args=())#
taskgraph.optimize.base.remove_tasks(target_task_graph, requested_tasks, params, optimizations, do_not_optimize)#

Implement the “Removing Tasks” phase, returning a set of task labels of all removed tasks.

taskgraph.optimize.base.replace_tasks(target_task_graph, params, optimizations, do_not_optimize, label_to_taskid, removed_tasks, existing_tasks)#

Implement the “Replacing Tasks” phase, returning a set of task labels of all replaced tasks. The replacement taskIds are added to label_to_taskid as a side-effect.

taskgraph.optimize.strategies module#

class taskgraph.optimize.strategies.IndexSearch#

Bases: OptimizationStrategy

fmt = '%Y-%m-%dT%H:%M:%S.%fZ'#
should_replace_task(task, params, deadline, index_paths)#

Look for a task with one of the given index paths

class taskgraph.optimize.strategies.SkipUnlessChanged#

Bases: OptimizationStrategy

check(files_changed, patterns)#
should_remove_task(task, params, file_patterns)#

Determine whether to optimize this task by removing it. Returns True to remove.

Module contents#