# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from collections import defaultdict from fnmatch import fnmatch
from taskgraph.optimize.base import OptimizationStrategy, register_strategy, registry
from gecko_taskgraph.util.bugbug import (
CT_HIGH,
CT_LOW,
CT_MEDIUM,
BugbugTimeoutException,
push_schedules,
) from gecko_taskgraph.util.hg import get_push_data
FALLBACK = "skip-unless-has-relevant-tests"
def merge_bugbug_replies(data, new_data): """Merge a bugbug reply (stored in the `new_data` argument) into another (stored in the `data` argument). """ for key, value in new_data.items(): if isinstance(value, dict): if key notin data:
data[key] = {}
if len(value) == 0: continue
dict_value = next(iter(value.values())) if isinstance(dict_value, list): for name, configs in value.items(): if name notin data[key]:
data[key][name] = set()
data[key][name].update(configs) else: for name, confidence in value.items(): if name notin data[key] or data[key][name] < confidence:
data[key][name] = confidence elif isinstance(value, list): if key notin data:
data[key] = set()
Args:
confidence_threshold (float): The minimum confidence threshold (in
range [0, 1]) needed for a task to be scheduled.
tasks_only (bool): Whether ornot to only use tasks and no groups
(default: False)
use_reduced_tasks (bool): Whether ornot to use the reduced set of tasks
provided by the bugbug service (default: False).
fallback (str): The fallback strategy to use if there
was a failure in bugbug (default: None)
num_pushes (int): The number of pushes to consider for the selection
(default: 1).
select_configs (bool): Whether to select configurations for manifests
too (default: False). """
key = "reduced_tasks"if self.use_reduced_tasks else"tasks"
tasks = {
task for task, confidence in data.get(key, {}).items() if confidence >= self.confidence_threshold
}
test_manifests = task.attributes.get("test_manifests") if test_manifests isNoneor self.tasks_only: if data.get("known_tasks") and task.label notin data["known_tasks"]: returnFalse
if task.label notin tasks: returnTrue
returnFalse
# If a task contains more than one group, use the max confidence.
groups = data.get("groups", {})
confidences = [c for g, c in groups.items() if g in test_manifests] ifnot confidences or max(confidences) < self.confidence_threshold: returnTrue
# If the task configuration doesn't match the ones selected by bugbug for # the manifests, optimize out. if self.select_configs:
selected_groups = [
g for g, c in groups.items() if g in test_manifests and c > self.confidence_threshold
]
# Configurations returned by bugbug are in a format such as # `test-windows10-64/opt-*-e10s`, while task labels are like # test-windows10-64-qr/opt-mochitest-browser-chrome-e10s-6. # In order to match the strings, we need to ignore the chunk number # from the task label.
parts = task.label.split("-")
label_without_chunk_number = "-".join(
parts[:-1] if parts[-1].isdigit() else parts
)
ifnot any(
fnmatch(label_without_chunk_number, config) for group in selected_groups for config in config_groups[group]
): returnTrue
# Store group importance so future optimizers can access it. for manifest in test_manifests: if manifest notin groups: continue
@register_strategy("platform-disperse")
@register_strategy("platform-disperse-no-unseen", args=(None, 0))
@register_strategy( "platform-disperse-only-one",
args=(
{ "high": 1, "medium": 1, "low": 1, "lowest": 0,
},
0,
),
) class DisperseGroups(OptimizationStrategy): """Disperse groups across test configs.
Each task has an associated 'importance' dict passed in via the arg. This is of the form `{<group>: <importance>}`.
Where 'group'is a test group id (usually a path to a manifest), and'importance'is
one of `{'lowest', 'low', 'medium', 'high'}`.
Each importance value has an associated 'count'as defined in
`self.target_counts`. It guarantees that 'manifest' will run in at least 'count' different configurations (assuming there are enough tasks
containing 'manifest').
On configurations that haven't been seen before, we'll increase the target
count by `self.unseen_modifier` to increase the likelihood of scheduling a
task on that configuration.
Args:
target_counts (dict): Override DEFAULT_TARGET_COUNTS with custom counts. This is a dict mapping the importance value ('lowest', 'low', etc) to the
minimum number of configurations manifests with this value should run
on.
unseen_modifier (int): Override DEFAULT_UNSEEN_MODIFIER to a custom
value. This is the amount we'll increase 'target_count' by for unseen
configurations. """
# Build the test configuration key.
key = test_platform if"unittest_variant"in task.attributes:
key += "-" + task.attributes["unittest_variant"]
important_manifests = set(test_manifests) & set(importance) for manifest in important_manifests:
target_count = self.target_counts[importance[manifest]]
# If this configuration hasn't been seen before, increase the # likelihood of scheduling the task. if key notin self.seen_configurations:
target_count += self.unseen_modifier
if self.count[manifest] < target_count: # Update manifest counts and seen configurations.
self.seen_configurations.add(key) for manifest in important_manifests:
self.count[manifest] += 1 returnFalse
# Should remove task because all manifests have reached their # importance count (or there were no important manifests). returnTrue
¤ Dauer der Verarbeitung: 0.2 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.