aboutsummaryrefslogtreecommitdiffziptar.gz
path: root/wf_res.py
diff options
context:
space:
mode:
Diffstat (limited to 'wf_res.py')
-rw-r--r--wf_res.py10
1 files changed, 10 insertions, 0 deletions
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