diff options
| author | godosa <godosa@godosa.eu> | 2026-10-07 19:59:24 +0200 |
|---|---|---|
| committer | godosa <godosa@godosa.eu> | 2026-10-07 19:59:24 +0200 |
| commit | ea8bcc80ccbb3b7556d226d391189312fdd07321 (patch) | |
| tree | 723e92b5c5d8d39f96c51942ee7d93094d3e360f /wf_res.py | |
| parent | e6f7306c472a7589d08f4098e476d54bffd1f761 (diff) | |
| download | workflow-ea8bcc80ccbb3b7556d226d391189312fdd07321.tar.gz workflow-ea8bcc80ccbb3b7556d226d391189312fdd07321.zip | |
res: batch gate borrows batch claim; drop queued jobs of dead batch
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JEAjUkQRrCYX5MZhWxdtj2
Diffstat (limited to 'wf_res.py')
| -rw-r--r-- | wf_res.py | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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 |
