Fix DatasetDict.push_to_hub leaving removed splits in the dataset card - #8367
Merged
lhoestq merged 1 commit intoJul 28, 2026
Merged
Conversation
…lit set
DatasetDict.push_to_hub deletes the shards of splits that are no longer in
the dict, but _get_updated_dataset_card only applied remove_other_splits to
the dataset_info block. The configs.data_files patterns were still seeded
from the existing card and splits were only ever added, so a removed split
kept its pattern with no files behind it, making the dataset unloadable:
ValueError: Couldn't infer the same data file format for all splits.
Got {'train': ('parquet', {}), 'test': (None, {})}
Skip the seeding when remove_other_splits is set so the patterns describe
only the splits this push wrote. Dataset.push_to_hub passes
remove_other_splits=False and keeps its additive behaviour.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
pjh4993
marked this pull request as draft
July 26, 2026 12:08
pjh4993
marked this pull request as ready for review
July 26, 2026 13:42
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Elsword016
pushed a commit
to Elsword016/datasets
that referenced
this pull request
Aug 6, 2026
huggingface#8367) Drop removed splits from the dataset card when a push replaces the split set DatasetDict.push_to_hub deletes the shards of splits that are no longer in the dict, but _get_updated_dataset_card only applied remove_other_splits to the dataset_info block. The configs.data_files patterns were still seeded from the existing card and splits were only ever added, so a removed split kept its pattern with no files behind it, making the dataset unloadable: ValueError: Couldn't infer the same data file format for all splits. Got {'train': ('parquet', {}), 'test': (None, {})} Skip the seeding when remove_other_splits is set so the patterns describe only the splits this push wrote. Dataset.push_to_hub passes remove_other_splits=False and keeps its additive behaviour. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Pushing a
DatasetDictthat drops a split leaves the repo unloadable:Context
Two things matter here:
configs.data_filespaths are globs, and every split listed there must expand to real files at load time.DatasetDict.push_to_hubreplaces the split set: any split not in the dict has its parquet files deleted from the repo, and the card is rewritten withremove_other_splits=True. (Dataset.push_to_hubonly appends, and passesremove_other_splits=False.)After the second push above, the card's YAML header looks like this:
data/test-*now matches no files, soload_datasetcan't infer a format fortestand fails.Root cause
remove_other_splits=Truewas only honored for thedataset_infoblock. Theconfigs.data_filesblock was rebuilt like this:Splits are only ever added to that dict — nothing removes one, so
testsurvives from the old card even though this push deleted its files.Fix
When
remove_other_splits=True, don't seed from the old card — start empty so the patterns describe exactly the splits this push wrote.Dataset.push_to_hubis unaffected — it stays on the additive path and keeps whatever the card already lists.Tests
Two hermetic tests in
tests/test_buckets.py(in-memory filesystems, no Hub), alongside the existing_get_updated_dataset_cardtest:test_get_updated_dataset_card_drops_removed_splits_when_replacing_split_set— verified to fail before the fix. Asserts both blocks agree, since it's the disagreement that breaks loading.test_get_updated_dataset_card_keeps_existing_splits_when_appending— pins the additiveremove_other_splits=Falsepath soDataset.push_to_hubdoesn't regress.