Skip to content

Fix shard file pattern to match generated shard filenames - #9224

Open
Sakibpedia wants to merge 1 commit into
huggingface:mainfrom
Sakibpedia:fix/shard-file-pattern
Open

Sakibpedia wants to merge 1 commit into
huggingface:mainfrom
Sakibpedia:fix/shard-file-pattern

Conversation

@Sakibpedia

Copy link
Copy Markdown

What

Fixes filepattern_for_dataset_split so a filetype_suffix produces a glob that matches both the single-file and the sharded filenames generated by filenames_for_dataset_split.

Why

Fixes #9222. The old pattern was {prefix}.{suffix}*, e.g. toy_dataset-train.arrow*, while generated shards are named toy_dataset-train-00000-of-00002.arrow. Callers using the pattern to collect a split found none of its shards.

How

  • Put a [.-] separator character class between the split prefix and the suffix, so both .{suffix} and -00000-of-00002.{suffix} match.
  • Keep the trailing * so multi-part extensions such as json.gz keep working.
  • The separator class also prevents a neighbouring split such as training from being matched by a train pattern.
  • Behaviour when filetype_suffix is not supplied is unchanged.

Tests

  • Added tests/test_naming.py with 5 regression tests: generated shards, single file, neighbouring split, no suffix, and multi-part extension.
  • python -m pytest tests/test_naming.py tests/test_data_files.py -q — 228 passed, 1 skipped.

Checklist

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.

filepattern_for_dataset_split misses sharded filenames when filetype_suffix is given

1 participant