rerun tests scheduled immediately

This commit is contained in:
2026-08-03 16:11:33 -04:00
parent 424dea6e10
commit 462ef5c2f1
2 changed files with 22 additions and 9 deletions
+6 -6
View File
@@ -527,17 +527,17 @@ def compile_schedule_endpoint(request: CompileScheduleRequest, _admin_user: auth
holiday_dates = db.list_holidays(DB_PATH)
top_priority_pairs: set[tuple[str, str]] = set()
dut_top_priority_ids = {item.strip() for item in request.top_priority_tests_dut if item.strip()}
ref_top_priority_ids = {item.strip() for item in request.top_priority_tests_ref if item.strip()}
dut_top_priority_ids = {item.strip().upper() for item in request.top_priority_tests_dut if item.strip()}
ref_top_priority_ids = {item.strip().upper() for item in request.top_priority_tests_ref if item.strip()}
status_lookup = {(test.test_id, test.device): test.status for test in stored_tests}
for test_id in dut_top_priority_ids:
if any(t.test_id == test_id and t.device == DUT for t in stored_tests):
top_priority_pairs.add((test_id, DUT))
if any(t.test_id.upper() == test_id and t.device == DUT for t in stored_tests):
top_priority_pairs.add((next(t.test_id for t in stored_tests if t.test_id.upper() == test_id and t.device == DUT), DUT))
for test_id in ref_top_priority_ids:
if any(t.test_id == test_id and t.device == REF for t in stored_tests):
top_priority_pairs.add((test_id, REF))
if any(t.test_id.upper() == test_id and t.device == REF for t in stored_tests):
top_priority_pairs.add((next(t.test_id for t in stored_tests if t.test_id.upper() == test_id and t.device == REF), REF))
scheduler = Scheduler(
all_tests=all_tests,
+16 -3
View File
@@ -4,7 +4,7 @@ import os
from dataclasses import dataclass
from datetime import date, timedelta
from test_window import get_shift_sequence_with_capacity, get_shift_capacity_for_date, is_off_day, next_window_start_date
from test_bundle import Test, TestBundle, build_test_bundles, update_mirrored_bundle_priorities
from test_bundle import Test, TestBundle, build_test_bundles, update_mirrored_bundle_priorities, BUNDLE_PRIORITY_RERUN, BUNDLE_PRIORITY_USER_TOP
DUT = (os.getenv("DUT") or "DUT").strip()
REF = (os.getenv("REF") or "REF").strip()
@@ -105,10 +105,12 @@ class Scheduler:
pending_ref.append(bundle)
# If there is priority 0 bundle in REF bundle, device should be REF for the first window, otherwise DUT
if any(bundle.priority == 0 for bundle in pending_ref):
if any(bundle.priority == BUNDLE_PRIORITY_RERUN for bundle in pending_ref):
print(f"[scheduler] Found priority 0 bundle in REF for TC: {tc}. Setting night window device to REF.")
night_window_device = REF
# If there is priority 1 bundle in REF but not in DUT, device should be REF for the first window, otherwise DUT
elif any(bundle.priority == 1 for bundle in pending_ref) and not any(bundle.priority == 1 for bundle in pending_dut):
elif any(bundle.priority == BUNDLE_PRIORITY_USER_TOP for bundle in pending_ref) and not any(bundle.priority == BUNDLE_PRIORITY_USER_TOP for bundle in pending_dut):
print(f"[scheduler] Found priority 1 bundle in REF for TC: {tc} but not in DUT. Setting night window device to REF.")
night_window_device = REF
while pending_dut or pending_ref:
@@ -118,6 +120,7 @@ class Scheduler:
active_pending = pending_dut if window_device == DUT else pending_ref
if len(active_pending) == 0 and not daytime_window_active:
# If no unscheduled bundles for the current device, switch to the other device
print(f"[scheduler] No unscheduled bundles for device {window_device} on {cursor_date}. Switching to the other device.")
night_window_device = REF if night_window_device == DUT else DUT
window_device = night_window_device
active_pending = pending_dut if night_window_device == DUT else pending_ref
@@ -375,6 +378,16 @@ class Scheduler:
# Sort TCs by the number of bundles available for each TC (most to least)
sorted_tcs = sorted(all_bundles_by_tc.keys(), key=lambda tc: len(all_bundles_by_tc[tc]), reverse=True)
# If there are TCs with rerun and user top priority bundles, prioritize them first
prioritized_tcs = []
for tc in sorted_tcs:
bundles = all_bundles_by_tc[tc]
if any(b.priority == BUNDLE_PRIORITY_RERUN for b in bundles) or any(b.priority == BUNDLE_PRIORITY_USER_TOP for b in bundles):
prioritized_tcs.append(tc)
# Place prioritized TCs at the beginning of the list
sorted_tcs = prioritized_tcs + [tc for tc in sorted_tcs if tc not in prioritized_tcs]
return sorted_tcs