Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions bugbug/models/testselect.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def load_failing_together(task: str) -> dict[str, tuple[float, float]]:


def select_configs(
groups: Collection[str],
group_confidences: dict[str, float],
min_redundancy_confidence: float,
max_configurations: int = 3,
) -> dict[str, list[str]]:
Expand All @@ -290,6 +290,12 @@ def select_configs(
all_configs_by_group = pickle.loads(failing_together[b"$CONFIGS_BY_GROUP$"])
config_costs = {config: _get_cost(config) for config in all_configs}

all_groups = group_confidences.keys()
high_confidence_groups = {
group for group in all_groups if group_confidences.get(group, 0.0) >= 0.99
}
groups = [group for group in all_groups if group not in high_confidence_groups]
Comment thread
marco-c marked this conversation as resolved.

solver = pywraplp.Solver(
"select_configs", pywraplp.Solver.CBC_MIXED_INTEGER_PROGRAMMING
)
Expand All @@ -305,6 +311,14 @@ def select_configs(
)
}

# Configs used by high-confidence groups are already committed; fix their
# config_vars to 1 so the solver treats their fixed cost as already paid.
committed_configs = set()
for group in high_confidence_groups:
committed_configs |= set(all_configs_by_group.get(group, all_configs))
for config in committed_configs:
solver.Add(config_vars[config] == 1)

equivalence_sets = _get_equivalence_sets(min_redundancy_confidence)

for group in groups:
Expand Down Expand Up @@ -374,7 +388,10 @@ def select_configs(
)
)

configs_by_group: dict[str, list[str]] = {}
configs_by_group: dict[str, list[str]] = {
group: list(all_configs_by_group.get(group, all_configs))
for group in high_confidence_groups
}
for group in groups:
configs_by_group[group] = []

Expand Down Expand Up @@ -922,7 +939,14 @@ def eval_apply_transforms(
if granularity == "label":
selected = reduce_configs(selected, reduction)
elif granularity == "group":
group_configs = select_configs(selected, reduction)
group_configs = select_configs(
{
name: confidence
for name, confidence in push["all_possibly_selected"].items()
if name in selected
},
reduction,
)

if minimum is not None and len(selected) < minimum:
remaining = [
Expand Down
2 changes: 1 addition & 1 deletion http_service/bugbug_http/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def _analyze_patch(revs: list[bytes], branch: str | None) -> dict:
for group in test_scheduling.find_manifests_for_paths(REPO_DIR, modified_paths):
groups[group] = 1.0

config_groups = testselect.select_configs(groups.keys(), 0.9)
config_groups = testselect.select_configs(groups, 0.9)

data = {
"tasks": tasks,
Expand Down
49 changes: 23 additions & 26 deletions tests/test_testselect.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,37 +718,28 @@ def test_select_configs(failing_together_config_group: LMDBDict) -> None:
test_scheduling.close_failing_together_db("config_group")

result = testselect.select_configs(
{
"group1",
},
{"group1": 0.0},
1.0,
)
assert len(result) == 1
assert set(result["group1"]) == {"linux2404-64-asan/debug", "linux2404-64/opt"}

result = testselect.select_configs(
{
"group2",
},
{"group2": 0.0},
1.0,
)
assert len(result) == 1
assert set(result["group2"]) == {"linux2404-64/debug", "linux2404-64/opt"}

result = testselect.select_configs(
{
"group3",
},
{"group3": 0.0},
1.0,
)
assert len(result) == 1
assert set(result["group3"]) == {"windows10/debug", "linux2404-64/opt"}

result = testselect.select_configs(
{
"group1",
"group2",
},
{"group1": 0.0, "group2": 0.0},
1.0,
)
assert len(result) == 2
Expand All @@ -759,33 +750,23 @@ def test_select_configs(failing_together_config_group: LMDBDict) -> None:
}

result = testselect.select_configs(
{
"group1",
"group3",
},
{"group1": 0.0, "group3": 0.0},
1.0,
)
assert len(result) == 2
assert set(result["group1"]) == {"linux2404-64/opt", "linux2404-64-asan/debug"}
assert set(result["group3"]) == {"windows10/debug", "linux2404-64/opt"}

result = testselect.select_configs(
{
"group2",
"group3",
},
{"group2": 0.0, "group3": 0.0},
1.0,
)
assert len(result) == 2
assert set(result["group2"]) == {"linux2404-64/opt", "linux2404-64/debug"}
assert set(result["group3"]) == {"linux2404-64/opt", "windows10/debug"}

result = testselect.select_configs(
{
"group1",
"group2",
"group3",
},
{"group1": 0.0, "group2": 0.0, "group3": 0.0},
1.0,
)
assert len(result) == 3
Expand All @@ -796,3 +777,19 @@ def test_select_configs(failing_together_config_group: LMDBDict) -> None:
"linux2404-64-asan/debug",
}
assert set(result["group3"]) == {"linux2404-64/opt", "windows10/debug"}

# A group selected with >= 0.99 confidence runs on all its configs.
all_configs = {
"linux2404-64-asan/debug",
"linux2404-64/debug",
"linux2404-64/opt",
"mac/debug",
"windows10/debug",
}
result = testselect.select_configs(
{"group1": 0.99, "group2": 0.0},
1.0,
)
assert len(result) == 2
assert set(result["group1"]) == all_configs
assert set(result["group2"]) == {"linux2404-64/opt", "linux2404-64/debug"}