diff --git a/skills/kvb-org-queue/scripts/queue.py b/skills/kvb-org-queue/scripts/queue.py index b2f4ea8..1ca5f1b 100755 --- a/skills/kvb-org-queue/scripts/queue.py +++ b/skills/kvb-org-queue/scripts/queue.py @@ -706,9 +706,9 @@ def evaluate(entries: list[dict], free_gb: float, floor: float, stage: str, memo hotfix head, and behind any head whose kind is exclusive or that live load holds while queue jobs run; light ones wait too while load the queue causes holds a hotfix head. Behind an exclusive entry that only - live load holds, from the queue or outside it, head or not, no later - entry but a light one starts (loaded_exclusive()): it would keep that - entry out once the load drops. An entry never passes an active, + load the queue causes holds, head or not, no later entry but a light + one starts (loaded_exclusive()): it would keep that entry out once the + load drops. An entry never passes an active, granted or waiting entry enqueued before it that shares one of its claims (claims(): worktree, compose stack, slot): those form its line, which runs by enqueue time alone (in_lines()), never by rank, @@ -870,11 +870,15 @@ def loaded_exclusive(able: list[dict], verdicts: dict[str, str | None], loaded: """Returns: The id of the first entry of able (blocked, not unstartable()) whose kind is exclusive and that only live load holds back (its verdict is - its loaded reason), whether the queue or something outside it causes - the load; a job of a kind that is not light, started now, would keep - it out once the load drops (alone_reason()). None when there is none. + its loaded reason), the queue's own jobs causing that load; a job of + a kind that is not light, started now, would keep it out once they + end (alone_reason()). None when there is none. An Outside reason + never counts: the entry stays out with the queue empty, so holding + others back would only starve them while that load lasts, and once + it drops, the jobs then running turn the reason into the queue's. """ - return next((e["id"] for e in able if e["kind"] in exclusive and e["id"] in loaded and verdicts[e["id"]] == loaded[e["id"]]), None) + return next((e["id"] for e in able if e["kind"] in exclusive and e["id"] in loaded and not isinstance(loaded[e["id"]], Outside) + and verdicts[e["id"]] == loaded[e["id"]]), None) def drained(order: list[dict], verdicts: dict[str, str | None], drain: str | None, could: set[str], diff --git a/tests/test_queue.py b/tests/test_queue.py index 1413b9a..cdc8a84 100644 --- a/tests/test_queue.py +++ b/tests/test_queue.py @@ -724,7 +724,7 @@ class TestBackfill(Passes, unittest.TestCase): waiting = [e for e in waiting if verdicts[e["id"]] is not None] self.fail("a steady stream starved the head") - def test_r4_load_from_outside_the_queue_drains_for_no_head_and_holds_back_only_non_light_jobs_behind_an_exclusive_one(self): + def test_r4_load_from_outside_the_queue_drains_for_no_head_and_holds_back_no_job_while_queue_load_holds_heavy_ones_behind_an_exclusive_one(self): rules = {"exclusive": {"quality-high", "test"}, "light": {"test-nostack"}, "slot_limits": {"quality-high": 1, "test": 1, "test-nostack": 4, "iteration": 3}} head, light = job(1, kind="quality-high", enqueued=NOW - 3700), job(2, kind="test-nostack", task="work/b", workdir="/l") @@ -734,14 +734,14 @@ class TestBackfill(Passes, unittest.TestCase): self.assertEqual(self.run_pass([head, light, heavy], loaded={"j1": ram}, drain="j1", **rules)[:2], ({"j1": ram, "j2": None, "j3": "waits behind exclusive j1"}, None)) self.assertEqual(self.run_pass([running, head, light, heavy], loaded={"j1": outside}, drain="j1", **rules)[:2], - ({"j1": ram, "j2": None, "j3": "waits behind exclusive j1"}, None)) + ({"j1": ram, "j2": None, "j3": None}, None)) self.assertEqual(self.run_pass([running, head, light, heavy], loaded={"j1": ram}, drain="j1", **rules)[:2], ({"j1": ram, "j2": None, "j3": "drained for j1"}, "j1")) self.assertEqual(self.run_pass([{**head, "kind": "iteration"}, light, heavy], loaded={"j1": ram}, drain="j1", **rules)[:2], ({"j1": ram, "j2": None, "j3": None}, None)) twin = job(4, kind="test", task="work/c", workdir="/w1") self.assertEqual((self.decide([head, twin], loaded={"j1": outside}, **rules), self.decide([head, twin], loaded={"j1": ram}, **rules)), - ({"j1": ram, "j4": "waits behind exclusive j1"}, {"j1": ram, "j4": "waits in line behind j1"})) + ({"j1": ram, "j4": None}, {"j1": ram, "j4": "waits in line behind j1"})) def test_r12_a_test_job_never_backfills_past_an_exclusive_head_the_load_holds_while_no_job_runs(self): rules = {"exclusive": {"quality-high"}, "light": {"test-nostack"}, "slot_limits": {"quality-high": 1, "test": 1, "test-nostack": 4}}