Fix merge_index dropping nested directories from shard paths#983
Open
discobot wants to merge 1 commit into
Open
Fix merge_index dropping nested directories from shard paths#983discobot wants to merge 1 commit into
discobot wants to merge 1 commit into
Conversation
merge_index prefixed each shard basename with only the immediate parent directory of its partition index, so partitions nested more than one level under the merge root ended up with shard paths that do not exist, breaking downstream streaming with 404s (issue mosaicml#959). Resolve each partition's directory relative to the merge root instead, falling back to the previous single-level behavior when a partition does not reside under the root. Add a spark-free nested-layout regression test and unit tests for the new path resolution helper.
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.
Description of changes:
merge_indexdrops intermediate directories from shard paths in the mergedindex.jsonwhenpartitions are nested more than one level under the root. Root cause:
_merge_index_from_list(
streaming/base/util.py) rebuilds each merged basename asos.path.join(os.path.basename(p.parent), basename)— exactly one directory level of thepartition index's path — so anything between the merge root and the partition is silently
dropped.
This PR resolves each partition's directory relative to the merge root instead, via a new
_get_partition_dirnamehelper that compares the partition index url againstout(local partagainst local root, remote against remote, same bucket only) and takes
os.path.relpathon theurl paths. Partitions that don't reside under
out(arbitraryindex_file_urls) fall back tothe previous single-level behavior, so existing one-level layouts are unaffected.
Testing:
test_merge_index_from_root_local_nestedwrites 4 MDS partitions atout/group{1,2}/subdir{1,2}, merges, and asserts the merged basenames keep the full relativepaths and that a
StreamingDataseton the merged root iterates all samples. It fails on main("expected 4 shard files but got 2") and passes with this change.
test_get_partition_dirnamecovers local, remote, tuple, root-level, cross-bucket, andoutside-root fallback cases.
tests/test_util.pytests (incl. the spark-basedtest_merge_index_from_list_local/test_merge_index_from_root_localmatrices) andtests/base/converters/test_dataframe_to_mds.pypass locally.Issue #, if available:
Merge Checklist:
Put an
xwithout space in the boxes that apply. If you are unsure about any checklist, please don't hesitate to ask. We are here to help! This is simply a reminder of what we are going to look for before merging your pull request.General
Tests
pre-commiton my change. (check out thepre-commitsection of prerequisites)