taskgraph.optimize package

Submodules

taskgraph.optimize.seta module

class taskgraph.optimize.seta.SETA

Bases: object

Interface to the SETA service, which defines low-value tasks that can be optimized out of the taskgraph.

is_low_value_task(label, project, pushlog_id, push_date, push_interval, time_interval)
minutes_between_pushes(project, cur_push_id, cur_push_date, time_interval)
query_low_value_tasks(project)
class taskgraph.optimize.seta.SkipLowValue(push_interval, time_interval)

Bases: taskgraph.optimize.OptimizationStrategy

should_remove_task(task, params, _)

taskgraph.optimize.strategies module

class taskgraph.optimize.strategies.IndexSearch

Bases: taskgraph.optimize.OptimizationStrategy

should_replace_task(task, params, index_paths)

Look for a task with one of the given index paths

class taskgraph.optimize.strategies.SkipUnlessChanged

Bases: taskgraph.optimize.OptimizationStrategy

should_remove_task(task, params, file_patterns)
class taskgraph.optimize.strategies.SkipUnlessSchedules

Bases: taskgraph.optimize.OptimizationStrategy

scheduled_by_push = <functools.partial object>
should_remove_task(task, params, conditions)

Module contents

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.Alias(strategy)

Bases: taskgraph.optimize.Either

Provides an alias to an existing strategy.

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

class taskgraph.optimize.Either(*substrategies, **kwargs)

Bases: taskgraph.optimize.OptimizationStrategy

Given one or more optimization strategies, remove a task if any of them says to, and replace with a task if any finds a replacement (preferring the earliest). By default, each substrategy gets the same arg, but split_args can return a list of args for each strategy, if desired.

should_remove_task(task, params, arg)
should_replace_task(task, params, arg)
class taskgraph.optimize.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, 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.get_subgraph(target_task_graph, removed_tasks, replaced_tasks, label_to_taskid)

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.optimize_task_graph(target_task_graph, params, do_not_optimize, 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.register_strategy(name, args=())
taskgraph.optimize.remove_tasks(target_task_graph, params, optimizations, do_not_optimize)

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

taskgraph.optimize.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.