Skip to content

fix(qpx): use write_dataset_mudata so a partial MuData cannot ship - #732

Closed
ypriverol wants to merge 1 commit into
bigbio:devfrom
ypriverol:fix/qpx-mudata-modality-guard
Closed

ypriverol wants to merge 1 commit into
bigbio:devfrom
ypriverol:fix/qpx-mudata-modality-guard

Conversation

@ypriverol

Copy link
Copy Markdown
Contributor

Draft until qpx 1.1.4 is tagged — the ghcr.io/bigbio/qpx:1.1.4 image does not exist yet, so CI will fail to pull it. Depends on bigbio/qpx#316.

The problem

QPX_OPENMSCONSENSUS calls build_mudata() + mdata.write() directly, which bypasses qpx's own writer. write_dataset_mudata checks:

missing = required_modalities - set(mdata.mod)
if missing:
    raise ValueError(f"Missing required quantification modalities: ...")

build_mudata catches per-modality build failures, logs them, and continues — so a modality that fails to build is simply absent from the result. The module then wrote that incomplete MuData and the task exited 0.

This is not theoretical. Validating the 1.1.4 container against MSV000085836 (TMT, 552 runs x 10 channels) produced:

Failed to build precursors modality: offset overflow while concatenating arrays
...
modalities present: ['proteins']

A 451 MB h5mu with no precursors, reported as success. The underlying overflow is fixed in bigbio/qpx#316 (that dataset now yields ['precursors', 'proteins'], 988 MB), but the module would have shipped the partial view for any future modality failure — so the guard matters independently of that bug.

Changes

  1. Use write_dataset_mudata. Gets the modality guard, plus a tmp-file write and removal of a stale h5mu when the build fails — neither of which the inline heredoc did.
  2. Make *.h5mu optional. It had been made a required output, which inverted qpx's contract: the parquet views are the dataset's source of truth and the MuData view is explicitly best-effort. A view that cannot be built should not destroy an otherwise complete run — which is exactly what happened on MSV000085836, where a ~1h19 conversion succeeded and the run died afterwards on the h5mu step.
  3. Bump container and conda pins to 1.1.4.

Net behaviour: a complete view, or no view plus a warning — never a silently partial one.

Scope check

out.mudata is consumed only by this module's own nf-test (assert process.out.mudata.size() == 1), which exercises the stub and still passes; no workflow consumes the channel, so optional: true changes nothing downstream.

QPX_OPENMSCONSENSUS called build_mudata() + mdata.write() directly. That
bypasses qpx's own writer, which checks

    missing = required_modalities - set(mdata.mod)

and refuses a MuData missing a required quantification modality.

build_mudata catches per-modality failures, logs them and continues, so a
modality that failed to build was simply absent: the module wrote an
INCOMPLETE h5mu and the task exited 0. On MSV000085836 (TMT) that shipped
a view with proteins and no precursors, from a pyarrow offset overflow
(bigbio/qpx#316).

Also make *.h5mu an optional output. It was made required, which inverted
qpx's contract: the parquet views are the dataset's source of truth and
the MuData view is best-effort, so a view that cannot be built must not
destroy an otherwise complete run. Combined with the writer's guard the
behaviour is now: complete view, or no view and a warning - never a
silently partial one.

write_dataset_mudata also writes via a temporary file and removes a stale
h5mu when the build fails, which the inline heredoc did not.

Requires qpx 1.1.4: write_dataset_mudata was extracted in bigbio/qpx#312
and the overflow fixed in bigbio/qpx#316. Container and conda pins bumped.
@coderabbitai

coderabbitai Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 3329141d-52a7-4288-8fed-1c0cebd60602

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

nf-core pipelines lint overall result: Passed ✅ ⚠️

Posted for pipeline commit 78bc810

+| ✅ 117 tests passed       |+
#| ❔  18 tests were ignored |#
#| ❔   1 tests had warnings |#
!| ❗   7 tests had warnings |!
Details

❗ Test warnings:

❔ Tests ignored:

❔ Tests fixed:

✅ Tests passed:

Run details

  • nf-core/tools version 4.1.0
  • Run at 2026-09-13 05:15:09

@ypriverol
ypriverol marked this pull request as ready for review September 16, 2026 04:33
@ypriverol

Copy link
Copy Markdown
Contributor Author

qpx 1.1.4 is released: ghcr.io/bigbio/qpx:1.1.4 is on GHCR (verified pullable, and stamped 1.1.4 — the floating :dev tag reports 0.0.0.dev0, which would land in dataset provenance and versions.yml), and qpx==1.1.4 is on PyPI. Taking this out of draft.

It carries the two fixes this module needs:

  • write_dataset_mudata instead of build_mudata + mdata.write(), so a MuData missing a required quantification modality is refused rather than written. On MSV000085836 the old path shipped an h5mu with proteins and no precursors and exited 0 (fix(mudata): widen strings before combining chunks qpx#316, fixed in 1.1.4 — that dataset now yields ['precursors','proteins'], 5,520 x 633,097).
  • *.h5mu optional again, restoring qpx's contract that the parquet views are the source of truth. As a required output it turned a best-effort artifact into a run-killer: MSV000085836 lost a ~1h19 conversion three times to it.

@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Prevent partial MuData output from QPX OpenMS consensus conversion

🐞 Bug fix ⚙️ Configuration changes 🕐 10-20 Minutes

Grey Divider

AI Description

• Routes MuData generation through qpx's guarded writer to prevent incomplete modality views.
• Keeps authoritative Parquet conversion successful when optional MuData generation fails.
• Pins container and Conda environments to qpx 1.1.4.
Diagram

graph TD
  A["consensusXML"] --> B["QPX converter"] --> C["Parquet dataset"] --> D["MuData writer"] --> E{"Modalities complete?"} -->|Yes| F["MuData view"]
  E -->|No| G["Warning only"]
Loading
High-Level Assessment

Using qpx's canonical writer is the preferred approach because it centralizes required-modality validation, temporary-file handling, and stale-output cleanup. Reimplementing these checks inline would duplicate upstream policy, while keeping MuData required would contradict its best-effort view contract and discard otherwise valid Parquet conversions.

Files changed (2) +22 / -10

Bug fix (1) +21 / -9
main.nfGuard MuData publication and make the view optional +21/-9

Guard MuData publication and make the view optional

• Uses 'write_dataset_mudata' instead of directly building and writing MuData, preventing publication when required modalities are missing and gaining temporary-file and stale-output cleanup. Marks the h5mu output optional, emits a warning when no view is produced, moves successful output to the expected filename, and updates the container to qpx 1.1.4.

modules/bigbio/qpx/openmsconsensus/main.nf

Other (1) +1 / -1
environment.ymlPin the Conda environment to qpx 1.1.4 +1/-1

Pin the Conda environment to qpx 1.1.4

• Updates the pip-installed qpx dependency from 1.1.3 to 1.1.4, providing the extracted guarded writer and upstream overflow fix.

modules/bigbio/qpx/openmsconsensus/environment.yml

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (3) 📜 Skill insights (0)

Grey Divider


Action required

1. Module tests cannot pull the image 📘 Rule violation ☼ Reliability
Description
The container declaration now selects ghcr.io/bigbio/qpx:1.1.4, which the supplied PR
description identifies as unpublished. Any container-based module test or workflow profile reaches
this image before executing either the normal or stub script, so the affected automated checks
cannot currently pass.
Code

modules/bigbio/qpx/openmsconsensus/main.nf[11]

+    container "ghcr.io/bigbio/qpx:1.1.4"
Evidence
Compliance rule 4 requires affected test profiles to pass. The changed process selects the 1.1.4
container, while the supplied PR context states that this image does not exist yet; the existing
nf-test invokes the process in stub mode and therefore still requires its configured execution
environment.

AGENTS.md: Code Changes Must Include Relevant Automated Test Coverage
modules/bigbio/qpx/openmsconsensus/main.nf[11-11]
modules/bigbio/qpx/openmsconsensus/tests/main.nf.test[19-29]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The module selects a container image that is not yet available, preventing container-based tests and workflows from starting.

## Fix Focus Areas
- modules/bigbio/qpx/openmsconsensus/main.nf[11-11]
- modules/bigbio/qpx/openmsconsensus/environment.yml[10-10]

## Recommended Fix
Publish and verify the qpx 1.1.4 container before merging, retain matching container and Conda versions, and rerun the affected module and workflow tests against the released artifacts.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Broken view safeguards go undetected 📘 Rule violation ☼ Reliability
Description
The normal script introduces write_dataset_mudata and its None branch, but the sole nf-test runs
with -stub and never executes either path. The stub always creates an .h5mu file and asserts one
output, so it cannot detect regressions in partial-view rejection or the optional no-view behavior.
Code

modules/bigbio/qpx/openmsconsensus/main.nf[R55-58]

+written = write_dataset_mudata(Path("qpx_output"), "${prefix}")
+if written is None:
+    print("WARNING: no MuData view was written; see the log above. "
+          "The qpx_output parquet views are complete and authoritative.")
Evidence
Compliance rule 4 requires executable module changes and new behavior to receive relevant automated
coverage. The changed production branch handles successful and unsuccessful writes, whereas the only
test selects stub mode and merely checks the unconditional stub artifact.

AGENTS.md: Code Changes Must Include Relevant Automated Test Coverage
modules/bigbio/qpx/openmsconsensus/main.nf[55-60]
modules/bigbio/qpx/openmsconsensus/tests/main.nf.test[19-40]
modules/bigbio/qpx/openmsconsensus/main.nf[71-82]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The changed MuData writing behavior is covered only by a stub that always creates the output, leaving the new failure guard and optional-output path untested.

## Fix Focus Areas
- modules/bigbio/qpx/openmsconsensus/main.nf[55-60]
- modules/bigbio/qpx/openmsconsensus/tests/main.nf.test[19-40]

## Recommended Fix
Add non-stub automated cases for both a complete MuData build and a modality-build failure. Assert that the complete case emits one `.h5mu`, while the failure case succeeds with complete parquet outputs, emits no `.h5mu`, and records the warning.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Users expect a sometimes-absent output 📘 Rule violation ⚙ Maintainability
Description
The mudata declaration now makes the .h5mu view optional, while docs/output.md still presents
the combined MuData container as an unconditional part of the published QPX artifact. Whenever
write_dataset_mudata returns None, the documented output is absent without documentation
explaining the failure condition or that the parquet views remain authoritative.
Code

modules/bigbio/qpx/openmsconsensus/main.nf[R20-22]

+    // Optional: the parquet views are the dataset's source of truth, so a MuData
+    // view that cannot be built must not destroy an otherwise complete run.
+    path "*.h5mu"      , emit: mudata, optional: true
Evidence
Compliance rule 10 requires changed user-facing outputs to be documented. The process now explicitly
permits no .h5mu, but both QPX output descriptions continue to list the MuData container without
qualification.

AGENTS.md: New Steps, Parameters, Outputs, and Tools Must Be Documented
modules/bigbio/qpx/openmsconsensus/main.nf[20-22]
docs/output.md[162-166]
docs/output.md[242-249]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The output documentation still describes the MuData container as a guaranteed artifact even though the process now omits it when a complete view cannot be built.

## Fix Focus Areas
- docs/output.md[162-166]
- docs/output.md[242-249]
- modules/bigbio/qpx/openmsconsensus/meta.yml[44-48]

## Recommended Fix
Describe `.h5mu` as an optional best-effort view, explain that it is omitted when required modalities cannot be built, and identify the parquet dataset as the authoritative output. Align the module metadata description with the same contract.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
Review mode: ⚖️ Balanced: This changes runtime workflow behavior and output optionality around MuData validation and failure handling, with container and dependency pin updates that warrant a complete review.

Grey Divider

Tip of the day
💡 Did you know, you can group findings by type and pick your Finding display, from Minimal to Full

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

// BioContainers/Galaxy-depot lag the release, so GHCR is used for containers;
// -profile conda still resolves the bioconda package in environment.yml.
container "ghcr.io/bigbio/qpx:1.1.3"
container "ghcr.io/bigbio/qpx:1.1.4"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Module tests cannot pull the image 📘 Rule violation ☼ Reliability

The container declaration now selects ghcr.io/bigbio/qpx:1.1.4, which the supplied PR
description identifies as unpublished. Any container-based module test or workflow profile reaches
this image before executing either the normal or stub script, so the affected automated checks
cannot currently pass.
Agent Prompt
## Issue description
The module selects a container image that is not yet available, preventing container-based tests and workflows from starting.

## Fix Focus Areas
- modules/bigbio/qpx/openmsconsensus/main.nf[11-11]
- modules/bigbio/qpx/openmsconsensus/environment.yml[10-10]

## Recommended Fix
Publish and verify the qpx 1.1.4 container before merging, retain matching container and Conda versions, and rerun the affected module and workflow tests against the released artifacts.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +55 to +58
written = write_dataset_mudata(Path("qpx_output"), "${prefix}")
if written is None:
print("WARNING: no MuData view was written; see the log above. "
"The qpx_output parquet views are complete and authoritative.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

2. Broken view safeguards go undetected 📘 Rule violation ☼ Reliability

The normal script introduces write_dataset_mudata and its None branch, but the sole nf-test runs
with -stub and never executes either path. The stub always creates an .h5mu file and asserts one
output, so it cannot detect regressions in partial-view rejection or the optional no-view behavior.
Agent Prompt
## Issue description
The changed MuData writing behavior is covered only by a stub that always creates the output, leaving the new failure guard and optional-output path untested.

## Fix Focus Areas
- modules/bigbio/qpx/openmsconsensus/main.nf[55-60]
- modules/bigbio/qpx/openmsconsensus/tests/main.nf.test[19-40]

## Recommended Fix
Add non-stub automated cases for both a complete MuData build and a modality-build failure. Assert that the complete case emits one `.h5mu`, while the failure case succeeds with complete parquet outputs, emits no `.h5mu`, and records the warning.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +20 to +22
// Optional: the parquet views are the dataset's source of truth, so a MuData
// view that cannot be built must not destroy an otherwise complete run.
path "*.h5mu" , emit: mudata, optional: true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

3. Users expect a sometimes-absent output 📘 Rule violation ⚙ Maintainability

The mudata declaration now makes the .h5mu view optional, while docs/output.md still presents
the combined MuData container as an unconditional part of the published QPX artifact. Whenever
write_dataset_mudata returns None, the documented output is absent without documentation
explaining the failure condition or that the parquet views remain authoritative.
Agent Prompt
## Issue description
The output documentation still describes the MuData container as a guaranteed artifact even though the process now omits it when a complete view cannot be built.

## Fix Focus Areas
- docs/output.md[162-166]
- docs/output.md[242-249]
- modules/bigbio/qpx/openmsconsensus/meta.yml[44-48]

## Recommended Fix
Describe `.h5mu` as an optional best-effort view, explain that it is omitted when required modalities cannot be built, and identify the parquet dataset as the authoritative output. Align the module metadata description with the same contract.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@ypriverol

Copy link
Copy Markdown
Contributor Author

Correction on process: qpx/openmsconsensus is vendored from bigbio/nf-modules (modules.json pins it at 7cd54b39), so this PR hand-edits a vendored copy that nf-core modules update would overwrite, and the same bug exists in qpx/diann which quantmsdiann vendors.

The fix now lives upstream in bigbio/nf-modules#52 (both modules: write_dataset_mudata, optional *.h5mu, pins to 1.1.4). Once that merges, this PR will be redone as a plain nf-core modules update — the module file plus the modules.json sha — and quantmsdiann gets the same update for qpx/diann.

Putting this back to draft until then.

@ypriverol

Copy link
Copy Markdown
Contributor Author

Superseded by #733, which does this as a proper nf-core modules update (bigbio/nf-modules#52) instead of hand-editing the vendored module, and also passes the search database to the module's new FASTA input. quantmsdiann gets the same in bigbio/quantmsdiann#125.

@ypriverol ypriverol closed this Sep 16, 2026
ypriverol added a commit that referenced this pull request Sep 16, 2026
…abase

nf-core modules update bigbio/qpx/openmsconsensus -> bigbio/nf-modules d9e1b05,
which brings:

- write_dataset_mudata instead of build_mudata + mdata.write(), so a MuData
  missing a required quantification modality is refused rather than written.
  The old path shipped an h5mu with proteins and no precursors on
  MSV000085836 and exited 0 (bigbio/qpx#316).
- *.h5mu optional again: the parquet views are the dataset's source of
  truth, so a best-effort artifact no longer kills an otherwise complete
  run. MSV000085836 lost a ~1h19 conversion to it three times.
- container/conda pinned to qpx 1.1.4.
- an optional FASTA input.

LFQ and TMT now pass ch_database_wdecoy — the database the search actually
used — so qpx fills null pg.sequence_coverage, pg.molecular_weight and
feature.pg_positions for target rows. Decoy entries are skipped by the
reader, so the with-decoy database is safe to pass, and .first() keeps it a
value channel because the same channel already feeds ID and PROTEOMICSLFQ.

Supersedes #732, which hand-edited the vendored module.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant