fix(krakenuniq/preloadedkrakenuniq): fix --preload-size handling, report optionality, and simplify stub - #12912
Conversation
….args2 --preload-size is a classify-time option that overrides --preload (per KrakenUniq's own docs, it's used on the same invocation as classification, not a separate step) - so it belongs in ext.args2, the slot that reaches the classify call, not ext.args, which only ever feeds the separate preload warm-up command. The preload_mode check looked at the wrong slot (task.ext.args instead of ext.args2), so a user following the existing test's precedent (setting --preload-size via ext.args) got it silently dropped entirely: the separate warm-up was skipped, but the flag never reached the classify call either since that only reads ext.args2. Also fixes an independent typo in the stub, where args2 read from task.ext.args instead of task.ext.args2 - a regression PR nf-core#11939 fixed in script: but missed in stub:. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
report_file (an input the user can set false) gates whether the --report-file flag is passed to krakenuniq, and thus whether *.krakenuniq.report.txt is ever created. But the report output was declared without optional: true, so setting report_file: false made Nextflow fail the task with a missing-output-file error even though the process itself ran successfully. Verified empirically before and after via nf-test. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Per the nf-core module spec, a stub only needs to create correctly named placeholder files for each output channel - it doesn't need to fake the real tool invocation. The stub was duplicating the entire script: command-construction logic (preload_cmd, args, per-option flags, the --paired branch) just to produce an unused `echo krakenuniq ...` line that had no bearing on which files got created. Replaced ~100 lines of duplicated branching with a single loop over the batch's prefixes that touches/gzips the same placeholder files as before - verified byte-identical via existing nf-test snapshots. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
e2d7368 to
592da6d
Compare
There was a problem hiding this comment.
Reviewed with some help from entirely by Claude Code.
Checked all three fixes carefully rather than trusting the description, and I think they're all correct:
- --preload-size fix: confirmed by reading the full (untouched) classify command that ${args2} is what actually reaches krakenuniq in both the single-end and paired branches, so checking args2 for --preload-size (rather than args) is the right place -- the old code's check against task.ext.args meant a flag set the way the original test set it (ext.args = '--preload-size 1GB') was silently ineffective twice over: the separate warm-up ran anyway (since args didn't have the string either, in the fixed check's frame), and the flag itself never reached classify since that only ever read args2. The new "sarscov2 - Illumina FASTQ single" test reads the real rendered .command.sh and asserts --preload --threads is absent -- traced this by hand against the old code and confirmed that specific assertion would actually have failed there, so it's a genuine regression test, not just decoration.
- optional: true on report: straightforward, matches the pattern the other three outputs already use, and the new "no optional outputs" test exercises the exact all-four-off case that used to crash.
- Stub simplification: traced the new merged_suffix logic against both deleted branches side by side for all four file patterns (classified/unclassified txt and gz, single vs. paired) -- byte-for-byte equivalent to what was there before. Confirmed the always-create-everything-regardless-of-flags behavior isn't a change either; the old stub did the same, the boolean-driven variables were only ever used inside the now-deleted unused echo krakenuniq ... line.
One thing worth a thought, not a blocking issue: now that --preload-size is only honoured via ext.args2, what happens to a user who -- understandably, given the original test itself made exactly this mistake -- still sets it via ext.args? As I read it, preload_mode would come out true (since args2 doesn't have the string), so the separate warm-up runs with --preload-size folded into args alongside --preload itself, which per KrakenUniq's own docs (--preload-size overrides --preload) sounds like a genuinely contradictory combination to hand it, rather than just a dropped flag. Not a regression from this PR -- the old code mishandled that case differently, not better -- and possibly out of scope for a bug-fix PR to also add misuse detection for a free-form ext.args/ext.args2 string. Just flagging in case it's worth a one-line note in meta.yml about where the flag belongs, given it's apparently an easy mistake to make.
Nothing else stood out. LGTM.
| def args = task.ext.args ?: '' | ||
| def args2 = task.ext.args2 ?: '' | ||
| def preload_mode = !task.ext.args.toString().contains('--preload-size') | ||
| def preload_mode = !args2.contains('--preload-size') |
There was a problem hiding this comment.
Traced this against the untouched classify command below (${args2} is what actually reaches krakenuniq in both branches) -- checking args2 here is correct. See the review body for the one open question this raised (what happens if a user sets --preload-size via ext.args instead, matching what the original test itself did).
|
Merging and will let |
PR checklist
Three related fixes to
krakenuniq/preloadedkrakenuniq, found while auditing the module.1.
--preload-sizewas silently droppedext.argsfeeds the module's separate preload warm-up call,ext.args2feeds the actual classify call. Per KrakenUniq's own docs,
--preload-sizeoverrides
--preloadand runs on the classify invocation itself, not aseparate step - so it belongs in
ext.args2. But the code that decideswhether to skip the separate warm-up checked
task.ext.argsinstead, so auser setting
--preload-sizeviaext.args(as the existing test did) hadit silently dropped entirely: the warm-up was skipped, and the flag never
reached classify either, since that only reads
ext.args2.Also fixes an independent typo in the stub, where
args2read fromtask.ext.argsinstead oftask.ext.args2- a regression PR #11939 fixedin
script:but missed instub:.2.
report_file: falsecrashed the processThe
reportoutput wasn't markedoptional: truedespite only beingcreated when
report_fileis true - so disabling it made Nextflow fail thetask with a missing-output-file error, even though the run itself succeeded.
3. Stub was needlessly complex
The stub duplicated the entire
script:command-construction logic (preloadcommand, args, per-flag options,
--pairedbranching) just to produce anunused
echo krakenuniq ...line - none of it affects which files actuallyget created. Per the nf-core module spec, a stub only needs to produce
correctly named placeholder files. Simplified from ~100 duplicated lines to
an ~18-line loop over the batch's prefixes; verified byte-identical output
against the existing snapshots.
nf-core modules test krakenuniq/preloadedkrakenuniq --profile dockernf-core modules test krakenuniq/preloadedkrakenuniq --profile singularitynf-core modules test krakenuniq/preloadedkrakenuniq --profile conda🤖 Generated with Claude Code