fixed day time testing
This commit is contained in:
+36
-9
@@ -24,6 +24,7 @@ class ScheduleWindow:
|
||||
shifts: list[tuple[date, int]]
|
||||
capacity_minutes: int
|
||||
remaining_minutes: int
|
||||
daytime_mode: bool = False
|
||||
assigned_device: str | None = None
|
||||
assigned_config: tuple[str, ...] | None = None
|
||||
|
||||
@@ -37,6 +38,8 @@ class Scheduler:
|
||||
start_date: str | None = None,
|
||||
holiday_dates: set[str] = set(),
|
||||
daytime_testing_today: bool = False,
|
||||
daytime_testing_hours: int = 8,
|
||||
daytime_testing_device: str | None = None,
|
||||
dual_device_weekend_start_enabled: bool = False,
|
||||
dual_device_window_start_dates: set[str] | None = None,
|
||||
priority_weight: int = 1000,
|
||||
@@ -49,6 +52,9 @@ class Scheduler:
|
||||
self.start_date = date.fromisoformat(start_date) if start_date else date.today()
|
||||
self.holiday_dates = holiday_dates
|
||||
self.daytime_testing_today = daytime_testing_today
|
||||
safe_daytime_hours = max(0, min(int(daytime_testing_hours), 8))
|
||||
self.daytime_testing_minutes = safe_daytime_hours * 60
|
||||
self.daytime_testing_device = daytime_testing_device if daytime_testing_device in {DUT, REF} else DUT
|
||||
self.dual_device_weekend_start_enabled = dual_device_weekend_start_enabled
|
||||
self.dual_device_window_start_dates = dual_device_window_start_dates or set()
|
||||
self.priority_weight = priority_weight
|
||||
@@ -76,6 +82,7 @@ class Scheduler:
|
||||
|
||||
window_index = 0
|
||||
cursor_date = self.start_date
|
||||
daytime_window_pending = self.daytime_testing_today and self.daytime_testing_minutes > 0
|
||||
|
||||
tc_order = self.get_tc_order(self.all_tests)
|
||||
|
||||
@@ -85,7 +92,7 @@ class Scheduler:
|
||||
print(f"[scheduler] No bundles found for TC: {tc}. Skipping to next TC.")
|
||||
continue
|
||||
print(f"[scheduler] Scheduling bundles for TC: {tc} with {len(tc_bundles)} bundles.")
|
||||
window_device = DUT
|
||||
night_window_device = DUT
|
||||
pending_dut: list[TestBundle] = []
|
||||
pending_ref: list[TestBundle] = []
|
||||
|
||||
@@ -98,17 +105,28 @@ class Scheduler:
|
||||
pending_ref.append(bundle)
|
||||
|
||||
while pending_dut or pending_ref:
|
||||
active_pending = pending_dut if window_device == DUT else pending_ref
|
||||
if len(active_pending) == 0:
|
||||
# If no unscheduled bundles for the current device, switch to the other device
|
||||
window_device = REF if window_device == DUT else DUT
|
||||
active_pending = pending_dut if window_device == DUT else 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
|
||||
|
||||
shifts, capacity = get_shift_sequence_with_capacity(cursor_date, self.holiday_dates, self.daytime_testing_today)
|
||||
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
|
||||
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
|
||||
|
||||
shifts, capacity = get_shift_sequence_with_capacity(
|
||||
cursor_date,
|
||||
self.holiday_dates,
|
||||
daytime_window_active,
|
||||
self.daytime_testing_minutes,
|
||||
)
|
||||
cursor_date_key = cursor_date.isoformat()
|
||||
dual_device_window = cursor_date_key in self.dual_device_window_start_dates
|
||||
if not dual_device_window and self.dual_device_weekend_start_enabled:
|
||||
dual_device_window = self._is_weekend_start_day(cursor_date)
|
||||
if daytime_window_active:
|
||||
dual_device_window = False
|
||||
|
||||
selected_bundles = []
|
||||
selected_bundles = self._knapsack_select(capacity, active_pending)
|
||||
@@ -130,6 +148,7 @@ class Scheduler:
|
||||
shifts=shifts,
|
||||
capacity_minutes=capacity,
|
||||
remaining_minutes=remaining_time,
|
||||
daytime_mode=daytime_window_active,
|
||||
assigned_config=tc,
|
||||
assigned_device=primary_device,
|
||||
)
|
||||
@@ -148,8 +167,11 @@ class Scheduler:
|
||||
pending_ref = [b for b in pending_ref if (b.index, b.device) not in selected_keys]
|
||||
|
||||
window_index += 1
|
||||
window_device = REF if window_device == DUT else DUT
|
||||
if not daytime_window_active:
|
||||
night_window_device = REF if night_window_device == DUT else DUT
|
||||
cursor_date = next_window_start_date(shifts)
|
||||
if daytime_window_active:
|
||||
daytime_window_pending = False
|
||||
|
||||
return None
|
||||
|
||||
@@ -250,7 +272,12 @@ class Scheduler:
|
||||
) -> None:
|
||||
# Build per-shift remaining capacity
|
||||
shift_remaining = [
|
||||
get_shift_capacity_for_date(day, self.holiday_dates, self.daytime_testing_today).get(shift_idx, 0)
|
||||
get_shift_capacity_for_date(
|
||||
day,
|
||||
self.holiday_dates,
|
||||
window.daytime_mode,
|
||||
self.daytime_testing_minutes,
|
||||
).get(shift_idx, 0)
|
||||
for day, shift_idx in window.shifts
|
||||
]
|
||||
current_shift_pos = 0
|
||||
|
||||
Reference in New Issue
Block a user