File tree Expand file tree Collapse file tree
tensorflow_datasets/core/dataset_builders Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2929from collections .abc import Mapping , Sequence
3030import dataclasses
3131import functools
32+ import inspect
3233import itertools
3334import multiprocessing
3435import os
@@ -136,9 +137,18 @@ def _write_shard(
136137 def get_serialized_examples_iter ():
137138 nonlocal num_bytes
138139 nonlocal num_exceptions
139- dataset = hf_builder .as_dataset (
140- split = shard_spec .shard_split , run_post_process = False
141- )
140+ as_dataset_kwargs = dict (split = shard_spec .shard_split )
141+ # We dynamically construct the arguments because the 'run_post_process'
142+ # parameter was only added in Hugging Face 'datasets' 2.9.1. In some
143+ # environments, such as GitHub CI, an older version of the library
144+ # may be installed due to dependency resolution conflicts with
145+ # apache-beam.
146+ if (
147+ 'run_post_process'
148+ in inspect .signature (hf_builder .as_dataset ).parameters
149+ ):
150+ as_dataset_kwargs ['run_post_process' ] = False
151+ dataset = hf_builder .as_dataset (** as_dataset_kwargs )
142152 for i in range (shard_spec .num_examples ):
143153 try :
144154 hf_value = dataset [i ]
You can’t perform that action at this time.
0 commit comments