From 0e7f55ed8bf7736b0886e8134adc05acd3bf8783 Mon Sep 17 00:00:00 2001 From: Mia Wu Date: Mon, 27 Jul 2026 14:52:39 -0400 Subject: [PATCH] fixed top priority tests and start with correct device --- backend/app.py | 13 ++----------- backend/scheduler.py | 7 +++++++ backend/test_bundle.py | 9 +++++---- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/backend/app.py b/backend/app.py index d8944a1..dfffaac 100644 --- a/backend/app.py +++ b/backend/app.py @@ -428,22 +428,13 @@ def compile_schedule_endpoint(request: CompileScheduleRequest) -> dict[str, Any] ref_top_priority_ids = {item.strip() 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} - # Backward compatibility: if only legacy top_priority_tests was sent, - # keep previous behavior by applying IDs to whichever device has that test. - if not dut_top_priority_ids and not ref_top_priority_ids and request.top_priority_tests: - for test_id in {item.strip() for item in request.top_priority_tests if item.strip()}: - if any(t.test_id == test_id and t.device == DUT for t in stored_tests): - dut_top_priority_ids.add(test_id) - if any(t.test_id == test_id and t.device == REF for t in stored_tests): - ref_top_priority_ids.add(test_id) - 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((DUT, test_id)) + top_priority_pairs.add((test_id, 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((REF, test_id)) + top_priority_pairs.add((test_id, REF)) scheduler = Scheduler( all_tests=all_tests, diff --git a/backend/scheduler.py b/backend/scheduler.py index 0f8fce0..3ab4fd9 100644 --- a/backend/scheduler.py +++ b/backend/scheduler.py @@ -104,6 +104,13 @@ class Scheduler: elif bundle.device == REF: 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): + 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): + night_window_device = REF + while pending_dut or pending_ref: daytime_window_active = daytime_window_pending and not is_off_day(cursor_date, self.holiday_dates) window_device = self.daytime_testing_device if daytime_window_active else night_window_device diff --git a/backend/test_bundle.py b/backend/test_bundle.py index 82f1b6b..99b4654 100644 --- a/backend/test_bundle.py +++ b/backend/test_bundle.py @@ -44,6 +44,7 @@ class TestBundle: def build_test_bundles(active_dut: dict[str, Test], active_ref: dict[str, Test], top_priority_tests: set[tuple[str, str]]) -> list[TestBundle]: """Build deterministic bundles for DP scheduling.""" + print(f"Top priority tests: {top_priority_tests}") processed_dut: set[str] = set() processed_ref: set[str] = set() test_bundles: list[TestBundle] = [] @@ -87,7 +88,7 @@ def build_test_bundles(active_dut: dict[str, Test], active_ref: dict[str, Test], dut_bundled_tests = dedupe_preserve_order(dut_bundled_tests) # Check if any of the DUT tests in this bundle are in the top priority list - if any((DUT, dut_test_id) in top_priority_tests for dut_test_id in dut_bundled_tests): + if any((dut_test_id, DUT) in top_priority_tests for dut_test_id in dut_bundled_tests): priority = BUNDLE_PRIORITY_USER_TOP # Check if any of the DUT tests in this bundle are reruns @@ -108,7 +109,7 @@ def build_test_bundles(active_dut: dict[str, Test], active_ref: dict[str, Test], processed_ref.update(ref_bundled_tests) # Check if any of the REF tests in this bundle are in the top priority list - if any((REF, ref_test_id) in top_priority_tests for ref_test_id in ref_bundled_tests): + if any((ref_test_id, REF) in top_priority_tests for ref_test_id in ref_bundled_tests): priority = BUNDLE_PRIORITY_USER_TOP # Check if any of the REF tests in this bundle are reruns elif any((ref_test.status == "rerun" for ref_test_id in ref_bundled_tests if (ref_test := active_ref.get(ref_test_id)))): @@ -137,7 +138,7 @@ def build_test_bundles(active_dut: dict[str, Test], active_ref: dict[str, Test], priority = BUNDLE_PRIORITY_P3P # Check if any of the DUT tests in this bundle are in the top priority list - if any((DUT, dut_test_id) in top_priority_tests for dut_test_id in dut_bundled_tests): + if any((dut_test_id, DUT) in top_priority_tests for dut_test_id in dut_bundled_tests): priority = BUNDLE_PRIORITY_USER_TOP # Check if any of the DUT tests in this bundle are reruns @@ -155,7 +156,7 @@ def build_test_bundles(active_dut: dict[str, Test], active_ref: dict[str, Test], ] # Check if any of the REF tests in this bundle are in the top priority list - if any((REF, ref_test_id) in top_priority_tests for ref_test_id in ref_bundled_tests): + if any((ref_test_id, REF) in top_priority_tests for ref_test_id in ref_bundled_tests): priority = BUNDLE_PRIORITY_USER_TOP # Check if any of the REF tests in this bundle are reruns elif any((ref_test.status == "rerun" for ref_test_id in ref_bundled_tests if (ref_test := active_ref.get(ref_test_id)))):