File tree 3 files changed +20
-15
lines changed
tensorflow_datasets/scripts/cli
3 files changed +20
-15
lines changed Original file line number Diff line number Diff line change @@ -356,6 +356,7 @@ def _download_and_prepare(
356
356
publish_dir = args .publish_dir ,
357
357
skip_if_published = args .skip_if_published ,
358
358
overwrite = args .overwrite ,
359
+ beam_pipeline_options = args .beam_pipeline_options ,
359
360
)
360
361
361
362
@@ -384,7 +385,7 @@ def _make_download_config(
384
385
if args .update_metadata_only :
385
386
kwargs ['download_mode' ] = tfds .download .GenerateMode .UPDATE_DATASET_INFO
386
387
387
- dl_config = tfds .download .DownloadConfig (
388
+ return tfds .download .DownloadConfig (
388
389
extract_dir = args .extract_dir ,
389
390
manual_dir = manual_dir ,
390
391
max_examples_per_split = args .max_examples_per_split ,
@@ -393,20 +394,6 @@ def _make_download_config(
393
394
** kwargs ,
394
395
)
395
396
396
- # Add Apache Beam options to download config
397
- try :
398
- import apache_beam as beam # pylint: disable=g-import-not-at-top
399
- except ImportError :
400
- beam = None
401
-
402
- if beam is not None :
403
- if args .beam_pipeline_options :
404
- dl_config .beam_options = beam .options .pipeline_options .PipelineOptions (
405
- flags = [f'--{ opt } ' for opt in args .beam_pipeline_options .split (',' )]
406
- )
407
-
408
- return dl_config
409
-
410
397
411
398
def _get_config_name (
412
399
builder_cls : Type [tfds .core .DatasetBuilder ],
Original file line number Diff line number Diff line change @@ -299,6 +299,7 @@ def download_and_prepare(
299
299
publish_dir : epath .Path | None ,
300
300
skip_if_published : bool ,
301
301
overwrite : bool ,
302
+ beam_pipeline_options : str | None ,
302
303
) -> None :
303
304
"""Generate a single builder."""
304
305
dataset = builder .info .full_name
@@ -312,6 +313,22 @@ def download_and_prepare(
312
313
)
313
314
return
314
315
316
+ if not download_config :
317
+ download_config = download .DownloadConfig ()
318
+
319
+ # Add Apache Beam options to download config
320
+ try :
321
+ import apache_beam as beam # pylint: disable=g-import-not-at-top
322
+
323
+ if beam_pipeline_options :
324
+ download_config .beam_options = (
325
+ beam .options .pipeline_options .PipelineOptions (
326
+ flags = [f'--{ opt } ' for opt in beam_pipeline_options .split (',' )]
327
+ )
328
+ )
329
+ except ImportError :
330
+ pass
331
+
315
332
builder .download_and_prepare (
316
333
download_dir = download_dir ,
317
334
download_config = download_config ,
Original file line number Diff line number Diff line change @@ -155,6 +155,7 @@ def prepare_croissant_builder(
155
155
publish_dir = args .publish_dir ,
156
156
skip_if_published = args .skip_if_published ,
157
157
overwrite = args .overwrite ,
158
+ beam_pipeline_options = None ,
158
159
)
159
160
return builder
160
161
You can’t perform that action at this time.
0 commit comments