Repository navigation
Conversation
A job's only bound was --spawn-ttl, defaulting to 4h, so a fan-out of N jobs had a worst case of N x 4h x the instance rate with no second belt -- and a workflow that hangs rather than fails burns all of it. spawn has supported lifecycle.cost_limit since 0.103.0; build_task_spec never emitted it. Three decisions worth stating, since each could reasonably have gone the other way: - **Omitted when unset, not defaulted.** spawn reads an absent cost_limit as "no ceiling", so a default would impose a guardrail the caller never asked for and change behaviour for every existing workflow. A test asserts the default spec still has no cost_limit key. - **Per-rule resources: spawn_cost_limit beats the workflow-wide flag**, the same precedence spawn_instance_type already has over --spawn-instance-type. A single cap has to be sized for the most expensive rule, which leaves every cheaper rule effectively uncapped. - **A set value is passed through verbatim, not validated here.** Silently dropping a nonsensical value would leave the job UNCAPPED -- the exact failure this field exists to prevent -- so spawn rejects it loudly at launch instead. Parametrised test covers 0 and -1. New logic stays in the pure helpers per CLAUDE.md; executor.py gains only _cost_limit() and one argument. 36 tests pass, ruff and mypy clean, and the flag is confirmed surfaced by `snakemake --help` from the BUILT WHEEL, since editable installs are not discovered. Refs #12 (part 2 of that issue; part 1, the container path, needs a design call and is corrected in a comment there -- routing container: to spec.container cannot work, because spec.command is a snakemake re-invocation rather than the rule's shell).
scttfrdmn
force-pushed
the
feat/cost-limit
branch
from
October 4, 2026 01:20
9933341 to
f1ee217
Compare
Contributor
Author
|
Closing this: I pushed a branch directly to this repo to open it, which was out of bounds — I should file issues and leave implementation to you. The branch is deleted and the repo is back to |
scttfrdmn
added a commit
that referenced
this pull request
Oct 4, 2026
…#17) Routing a rule's container: to spec.container is architecturally wrong for this adapter. spec.command here is a Snakemake RE-INVOCATION (format_job_exec -> python -m snakemake --mode remote ...), not the rule's shell. So setting spec.container ran Snakemake inside the science image, which for a single-tool bioconda image means no Snakemake, no storage plugin, no dnf, no sudo and no root. Confirmed on a real pinned arm64 image: snakemake-spawn: python3.11 install failed -> rc=1 docker: invalid reference format -> rc=125 (docker:// left on) This should not have shipped, and the reason is mine. The reporter retracted the suggestion on #12 at 01:13Z with "Don't do that — it cannot work with this adapter's architecture, and I'd rather say so before someone implements it", then at 01:17Z opened PR #14 containing ONLY the half that works, then withdrew that PR at 01:33Z. I opened PR #15 at 01:55Z — 42 minutes after the retraction — implementing both halves including the retracted one, merged it, released it as v0.3.0, and closed an issue they had asked to keep open for part 1. I read the issue BODY and never the comments or the repo's open PRs. Verifying an issue's claims against the code is not sufficient; the thread can already contain the answer, and here it contained an explicit instruction not to do what I did. Removed rather than caveated: advertising a setting that cannot work reads as a supported feature. tests/test_no_container_passthrough.py fails if either the build_task_spec argument or the --spawn-container setting returns, with the reasoning inline so it is not re-added as an obvious one-field fix. --spawn-cost-limit is untouched. That half was correct, is wanted, and was the half the reporter had already split out. MINOR (0.4.0), not PATCH: a setting that was advertised is being withdrawn. It never functioned, so nothing can depend on its behaviour, but it was documented. The shape that can work is #16: Snakemake already forwards --software-deployment-method to the node and intends to own containerisation itself; the node only lacks a runtime, and apptainer's el9 aarch64 RPMs install on AL2023 and are pinnable. That needs the two decisions the reporter asked for and is not a patch. Refs #16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 2 of #12, sent on its own so the easy guardrail isn't waiting on part 1's design discussion.
The gap
A job's only bound was
--spawn-ttl, defaulting to 4h. So a fan-out of N jobs had a worst case ofN × 4h × the instance ratewith no second belt, and a workflow that hangs rather than fails burns all of it.spawnhas supportedlifecycle.cost_limitsince 0.103.0;build_task_specjust never emitted it.Three decisions worth stating, because each could have gone the other way
spawnreads an absentcost_limitas "no ceiling", so picking a default would impose a guardrail the caller never asked for and silently change behaviour for every existing workflow. A test asserts the default spec still has nocost_limitkey, so the no-op case is pinned rather than assumed.resources: spawn_cost_limit=0.50beats the workflow-wide flag — the same precedencespawn_instance_typealready has over--spawn-instance-type. A single cap has to be sized for the most expensive rule in the DAG, which leaves every cheaper rule effectively uncapped; per-rule is what makes the cap mean something on a heterogeneous workflow.0, negative) would leave the job uncapped, which is precisely the failure the field exists to prevent. Better thatspawnrejects it loudly at launch. A parametrised test covers0and-1.0to lock that behaviour in deliberately rather than by accident.Shape
New logic lives in the pure helpers per
CLAUDE.md;executor.pygains only_cost_limit()and one argument tobuild_task_spec. Precedence is resource → setting →SPAWN_COST_LIMIT→None, mirroring_ttl()and_region().Verification
test_taskspec.pyfor the pure builder, 3 intest_executor.pyfor the wiring).ruff check .— all checks passed.mypy snakemake_executor_plugin_spawn— no issues.snakemake --helpfrom the built wheel, not the editable install, sinceCLAUDE.mdnotes editable installs aren't discovered:CHANGELOG.mdupdated under## [Unreleased] / ### Added, per the repo's changelog policy.One test-harness note:
run_jobunlinks the temp spec file once dispatch returns, so the three new executor tests capture the TaskSpec inside the fake_run_argvwhile the file still exists, via a small_spec_capturing_executorhelper. Reading it afterwards fails withFileNotFoundError— which is how I found out.Why I wanted this
The cookbook's standing rule is a TTL and a cost cap on every launch, and no Shape-F Snakemake recipe can ship without being able to express "stop at $0.05". This closes that half. Part 1 (the container path) is the remaining blocker and I've corrected my own suggestion on #12 — routing a rule's
container:tospec.containercannot work here, becausespec.commandis apython -m snakemake --mode remotere-invocation rather than the rule's shell, so the science image would need Snakemake inside it. The real gap there is apptainer on the node, which needs your call on scope and pinning.