Skip to content

Address PR review comments: optimize ion mobility access, enhance docs, improve test files - #8658

Merged
timosachsenberg merged 2 commits into
feature/cpp-arrow-ms-experimentfrom
copilot/sub-pr-8655
Jan 14, 2026
Merged

timosachsenberg merged 2 commits into
feature/cpp-arrow-ms-experimentfrom
copilot/sub-pr-8655

Conversation

Copilot AI commented Jan 14, 2026 •

Copy link
Copy Markdown
Contributor

Addresses three optimization and quality improvements from PR review feedback.

Changes

  • Ion mobility array access optimization (MSExperiment.pyx): Replace element-by-element list comprehension with FloatDataArray.get_data() for ~50x performance improvement on large datasets

  • Parquet test file naming (ArrowExport_test.cpp): Add .parquet suffix to temporary test files for better file association and debugging experience

  • Documentation consistency (ArrowExport.h): Add @note sections to ArrowChromatogramExportConfig matching ArrowSpectraExportConfig style, clarifying empty columns and RT filter behavior

# Before: O(n) Python loop
im_data = np.array([im_arr[i] for i in range(len(im_arr))])

# After: Optimized C-level copy
im_data = np.asarray(im_arr.get_data())

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@coderabbitai

coderabbitai Bot commented Jan 14, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

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


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

Copilot AI changed the title [WIP] Add export functionality for MSExperiment to Arrow/Parquet Address PR review comments: optimize ion mobility access, enhance docs, improve test files Jan 14, 2026
Copilot AI requested a review from timosachsenberg January 14, 2026 19:53
@timosachsenberg
timosachsenberg marked this pull request as ready for review January 14, 2026 19:55
@timosachsenberg
timosachsenberg merged commit 703df03 into feature/cpp-arrow-ms-experiment Jan 14, 2026
@timosachsenberg
timosachsenberg deleted the copilot/sub-pr-8655 branch January 14, 2026 19:55
timosachsenberg added a commit that referenced this pull request Jan 15, 2026
* [FEATURE] Add Arrow/Parquet export for MSExperiment

Add opt-in C++ helper for exporting MSExperiment to Apache Arrow tables
when OpenMS is built with Parquet/Arrow support.

Features:
- Export spectra & chromatograms to Arrow/Parquet formats
- Long or semi-wide layout options
- Configurable columns, RT/m/z/MS-level filters
- Optional precursor and ion-mobility fields
- Parquet compression tuning
- Zero-copy Python interop via pyarrow

The code is guarded by WITH_PARQUET and does not change existing behavior.

Co-Authored-By: Claude Opus 4.5 <[email protected]>

* Update src/pyOpenMS/tests/unittests/test_dataframe_columns.py

Co-authored-by: Copilot <[email protected]>

* Address PR review comments: optimize ion mobility access, enhance docs, improve test files (#8658)

* Initial plan

* Address PR review comments: optimize ion mobility access, add parquet suffix, enhance docs

Co-authored-by: timosachsenberg <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: timosachsenberg <[email protected]>

* Update wrapping docs: libcpp_utf8_output_string works in containers

Document that libcpp_utf8_output_string can be used in container return
types (e.g., libcpp_vector) for automatic conversion to Python strings.

Co-Authored-By: Claude Opus 4.5 <[email protected]>

* Use libcpp_utf8_output_string for ArrowExport column name returns

Use automatic string conversion for getSpectraArrowColumns and
getChromatogramArrowColumns return types, removing need for manual
.decode('utf-8') calls in Python code.

Co-Authored-By: Claude Opus 4.5 <[email protected]>

* Simplify ArrowExport and rename column discovery methods

- Remove redundant empty chromatogram handling (81 lines) - the normal
  code path handles empty data correctly and respects column filtering
- Rename C++ methods: getSpectraArrowColumns -> getSpectraArrowColumnNames,
  getChromatogramArrowColumns -> getChromatogramArrowColumnNames
- Rename Python methods: get_df_columns -> get_df_column_names,
  get_arrow_columns -> get_arrow_column_names across all addon files
- Update tests and documentation to use new names

The "Names" suffix clarifies these methods return column name strings,
consistent with Arrow's column_names() convention.

Co-Authored-By: Claude Opus 4.5 <[email protected]>

* Add tests for missing get_df_column_names() methods

Add test coverage for column name discovery methods that were renamed
but not tested:
- FeatureMap.get_df_column_names()
- ConsensusMap.get_df_column_names()
- MRMTransitionGroupCP.get_chromatogram_df_column_names()
- MRMTransitionGroupCP.get_feature_df_column_names()
- MSExperiment.get_df_column_names()

Co-Authored-By: Claude Opus 4.5 <[email protected]>

* Rename DataFrame methods to Pythonic conventions

- get_df() → to_df() (matches pandas/polars to_pandas(), to_arrow() pattern)
- get_df_column_names() → df_columns() (shorter, cleaner)
- get_arrow_column_names() → arrow_columns()
- get_chromatogram_df_column_names() → chromatogram_df_columns()
- get_feature_df_column_names() → feature_df_columns()
- get_chromatogram_df() → to_chromatogram_df()
- get_feature_df() → to_feature_df()

Updated in MSSpectrum, MSChromatogram, Mobilogram, FeatureMap,
ConsensusMap, MSExperiment, MRMTransitionGroupCP, and
PeptideIdentificationList addons. Tests and documentation updated.

Co-Authored-By: Claude Opus 4.5 <[email protected]>

* Add deprecated aliases for backward compatibility with pyopenms 3.5.0

Provides deprecated method aliases that emit DeprecationWarning:
- get_df() -> to_df()
- get_df_columns() -> df_columns()
- get_chromatogram_df() -> to_chromatogram_df()
- get_chromatogram_df_columns() -> chromatogram_df_columns()
- get_feature_df() -> to_feature_df()
- get_feature_df_columns() -> feature_df_columns()

This allows existing user code to continue working while encouraging
migration to the new Pythonic method names. Aliases will be removed
in a future major version.

Also updates _dataframes.py wrapper to call to_df() instead of get_df().

Co-Authored-By: Claude Opus 4.5 <[email protected]>

* Add deprecation warnings to standalone DataFrame functions

peptide_identifications_to_df() and update_scores_from_df() now emit
DeprecationWarning encouraging users to use the method-based API:
- peps.to_df() instead of peptide_identifications_to_df(peps)
- peps.update_scores_from_df(df, name) instead of update_scores_from_df(peps, df, name)

Co-Authored-By: Claude Opus 4.5 <[email protected]>

* Remove unused common_meta_value_types and _add_meta_values

- common_meta_value_types: Was exported but never imported; addon files
  define their own local copies
- _add_meta_values: Completely unused dead code

Also removed unused imports (numpy, DataValue).

Co-Authored-By: Claude Opus 4.5 <[email protected]>

* Add ParquetWriteConfig to ArrowExport.pxd Python bindings

Add missing ParquetWriteConfig struct declaration and update
exportSpectraToParquet/exportChromatogramsToParquet signatures
to include the parquet_config parameter matching the C++ header.

ParquetWriteConfig exposes:
- compression_level: ZSTD level (1-22, default 3)
- row_group_size: Target bytes per row group (default 128MB)
- write_statistics: Enable min/max stats for predicate pushdown
- data_page_size: Granularity within row groups (default 1MB)

Note: Compression enum class is not wrapped (autowrap limitation),
defaults to ZSTD which is optimal for MS data.

Co-Authored-By: Claude Opus 4.5 <[email protected]>

* Fix Arrow export: use sentinel values for RT/MZ filters, bulk IM accessor

- Use 0.0/inf sentinel values for None RT/MZ filters instead of calling
  getMinRT()/getMaxRT()/getMinMZ()/getMaxMZ() - consistent with C++ path
- Use bulk accessor np.asarray(im_arr.get_data()) for ion mobility in
  semi-wide format instead of element-by-element iteration
- Update test docstrings to clarify long_format is a deprecated parameter

Co-Authored-By: Claude Opus 4.5 <[email protected]>

* Add ArrowExportFormat enum binding for proper format handling

- Add ArrowExportFormat enum class to ArrowExport.pxd (Long, SemiWide)
- Add format field to ArrowSpectraExportConfig and ArrowChromatogramExportConfig
- Update MSExperiment.arrow_columns() to map Python format string to C++ enum
- C++ path now correctly returns columns for the requested format

Co-Authored-By: Claude Opus 4.5 <[email protected]>

* Fix method name in ArrowExport_test: getSpectraArrowColumns -> getSpectraArrowColumnNames

Co-Authored-By: Claude Opus 4.5 <[email protected]>

---------

Co-authored-by: timosachsenberg <[email protected]>
Co-authored-by: Claude Opus 4.5 <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: timosachsenberg <[email protected]>
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.

2 participants