Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExamplesIterable fixes #5366

Merged
merged 1 commit into from
Dec 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/datasets/iterable_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ def __iter__(self):
def shuffle_data_sources(self, generator: np.random.Generator) -> "ExamplesIterable":
return ShardShuffledExamplesIterable(self.generate_examples_fn, self.kwargs, generator)

def shard_data_sources(self, shard_idx: int) -> "MappedExamplesIterable":
def shard_data_sources(self, shard_idx: int) -> "ExamplesIterable":
"""Keep only the requested shard."""
kwargs_with_requested_data_source = _split_gen_kwargs(self.kwargs, max_num_jobs=self.n_shards)[shard_idx]
yield from self.generate_examples_fn(**kwargs_with_requested_data_source)
return ExamplesIterable(self.generate_examples_fn, kwargs_with_requested_data_source)

@property
def n_shards(self) -> int:
Expand All @@ -129,7 +129,7 @@ def __iter__(self):
kwargs_with_shuffled_shards = _shuffle_gen_kwargs(rng, self.kwargs)
yield from self.generate_examples_fn(**kwargs_with_shuffled_shards)

def shard_data_sources(self, shard_idx: int) -> "MappedExamplesIterable":
def shard_data_sources(self, shard_idx: int) -> "ExamplesIterable":
"""Keep only the requested shard."""
rng = deepcopy(self.generator)
kwargs_with_shuffled_shards = _shuffle_gen_kwargs(rng, self.kwargs)
Expand Down