Skip to content

fix(cudf.pandas): fix Excel/openpyxl test failures and add xlsxwriter dependency - #22722

Merged
rapids-bot[bot] merged 8 commits into
NVIDIA:mainfrom
vyasr:fix/pandas-excel-openpyxl
Jun 1, 2026
Merged

fix(cudf.pandas): fix Excel/openpyxl test failures and add xlsxwriter dependency#22722
rapids-bot[bot] merged 8 commits into
NVIDIA:mainfrom
vyasr:fix/pandas-excel-openpyxl

Conversation

@vyasr

@vyasr vyasr commented May 29, 2026

Copy link
Copy Markdown
Contributor

Description

Fix cudf.pandas Excel/openpyxl integration test failures by correcting engine dispatch, removing an over-engineered __exit__ override that diverged from vanilla pandas behavior, and adding xlsxwriter as a test dependency (matching pandas CI).

Changes:

  • Fix ExcelWriter engine dispatch so openpyxl is correctly selected for .xlsx files
  • Fix engine_kwargs passthrough for openpyxl data_only option
  • Remove custom __exit__ override and related gc/zipfile workarounds that masked real issues
  • Add xlsxwriter to cudf.pandas test dependencies (via dependencies.yaml)
  • xfail test_engine_kwargs_append_data_only — an inherent openpyxl limitation (freshly-written files have no formula cache)

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@vyasr
vyasr requested review from a team as code owners May 29, 2026 22:50
@vyasr vyasr added bug Something isn't working Python Affects Python cuDF API. non-breaking Non-breaking change cudf.pandas Issues specific to cudf.pandas labels May 29, 2026
@GPUtester GPUtester moved this to In Progress in cuDF Python May 29, 2026
@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Documentation

    • Expanded debugging guidance for cudf.pandas test failures, including new failure categories and improved diagnostic procedures.
  • Dependencies

    • Added xlsxwriter package support across environments.
  • Bug Fixes

    • Enhanced Excel-related proxy handling for improved compatibility with pandas Excel operations and updated test failure mappings.

Walkthrough

This PR adds xlsxwriter to test dependency bundles and generated conda envs, implements ExcelWriter proxy construction and engine-specific proxy subclasses (OpenpyxlWriter, XlsxWriter), updates pandas-testing expected-failure reasons for openpyxl cases, and extends SKILL.md with dependency/environment-gap diagnosis and proxy-fix constraints.

Changes

ExcelWriter proxy support with xlsxwriter dependency

Layer / File(s) Summary
xlsxwriter dependency setup
dependencies.yaml, conda/environments/all_cuda-129_arch-*.yaml, conda/environments/all_cuda-132_arch-*.yaml
Adds xlsxwriter to the test_cudf_pandas_pandas_tests conda dependency group and propagates it into generated conda environment YAMLs.
ExcelWriter proxy implementation with engine-specific writers
python/cudf/cudf/pandas/_wrappers/pandas.py
Imports pandas OpenpyxlWriter and XlsxWriter, implements _ExcelWriter__new__ to construct pd.ExcelWriter with module acceleration disabled and wrap it in the proxy, makes _ExcelWriter__init__ a no-op, and defines proxy subclasses OpenpyxlWriter and XlsxWriter exposing __fspath__.
pandas-testing expected-failure reasons update
python/cudf/cudf/pandas/scripts/pandas-testing-plugin.py
Adds openpyxl-specific expected-failure reason entries for test_engine_kwargs_append_data_only and test_styler_custom_converter, and reintroduces existing failure reason entries for hierarchical rows/periodindex cases.
Debugging guidance for dependency/environment gaps and proxy fixes
.agents/skills/debug-cudf-pandas/SKILL.md
Adds "dependency/environment gap" to failure categories, strengthens rule forbidding proxy fixes that diverge from vanilla pandas, adds Step 3d to require verifying vanilla pandas and enumerates common non-cudf causes, and introduces Step 4c detailing how to add missing test packages to dependencies.yaml under test_cudf_pandas_pandas_tests, regenerate dependency files, and xfail only with root-cause explanation strings.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • rapidsai/cudf#22625: Expands the debug-cudf-pandas workflow in SKILL.md with failure categories, diagnosis steps, and xfail procedures aligned to pandas-vs-proxy troubleshooting.

Suggested reviewers

  • mroeschke
  • TomAugspurger
  • galipremsagar
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(cudf.pandas): fix Excel/openpyxl test failures and add xlsxwriter dependency' directly and clearly summarizes the main changes: fixing Excel/openpyxl test failures and adding the xlsxwriter dependency.
Description check ✅ Passed The description is directly related to the changeset, detailing the specific fixes (engine dispatch, engine_kwargs passthrough, removal of exit override) and dependency additions that match the file changes across the codebase.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.agents/skills/debug-cudf-pandas/SKILL.md:
- Around line 295-296: Update the xfail dict entry so its explanation string
states the root cause (e.g., "openpyxl limitation" or "pandas test bug: assumes
xlsxwriter present") instead of the raw error message, and fix the accidental
setext heading parsing by inserting a blank line (or rewording/escaping)
immediately before the `---` horizontal rule so the `---` is treated as a rule
rather than a setext underline; locate the xfail dict and the `---` separator in
SKILL.md to apply these changes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 020e9111-9a17-4540-84fc-145d38441cdf

📥 Commits

Reviewing files that changed from the base of the PR and between b99f73f and a409437.

📒 Files selected for processing (9)
  • .agents/skills/debug-cudf-pandas/SKILL.md
  • conda/environments/all_cuda-129_arch-aarch64.yaml
  • conda/environments/all_cuda-129_arch-x86_64.yaml
  • conda/environments/all_cuda-132_arch-aarch64.yaml
  • conda/environments/all_cuda-132_arch-x86_64.yaml
  • dependencies.yaml
  • python/cudf/cudf/pandas/_wrappers/pandas.py
  • python/cudf/cudf/pandas/scripts/pandas-testing-plugin.py
  • python/cudf/pyproject.toml

Comment on lines +295 to 296
The explanation string in the xfail dict should describe the *root cause* (e.g. "openpyxl limitation", "pandas test bug: assumes xlsxwriter present"), not just the error message.
---

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix accidental setext heading parsing before horizontal rule.

Line 296 is being interpreted as a setext underline for Line 295, which triggers markdownlint MD003. Add a blank line before --- (or escape/reword) so it’s treated as a horizontal rule.

Suggested fix
 The explanation string in the xfail dict should describe the *root cause* (e.g. "openpyxl limitation", "pandas test bug: assumes xlsxwriter present"), not just the error message.
+
 ---
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 295-295: Heading style
Expected: atx; Actual: setext

(MD003, heading-style)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.agents/skills/debug-cudf-pandas/SKILL.md around lines 295 - 296, Update the
xfail dict entry so its explanation string states the root cause (e.g.,
"openpyxl limitation" or "pandas test bug: assumes xlsxwriter present") instead
of the raw error message, and fix the accidental setext heading parsing by
inserting a blank line (or rewording/escaping) immediately before the `---`
horizontal rule so the `---` is treated as a rule rather than a setext
underline; locate the xfail dict and the `---` separator in SKILL.md to apply
these changes.

@vyasr vyasr changed the title fix(cudf.pandas): fix Excel/openpyxl test failures and add xlsxwriter dependency fix(cudf.pandas): fix Excel/openpyxl test failures and add xlsxwriter dependency May 30, 2026
@vyasr vyasr changed the title fix(cudf.pandas): fix Excel/openpyxl test failures and add xlsxwriter dependency fix(cudf.pandas): fix Excel/openpyxl test failures and add xlsxwriter dependency May 30, 2026
@vyasr vyasr changed the title fix(cudf.pandas): fix Excel/openpyxl test failures and add xlsxwriter dependency fix(cudf.pandas): fix Excel/openpyxl test failures and add xlsxwriter dependency May 30, 2026
@vyasr vyasr changed the title fix(cudf.pandas): fix Excel/openpyxl test failures and add xlsxwriter dependency fix(cudf.pandas): fix Excel/openpyxl test failures and add xlsxwriter dependency May 30, 2026
@jameslamb
jameslamb removed the request for review from msarahan June 1, 2026 15:42
vyasr and others added 8 commits June 1, 2026 16:13
…r dep

The _ExcelWriter__exit__ override was suppressing an IndexError that
vanilla pandas also raises on empty workbooks. This made cudf.pandas
diverge from pandas behavior. The root cause was a missing xlsxwriter
dependency — pandas CI has it installed, causing ExcelWriter to dispatch
to xlsxwriter (which handles empty workbooks) rather than openpyxl.

Add xlsxwriter to test_python_cudf_pandas dependencies to match pandas
CI, and remove the unnecessary proxy override, gc, and zipfile imports.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Add lessons learned from debugging openpyxl test failures:
- New failure category: dependency/environment gaps
- New diagnostic step: verify vanilla pandas behavior (Step 3d)
- New resolution path: fix dependency gaps (Step 4c)
- New unacceptable fix: diverging from pandas to pass a test
- Guidance on rapids-dependency-file-generator workflow
- xfail strings should describe root cause, not error type

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
xlsxwriter was incorrectly placed in test_python_cudf_pandas, which is
for cudf.pandas's own unit tests (run_tests.sh). The pandas test suite
under cudf.pandas gets xlsxwriter via pip's pandas[excel] extra, but
conda environments need it listed explicitly.

Create a new test_cudf_pandas_pandas_tests group with output_types:
[conda] for dependencies that pandas CI has installed (via pip extras)
but conda environments require explicitly. Add it to the 'all' includes.

Update SKILL.md to reference the correct dependency group.
Same root cause as test_engine_kwargs_append_data_only: cudf.pandas
fast path raises NotImplementedError, falls back to openpyxl which
raises IndexError on workbook with no visible sheets.
@vyasr
vyasr force-pushed the fix/pandas-excel-openpyxl branch from edd9f17 to ae4b616 Compare June 1, 2026 16:16

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
.agents/skills/debug-cudf-pandas/SKILL.md (1)

297-298: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix markdown linting issue: add blank line before horizontal rule.

Line 297 is being interpreted as a setext heading because of the --- on line 298. Add a blank line before the --- so it's properly treated as a horizontal rule, not a setext underline.

📝 Suggested fix
 The explanation string in the xfail dict should describe the *root cause* (e.g. "openpyxl limitation", "pandas test bug: assumes xlsxwriter present"), not just the error message.
+
 ---
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.agents/skills/debug-cudf-pandas/SKILL.md around lines 297 - 298, Add a
blank line before the horizontal rule `---` in SKILL.md around the xfail dict
section so the `---` is treated as a horizontal rule (not a setext underline);
while there, update the xfail dict's `explanation` string to describe the root
cause (e.g., "openpyxl limitation" or "pandas test bug: assumes xlsxwriter
present") rather than just the raw error message to make the intent clear.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In @.agents/skills/debug-cudf-pandas/SKILL.md:
- Around line 297-298: Add a blank line before the horizontal rule `---` in
SKILL.md around the xfail dict section so the `---` is treated as a horizontal
rule (not a setext underline); while there, update the xfail dict's
`explanation` string to describe the root cause (e.g., "openpyxl limitation" or
"pandas test bug: assumes xlsxwriter present") rather than just the raw error
message to make the intent clear.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 47b7e4ee-a769-4465-b19a-2e8a4c8c67d9

📥 Commits

Reviewing files that changed from the base of the PR and between 0885958 and ae4b616.

📒 Files selected for processing (8)
  • .agents/skills/debug-cudf-pandas/SKILL.md
  • conda/environments/all_cuda-129_arch-aarch64.yaml
  • conda/environments/all_cuda-129_arch-x86_64.yaml
  • conda/environments/all_cuda-132_arch-aarch64.yaml
  • conda/environments/all_cuda-132_arch-x86_64.yaml
  • dependencies.yaml
  • python/cudf/cudf/pandas/_wrappers/pandas.py
  • python/cudf/cudf/pandas/scripts/pandas-testing-plugin.py
✅ Files skipped from review due to trivial changes (1)
  • conda/environments/all_cuda-129_arch-aarch64.yaml
🚧 Files skipped from review as they are similar to previous changes (5)
  • conda/environments/all_cuda-132_arch-aarch64.yaml
  • conda/environments/all_cuda-129_arch-x86_64.yaml
  • conda/environments/all_cuda-132_arch-x86_64.yaml
  • python/cudf/cudf/pandas/scripts/pandas-testing-plugin.py
  • python/cudf/cudf/pandas/_wrappers/pandas.py

Comment thread dependencies.yaml
- output_types: [conda]
packages:
- numexpr
- xlsxwriter

@mroeschke mroeschke Jun 1, 2026

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.

Just FYI, the pandas unit test job installs these pandas options dependencies specified the test_python_pandas_cudf section, so at some point it would be nice to consolidate test_python_pandas_cudf with test_cudf_pandas_pandas_tests 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I specifically created a new list here because I didn't want to force that job to install extra dependencies that are only needed for the pandas test suite. What I'd really love is if we can pull this information out of the pandas's pyproject.toml or something, but that feels like overkill to engineer 😅

@mroeschke

Copy link
Copy Markdown
Contributor

/merge

@rapids-bot
rapids-bot Bot merged commit 63bfe29 into NVIDIA:main Jun 1, 2026
318 of 325 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in cuDF Python Jun 1, 2026
@vyasr
vyasr deleted the fix/pandas-excel-openpyxl branch June 1, 2026 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cudf.pandas Issues specific to cudf.pandas non-breaking Non-breaking change Python Affects Python cuDF API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants