From b83678ad47df1064e964020550d49a9c789d3ebc Mon Sep 17 00:00:00 2001 From: f3ranmi Date: Mon, 5 Jan 2026 19:12:02 +0100 Subject: [PATCH] [testselect] KeyError in equivalence_sets[group] #5577 fix --- bugbug/models/testselect.py | 29 +++++++++++++++++++++++++++++ http_service/bugbug_http/models.py | 3 ++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/bugbug/models/testselect.py b/bugbug/models/testselect.py index bdb2709101..fcf4be64df 100644 --- a/bugbug/models/testselect.py +++ b/bugbug/models/testselect.py @@ -311,6 +311,35 @@ def select_configs( # Create constraints to ensure at least one task from each set of equivalent # groups is selected. + # Generate equivalence sets for groups that don't exist in the precomputed sets + if group not in equivalence_sets: + logger.warning( + f"Group {group} not found in equivalence sets, generating on-the-fly" + ) + key = test_scheduling.failing_together_key(group) + try: + failing_together_stats = pickle.loads(failing_together[key]) + except KeyError: + failing_together_stats = {} + + def load_failing_together( + config: str, + ) -> dict[str, tuple[float, float]]: + try: + return failing_together_stats[config] + except KeyError: + return {} + + configs = ( + all_configs_by_group[group] + if group in all_configs_by_group + else all_configs + ) + + equivalence_sets[group] = _generate_equivalence_sets( + configs, min_redundancy_confidence, load_failing_together, True + ) + mutually_exclusive = True seen = set() for equivalence_set in equivalence_sets[group]: diff --git a/http_service/bugbug_http/models.py b/http_service/bugbug_http/models.py index 77a73d0c5d..e07d418fd6 100644 --- a/http_service/bugbug_http/models.py +++ b/http_service/bugbug_http/models.py @@ -279,7 +279,8 @@ def get_config_specific_groups(config: str) -> str: [ {"name": group} for group in past_failures_data.all_runnables - if any( + if group in equivalence_sets + and any( equivalence_set == {config} for equivalence_set in equivalence_sets[group] )