Repository navigation
fix(tier3): read evaluation datasets as UTF-8 - #355
Conversation
Signed-off-by: YMuskrat <[email protected]>
rng1995
left a comment
There was a problem hiding this comment.
Reviewed head 4df9e7ee against main 55d8b8d4. I found no issues.
- The three
path.open()calls indataset_utils.pywere the only Tier 3 dataset reads without an explicit encoding. The Harbor adapter, plugin-prepare and report readers already decode UTF-8, and the generator writes UTF-8. - The new subprocess test fails on main for all four suffixes (
'ascii' codec can't decode byte 0xc3) and passes on this head. I ran it on macOS and in Linuxpython:3.12-slimand3.13-slimcontainers. The locale assertion holds on both (US-ASCIIandANSI_X3.4-1968), and the subprocess takes about 0.2 s, so the 20 s timeout has plenty of room under coverage and xdist. - Invalid UTF-8 still raises
UnicodeDecodeErrorfor every suffix under any locale. BOM handling is unchanged from main and matches the sibling readers. - The new file and the related dataset suites pass with
-n 4(336 tests) and under--cov, andruff check/ruff format --checkare clean. The CHANGELOG entry is under Unreleased > Fixed.
rng1995
left a comment
There was a problem hiding this comment.
Approving at 4df9e7ee. See my earlier review for what I checked.
chrisknvidia
left a comment
There was a problem hiding this comment.
Reviewed. The fix is correct: _load_jsonl, _load_yaml and _load_json were the only dataset readers that relied on the locale encoding, and the subprocess test with LC_ALL=C, PYTHONUTF8=0 and PYTHONCOERCECLOCALE=0 really exercises the ASCII-locale path rather than inheriting UTF-8 mode from the test runner. Rejecting invalid UTF-8 instead of using errors="replace" is the right call for authored eval text.
Nothing blocking from me. CI has not run on this fork PR yet, so it still needs a maintainer to approve the workflow run before merge.
|
@YMuskrat thanks for this fix. I left a review above, and nothing in the diff needed an inline comment: the reader change and the subprocess locale test look correct. The only step left is a maintainer approving the CI workflow run on this fork PR. |
Signed-off-by: Narendran Raghavan <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
Summary
UTF-8 evaluation datasets containing non-ASCII prompts or expected answers fail to load when Python uses an ASCII locale. The dataset generator writes UTF-8, but the shared JSON, JSONL and YAML readers use the host's default encoding.
Read all four supported formats explicitly as UTF-8. Preserve the exact authored text and continue rejecting invalid UTF-8. The regression tests run real child Python processes with
LC_ALL=C, UTF-8 mode disabled and locale coercion disabled; all four Unicode cases raisedUnicodeDecodeErrorbefore the fix.Verification
make lintpassed.make buildproduced the wheel and source distribution.make testwith two workers and a first-failure limit: 824 passed, 2 skipped, 2 failed before stopping. Both failures also occur on unchanged upstream55d8b8d: the GitLab template test cannot create its hard-coded/tmpdirectory in this sandbox, and the standalone provenance test returns norun_dir(cause not diagnosed). Full-suite success is not claimed.The change and tests use Python 3.12 with the repository's locked all/dev dependencies. No live model requests were made.
Release Impact
CHANGELOG.md.