fix tc ordering
This commit is contained in:
+3
-1
@@ -387,6 +387,7 @@ def compile_schedule_endpoint(request: CompileScheduleRequest) -> dict[str, Any]
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail="start_date must be YYYY-MM-DD") from exc
|
||||
|
||||
all_tests = db.get_not_excluded_tests(DB_PATH, rule=request.rule)
|
||||
stored_tests = db.list_schedulable_tests(DB_PATH, rule=request.rule)
|
||||
if not stored_tests:
|
||||
version = db.create_schedule_version([], DB_PATH)
|
||||
@@ -437,7 +438,8 @@ def compile_schedule_endpoint(request: CompileScheduleRequest) -> dict[str, Any]
|
||||
top_priority_pairs.add((test_id, REF))
|
||||
|
||||
scheduler = Scheduler(
|
||||
tests=scheduler_tests,
|
||||
all_tests=all_tests,
|
||||
schedulable_tests=scheduler_tests,
|
||||
top_priority_tests=top_priority_pairs,
|
||||
start_date=request.start_date,
|
||||
holiday_dates=holiday_dates,
|
||||
|
||||
+5
-7
@@ -399,8 +399,8 @@ def get_completed_dut_test_ids(db_path: str | Path = DB_PATH) -> set[str]:
|
||||
return {row["test_id"] for row in rows}
|
||||
|
||||
# Get tests for device that are not excluded regardless of completion status.
|
||||
def get_not_excluded_tests(device: str, db_path: str | Path = DB_PATH, rules: dict[str, Any] | None = None) -> list[TestRecord]:
|
||||
tokens = _parse_rule_tokens(rules.get("rule") if rules else "") if rules else []
|
||||
def get_not_excluded_tests(db_path: str | Path = DB_PATH, rule: str = "") -> list[TestRecord]:
|
||||
tokens = _parse_rule_tokens(rule)
|
||||
with get_connection(db_path) as conn:
|
||||
rows = conn.execute(
|
||||
"""
|
||||
@@ -411,12 +411,10 @@ def get_not_excluded_tests(device: str, db_path: str | Path = DB_PATH, rules: di
|
||||
excluded, status, raw_payload
|
||||
FROM tests
|
||||
WHERE excluded = 0
|
||||
AND device = ?
|
||||
""",
|
||||
(device,)
|
||||
"""
|
||||
).fetchall()
|
||||
|
||||
results: list[TestRecord] = []
|
||||
|
||||
results: list[TestRecord] = []
|
||||
for row in rows:
|
||||
results.append(
|
||||
TestRecord(
|
||||
|
||||
@@ -31,7 +31,8 @@ class ScheduleWindow:
|
||||
class Scheduler:
|
||||
def __init__(
|
||||
self,
|
||||
tests: list[Test],
|
||||
all_tests: list[Test],
|
||||
schedulable_tests: list[Test],
|
||||
top_priority_tests: set[tuple[str, str]],
|
||||
start_date: str | None = None,
|
||||
holiday_dates: set[str] = set(),
|
||||
@@ -40,10 +41,11 @@ class Scheduler:
|
||||
dual_device_window_start_dates: set[str] | None = None,
|
||||
priority_weight: int = 1000,
|
||||
):
|
||||
self.all_tests = all_tests
|
||||
self.schedulable_tests = schedulable_tests
|
||||
self.top_priority_tests = top_priority_tests
|
||||
self.tests = tests
|
||||
self.active_dut: dict[str, Test] = {test.test_id: test for test in tests if test.device == DUT}
|
||||
self.active_ref: dict[str, Test] = {test.test_id: test for test in tests if test.device == REF}
|
||||
self.active_dut: dict[str, Test] = {test.test_id: test for test in schedulable_tests if test.device == DUT}
|
||||
self.active_ref: dict[str, Test] = {test.test_id: test for test in schedulable_tests if test.device == REF}
|
||||
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
|
||||
@@ -75,13 +77,14 @@ class Scheduler:
|
||||
window_index = 0
|
||||
cursor_date = self.start_date
|
||||
|
||||
tc_order = self.get_tc_order(self.tests)
|
||||
tc_order = self.get_tc_order(self.all_tests)
|
||||
|
||||
for tc in tc_order:
|
||||
tc_bundles = all_bundles_by_tc[tc]
|
||||
if tc_bundles is None or len(tc_bundles) == 0:
|
||||
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
|
||||
pending_dut: list[TestBundle] = []
|
||||
pending_ref: list[TestBundle] = []
|
||||
|
||||
Reference in New Issue
Block a user