Skip to content

fix(protein-properties): rewrite views in decoded-size-bounded batches - #338

Merged
ypriverol merged 2 commits into
devfrom
fix/protein-properties-batched-rewrite
Oct 6, 2026
Merged

ypriverol merged 2 commits into
devfrom
fix/protein-properties-batched-rewrite

Conversation

@ypriverol

Copy link
Copy Markdown
Contributor

Problem

convert openms-consensus --fasta (and transform protein-properties) failed on a large TMT dataset, PXD023662 with 1,113 raw files:

protein_properties.py _rewrite_view -> parquet.read_row_group(group)
pyarrow.lib.ArrowNotImplementedError: Nested data conversions not implemented for chunked array outputs

The cause is the pg view's grouped_runs (list<string>). It is dictionary-encoded and repeats about 1,113 run names on every row. Row group 0 decodes to 7.8 GB, while the footer reports only 173 MB. Reading a whole row group at once overflows pyarrow's single-array limit.

Fix

_rewrite_view now streams each row group with iter_batches. It sizes each batch by decoding a 64-row probe and measuring its in-memory bytes per row, then caps batches at 256 MB decoded. Sizing from the footer's encoded total_byte_size is not enough: it understates nested dictionary columns by about 50×, and an earlier version of this fix that used it still failed on the real data. The output is unchanged.

Validation

  • Unit tests. Two new regression tests:

    • A rewrite with read_row_group raising this error and tiny batches gives the same result as a normal run.
    • A dictionary-encoded nested column with a small footer size and a large decoded size gets bounded batches.

    The full suite passes: 1,609 tests.

  • Real data (PXD023662 pg view, qpx 1.1.4 container, patched module bind-mounted):

    Code Result Peak RSS
    Unpatched Fails with the error above 10.9 GB
    Footer-sized batches (first version of this fix) Fails the same way 10.9 GB
    This PR Completes in 49 s 1.9 GB

    The full convert openms-consensus plus the MuData step also completes, at about 62 GB peak. Row counts are unchanged: pg 1,221,160 and feature 7,326,284. Of the target groups, 100% get sequence_coverage and molecular_weight.

Not in this PR

qpxc validate on the same pg view fails separately, with DuckDB's "Arrow Appender: maximum total string size 2147483647". That happens on the unpatched output too. It will be filed as its own issue.

The --fasta protein-properties rewrite read each pg/feature row group in one
call. On a 1,113-file TMT dataset (PXD023662) the pg view's dictionary-encoded
grouped_runs column (~1,113 run names per row) decodes to 7.8 GB in a single
row group whose footer reports 173 MB, so pyarrow raised "Nested data
conversions not implemented for chunked array outputs" and the conversion
failed.

Stream each row group with iter_batches, sizing batches from the decoded bytes
of a small probe batch (the footer's encoded size understates nested
dictionary columns ~50x), capped at 256 MB per batch. Output is unchanged.

Validated on the real PXD023662 pg view in the qpx 1.1.4 container: unpatched
fails (10.9 GB RSS); patched completes in 49 s at 1.9 GB, and the full
openms-consensus convert + MuData step completes (peak ~62 GB) with 100% of
target groups annotated.
@coderabbitai

coderabbitai Bot commented Oct 6, 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: 0c83a68e-41b3-48e1-9ea6-5d157216db92

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
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@ypriverol
ypriverol merged commit e954073 into dev Oct 6, 2026
16 checks passed
Shen-YuFei pushed a commit to Shen-YuFei/nf-modules that referenced this pull request Oct 8, 2026
qpx 1.1.5 carries the protein-properties batched rewrite (bigbio/qpx#338,
pyarrow 2 GB crash on large TMT) and the 1.1.4..1.1.5 converter fixes.

qpx 1.1.5 `convert diann` / `convert openms-consensus` now write the
MuData view themselves (--mudata, default on) through the same
write_dataset_mudata guard the modules called. Drop the modules' own
python build, which would rebuild the h5mu a second time, and just move
the CLI-written view out of qpx_output.
@ypriverol
ypriverol deleted the fix/protein-properties-batched-rewrite branch October 19, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant