Repository navigation
Conversation
Member
|
Thank you for the PR! This made the same fix as #16725, which has now been merged, so I'm closing this one as a duplicate. Your separator test cases are covered there too (all three characters, |
iam-knoit
pushed a commit
to SynhalaAI/unsloth
that referenced
this pull request
Nov 6, 2026
…unslothai#16725) Fixes unslothai#16721. S3 audio dataset preparation aborts when a JSON Lines transcript contains literal U+0085, U+2028, or U+2029. Python's `str.splitlines()` treats those characters as record boundaries even inside JSON strings. Split on LF after text-mode newline normalization. The regression test checks that both rows retain their transcripts and point to the downloaded audio for `.jsonl` and multi-record `.json` manifests with LF and CRLF. This draft overlaps unslothai#16723 and carries explicit CRLF regression coverage. ## Verification - Four regression cases failed before the fix and passed afterward. - 70 tests passed across `test_s3_audio_dataset.py` and `test_s3_dataset.py`. An additional eight local diagnostics using Hugging Face datasets 4.3.0 passed. - Repository formatter, scoped Ruff check, and `git diff --check` passed. --------- Co-authored-by: Daniel Han <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #16721.
Why
S3 audio dataset preparation reads JSON Lines manifests with
str.splitlines(). That method also breaks on U+0085, U+2028 and U+2029, which JSON allows unescaped inside strings. One transcript with such a character aborts preparation withJSONDecodeError, though the Hugging Face JSON loader reads the same file fine.What changed
_rewrite_json_manifestsplits JSON Lines records on"\n"only. Text mode already turns CRLF into LF..jsonland in JSON Lines stored as.json.Scope
This covers the JSON Lines branch of the S3 manifest rewriter. Single JSON documents and CSV manifests stay as they are.
Blast Radius
The change touches S3 manifests in JSON Lines form. A manifest without these characters splits into the same records as before.
Verification
JSONDecodeError: Unterminated string.pytest studio/backend/tests/test_s3_audio_dataset.py studio/backend/tests/test_s3_dataset.pyreported72 passed.datasets.load_dataset("json", ...)read a CRLF manifest with U+2028 as 2 rows, and the new split returned the same 2 rows.