Allow to_iterable_dataset() on a dataset with no rows - #8388
Open
LeSingh1 wants to merge 1 commit into
Open
Conversation
`Dataset.to_iterable_dataset()` defaults to `num_shards=1`, but the guard
rejected any `num_shards > len(self)`, so it always raised on an empty
dataset:
ValueError: Unable to shard a dataset of size 0 into 1 shards
(the number of shards exceeds the number of samples).
A dataset with no rows still has one (empty) shard, and the `num_shards == 1`
branch below does not call `.shard()` at all, so nothing else had to change.
Requesting more than one shard from an empty dataset still raises.
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.
Dataset.to_iterable_dataset()defaults tonum_shards=1, but the guard rejects anynum_shards > len(self), so it always raises on an empty dataset:A dataset with no rows still has one (empty) shard, and the
num_shards == 1branch below never calls.shard(), so no other change was needed. Requesting more than one shard from an empty dataset still raises as before.This matches the empty-dataset exemption proposed for
Dataset.shardin #8190, and is the same family as #8385 (save_to_diskon a dataset with no rows).Added
test_dataset_to_iterable_dataset_empty; it fails onmainwith theValueErrorabove and passes with the change.tests/test_arrow_dataset.py→ 400 passed, 25 skipped.