From ea8bcc80ccbb3b7556d226d391189312fdd07321 Mon Sep 17 00:00:00 2001 From: godosa Date: Wed, 7 Oct 2026 19:59:24 +0200 Subject: res: batch gate borrows batch claim; drop queued jobs of dead batch Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01JEAjUkQRrCYX5MZhWxdtj2 --- wf_res.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'wf_res.py') diff --git a/wf_res.py b/wf_res.py index cc9a415..9e90661 100644 --- a/wf_res.py +++ b/wf_res.py @@ -391,6 +391,12 @@ def _new_entry(env, led, facts, args, mem, est, state) -> res.Entry: by=owner_by(env, getattr(args, "by", "") or "")) +def _new_probe(env, args) -> res.Entry: + """Entry stand-in (no id) for capacity checks that depend on who starts it (res.loan).""" + return res.Entry(id="", project="", owner=0, title=args.title, mem_gb=0.0, cpus=0, est_min=0, state="queued", + by=owner_by(env, getattr(args, "by", "") or "")) + + def force_busy(cfg, led, facts, mem, cpus, room) -> str: """--force refused: not even the really free memory (beyond the user reserve) holds it.""" free = f"{res.fmt_gb(max(0.0, room[0]))}" if mem > room[0] + res.EPS else f"{max(0, room[1])} cpus" @@ -425,6 +431,10 @@ def cmd_run(env, cfg, args) -> int: room = res.force_room(cfg, led, facts) if args.force else res.budget(cfg, led, facts) if args.force: q_gb, q_cpus = 0.0, 0 + probe = _new_probe(env, args) + if not args.force: # a batch's own job borrows the batch's claim (res.loan) + l_gb, l_cpus = res.loan(led, probe) + room = (room[0] + l_gb, room[1] + l_cpus) if res.fits(mem + q_gb, args.cpus + q_cpus, room): e = _new_entry(env, led, facts, args, mem, est, "queued") e.cmd, e.env, e.lock = cmd, caller_env, lock -- cgit