Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from collections.abc import Mapping, Sequence
import dataclasses
import functools
import inspect
import itertools
import multiprocessing
import os
Expand Down Expand Up @@ -136,9 +137,18 @@ def _write_shard(
def get_serialized_examples_iter():
nonlocal num_bytes
nonlocal num_exceptions
dataset = hf_builder.as_dataset(
split=shard_spec.shard_split, run_post_process=False
)
as_dataset_kwargs = dict(split=shard_spec.shard_split)
# We dynamically construct the arguments because the 'run_post_process'
# parameter was only added in Hugging Face 'datasets' 2.9.1. In some
# environments, such as GitHub CI, an older version of the library
# may be installed due to dependency resolution conflicts with
# apache-beam.
if (
'run_post_process'
in inspect.signature(hf_builder.as_dataset).parameters
):
as_dataset_kwargs['run_post_process'] = False
dataset = hf_builder.as_dataset(**as_dataset_kwargs)
for i in range(shard_spec.num_examples):
try:
hf_value = dataset[i]
Expand Down
Loading