fix: prevent incomplete Search-R1 data cache files - #623
Open
Bluu (Bluuok) wants to merge 2 commits into
Open
Bluu (Bluuok) wants to merge 2 commits into
Bluu (Bluuok) wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Index assembly can still leave a non-empty partial cache file when concatenation fails.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Improves Search-R1 cache reliability by publishing successful downloads atomically and restricting index assembly to expected shards.
Changes:
- Downloads through temporary files with failure cleanup.
- Uses only
part_aaandpart_abfor index assembly. - Adds end-to-end regression tests for curl/wget failures and stale shards.
| File | Description |
|---|---|
examples/search_r1/data_process.sh |
Adds atomic downloads and explicit shard assembly. |
tests/examples/test_search_r1_data.py |
Tests retries, cache preservation, and index contents. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| if [[ ! -s "$DATA_DIR/e5_Flat.index" ]]; then | ||
| cat "$DATA_DIR"/part_* > "$DATA_DIR/e5_Flat.index" | ||
| cat "$DATA_DIR/part_aa" "$DATA_DIR/part_ab" > "$DATA_DIR/e5_Flat.index" |
This branch has not been deployed
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.

Failed Search-R1 downloads or index assembly can leave non-empty partial cache files that subsequent runs treat as valid. Wildcard shard assembly also includes unrelated
part_*files.Write downloads and the assembled index into same-directory temporary files, clean up failures, and publish each final path only after success. Assemble the index from the two expected shards (
part_aa,part_ab). Existing non-empty cache files remain reusable.Validation in the frozen Linux CPU environment:
All 4 tests passed. The original download/stale-shard regressions failed on unchanged main. The partial-assembly regression also failed on the previous branch version (1 failed / 3 passed): it emits the first shard and then returns a read error, verifies that no final or temporary index remains, and verifies that a subsequent run recovers the complete index. Scoped Pyright and syntax checks on repository-LF content passed.
Tests execute the full Bash script with isolated Conda/downloader commands and tiny gzip fixtures. No actual dataset download, external service or GPU training was run. Fork CI awaits maintainer approval. AI assistance was used; both the final script and regression tests were reviewed.