Skip to content

fix(gdpval): also apt-install JRE when libreoffice is pre-baked into image - #1268

Merged
bxyu-nvidia merged 5 commits into
mainfrom
agronskiy/gdpval/jre-when-libreoffice-prebaked
May 11, 2026
Merged

bxyu-nvidia merged 5 commits into
mainfrom
agronskiy/gdpval/jre-when-libreoffice-prebaked

Conversation

@agronskiy

Copy link
Copy Markdown
Contributor

Summary

PR #1228 added default-jre-headless to the apt package list in setup_libreoffice.py because libreoffice silently exits rc=0 with Warning: failed to launch javaldx for any chart/formula/embedded-object/pivot-table doc when no JRE is on PATH, producing filename-only stubs in comparison-mode preconvert.

But ensure_libreoffice() short-circuits at shutil.which(\"libreoffice\") before running apt — so when the deployment image already bakes libreoffice in (without a JRE), the apt-install never runs and JRE is never installed. The package-list change in #1228 is unreachable on that code path.

Why this matters

Observed in two GDPVal pipeclean runs on ultra-v3 (b8d417be, 078ab5e1) — ~25–30% of office docs reach the multimodal judge as filename-only stubs with libreoffice rc=0 did not produce X.pdf: Warning: failed to launch javaldx for every chart/formula doc.

This biases comparison-mode win rates: if Kimi reference docs convert without Java but eval candidate's docs don't (or vice-versa), the judge votes against the side delivering only a filename.

Fix

  • Gate the early-exit on both libreoffice AND java being on PATH.
  • When libreoffice is present but java is missing, still run apt-get install — idempotent on libreoffice (apt skips already-installed), and gives us the missing JRE.
  • Add a post-install which(\"java\") check that warns and fails if apt-install reports success but java still isn't on PATH.

Test plan

  • pytest resources_servers/gdpval/tests/test_setup_libreoffice.py — 11/11 pass (existing tests refactored to use a dict-based which mock; 2 new tests cover the libreoffice-present-but-java-missing case)
  • Validate end-to-end on a GDPVal pipeclean run — fold this PR into the pr-train and re-pin EFB (next step).

🤖 Generated with Claude Code

agronskiy and others added 2 commits May 8, 2026 11:10
…image

PR #1228 added `default-jre-headless` to the apt package list because
libreoffice silently exits rc=0 with `Warning: failed to launch javaldx`
on any chart/formula/embedded-object/pivot-table doc when no JRE is on
PATH, producing filename-only stubs in comparison-mode preconvert.

But `ensure_libreoffice()` short-circuits at `shutil.which("libreoffice")`
before running apt — so when the deployment image already bakes
libreoffice in (without a JRE), the apt-install never runs and JRE is
never installed. The package-list change in #1228 is unreachable on that
code path.

Observed in two GDPVal pipeclean runs (b8d417be, 078ab5e1) on
ultra-v3 — ~25–30 % of office docs reach the multimodal judge as stubs
with `failed to launch javaldx` for every chart/formula doc.

Fix: gate the early-exit on both `libreoffice` AND `java` being on PATH.
When libreoffice is present but java is missing, still run the apt install
(idempotent on libreoffice, installs missing JRE). Add a post-install
java check to fail the function if apt-install reports success but java
still isn't on PATH.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Signed-off-by: Alex Gronskiy <[email protected]>
…n`, not `which`

Run 9e2fcc4be75fb51e (slurm 2621307) on `nemotron-ultra-v3-rl-ea1-apr13-step108`
showed the previous commit's gate was insufficient. The deployment image
has *both* `libreoffice` AND a `java` binary on PATH that satisfy
`shutil.which()`, but the `java` is non-functional (or non-discoverable
by libreoffice's `javaldx` helper). `ensure_libreoffice()` short-
circuited at the early-exit, apt-install never ran, and chart/formula
docs reproduced the same `failed to launch javaldx` errors as the
pre-1268 sibling.

Replace `shutil.which("java")` with `_java_runs()` — which executes
`java -version` and checks rc=0. A non-functional `java` on PATH now
correctly fails the early-exit and triggers apt-install. Same fix
applied to the post-install verification.

Tests: refactored test mocks to drive the `java -version` outcome
through `setup._run` (since the probe now invokes it). Added two
direct unit tests for `_java_runs()` to lock in the regression: a
broken `java` (rc!=0) returns False, a working one (rc=0) returns
True. 15/15 pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Signed-off-by: Alex Gronskiy <[email protected]>
…tirely)

v3 (gate on `java -version` rc=0) was *also* insufficient. Run
4763431a924a4982 (slurm 2621556) reproduced the regression: 10
`failed to launch javaldx` errors at 35 rollouts despite the
`_java_runs()` gate firing. The deployment image has a `java` binary
that satisfies `java -version` but isn't reachable by libreoffice's
`javaldx` helper (which loads libjvm.so via JNI). Detecting *that*
out-of-band would require running javaldx itself or doing a smoke
preconvert — neither robust enough to bet on.

Drop the early-exit. Always run `apt-get update` + `apt-get install -y
--no-install-recommends libreoffice fonts-liberation
default-jre-headless` on first boot. Apt is idempotent on already-
installed packages — the install verb takes ~5 s when everything is
already present. Stale apt index doesn't fail the install, since
cached packages can still satisfy.

History (v1..v4) lives in the docstring so we don't loop on this again.

Tests: 14/14 pass. Removed the "early-exit fires when both binaries
present" test; added explicit
`test_always_runs_apt_install_even_when_libreoffice_and_java_already_on_path`
to lock in v4's contract.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Signed-off-by: Alex Gronskiy <[email protected]>
The actual root cause of the GDPVal Office→PDF failures across runs
b8d417be (16 misses), 078ab5e1 (148 misses), 9e2fcc4b/4763431a/f14a4eb7
(deprecated): the deployment image had libreoffice + libreoffice-core +
default-jre-headless + openjdk-21-jre-headless ALL installed, but
`/usr/lib/libreoffice/program/javaldx` was missing. javaldx is the
helper libreoffice uses to discover the JRE via JNI — without it,
libreoffice has no way to find the JRE no matter how many JRE packages
are installed. javaldx ships in `libreoffice-java-common`, which is
NOT a dependency of the Ubuntu `libreoffice` metapackage.

This explains why every prior fix iteration silently failed:
  v1 (`which("libreoffice")` early-exit): apt didn't run, but even if
      it had, the package list was missing javaldx provider.
  v2/v3 (gate on `which("java")` / `_java_runs()`): same — JRE was
      already there; we'd skip apt; but even running it would have
      produced no javaldx.
  v4 (always run apt): apt ran, JRE got verified, but javaldx still
      didn't exist because we never asked apt to install
      libreoffice-java-common.

Verified inside the running f14a4eb7 container (slurm 2621681) via
`enroot start --rw pyxis_2621681_2621681.8`: `find /usr -name javaldx`
returns nothing → `apt-get install -y libreoffice-java-common` →
`/usr/lib/libreoffice/program/javaldx` exists, runs cleanly (rc=0,
prints JVM lib paths).

Tests: 14/14 pass; install_command test now also asserts
libreoffice-java-common is in the apt args.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Signed-off-by: Alex Gronskiy <[email protected]>
Resolves the failing Lint check on this PR — only whitespace/wrapping
changes from `ruff format`, no logic changes.

Signed-off-by: Alex Gronskiy <[email protected]>
@bxyu-nvidia
bxyu-nvidia merged commit bf0a179 into main May 11, 2026
6 checks passed
@bxyu-nvidia
bxyu-nvidia deleted the agronskiy/gdpval/jre-when-libreoffice-prebaked branch May 11, 2026 15:47
bxyu-nvidia pushed a commit that referenced this pull request May 15, 2026
…est (#1333)

## Summary

Two related GDPVal bugs that bias comparison-mode scoring.

### 1. LibreOffice preconvert silently drops files with whitespace in
the filename

`convert_to_pdf` in `resources_servers/gdpval/preconvert.py` (and the
sibling `_convert_office_to_pdf` in
`responses_api_agents/stirrup_agent/file_reader.py`) passes
`str(input_path)` straight to `libreoffice --convert-to pdf`. The GDPVal
HF corpus includes filenames like `Population v2.xlsx`; libreoffice's
batch-convert URI handling drops these on the floor (`source file could
not be loaded`, rc=0), so every Office doc with a space in its name
silently reaches the multimodal judge as a filename-only stub — same
failure mode as the missing-JRE case fixed in #1268, but driven by the
path instead of the runtime.

**Fix:** generalize the existing ns0-staging path to also stage when the
name contains whitespace. Copy to a tempdir with a sanitized basename,
run libreoffice there, move the resulting PDF back to the caller's
expected location.

### 2. Persisted reference files are double-nested as
`reference_files/reference_files/`

`_download_reference_files` materializes each row's reference files at
`input_files_dir/<file_path>`, and every GDPVal row has `file_path`
prefixed with `reference_files/` (matching the HF dataset's directory
layout). The persistence step in `app.py` then did
`shutil.copytree(input_files_dir, task_dir / "reference_files")`, so
artifacts ended up at
`task_dir/reference_files/reference_files/<hash>/<file>` — double
nested.

This is **not just cosmetic**: `comparison.py`'s `build_file_section`
lists `<ref_dir>/reference_files/` with `os.listdir` (no recursion), so
it saw only the inner `reference_files/` subdir and **zero actual
reference files**, biasing every pairwise judgment against whichever
side actually had references.

Evidence:
`/lustre/.../ultra-v3/moonshotai/Kimi-K2.6/20260509_231553-df9e2fbb2daff866/nemo_gym.0`
— every task directory has `reference_files/reference_files/...`.

**Fix:** when `input_files_dir` already carries a top-level
`reference_files/` subdir (the HF GDPVal layout), merge contents
straight into `task_dir` so the persisted layout is the expected
single-level `task_dir/reference_files/<hash>/<file>`. Fall back to the
previous wrapping behavior when the prefix isn't present (non-GDPVal
datasets).

## Test plan
- [x] `pytest resources_servers/gdpval/tests/
responses_api_agents/stirrup_agent/tests/` → 127/127 pass
- [x] New `test_stages_when_path_has_whitespace` uses a `Population
v2.xlsx` fixture, asserts the staged input has no whitespace, and
verifies the PDF ends up at the original path
- [x] Existing ns0-normalization test updated for the unified stage→move
flow
- [x] `ruff check` + `ruff format --check` clean
- [ ] Validate end-to-end on a GDPVal pipeclean run via the pr-train

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Alex Gronskiy <[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