Skip to content

Commit 69e0840

Browse files
author
The TensorFlow Datasets Authors
committed
Fix convert_format when the requested input format is already the default input format.
PiperOrigin-RevId: 693690208
1 parent 03ad7d8 commit 69e0840

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

tensorflow_datasets/scripts/cli/convert_format_utils.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -475,16 +475,32 @@ def _get_info_for_dirs_to_convert(
475475
return None
476476
in_file_format = file_adapters.FileFormat(dataset_info_proto.file_format)
477477
if out_file_format == in_file_format:
478-
raise ValueError(
479-
f'The file format of the dataset ({in_file_format}) is the'
480-
f' same as the specified out file format! ({out_file_format})'
481-
)
478+
if os.fspath(from_dir) == os.fspath(to_dir):
479+
logging.warning(
480+
'The file format to convert to (%s) is already the default file'
481+
' format of the dataset in %s, and no different output folder is'
482+
' specified. Skipping conversion.',
483+
out_file_format.value,
484+
os.fspath(from_dir),
485+
)
486+
return None
487+
else:
488+
logging.info(
489+
'The file format to convert to (%s) is the same as the default file'
490+
' format, but the converted output is being written to a different'
491+
' folder. The shards will be converted anyway from: %s, to: %s',
492+
out_file_format.value,
493+
os.fspath(from_dir),
494+
os.fspath(to_dir),
495+
)
496+
return dataset_info_proto
482497
if out_file_format.file_suffix in dataset_info_proto.alternative_file_formats:
483498
if overwrite:
484499
logging.warning(
485500
'The file format to convert to (%s) is already an alternative file'
486-
' format. Overwriting the shards!',
501+
' format for the dataset in %s. Overwriting the shards!',
487502
out_file_format.value,
503+
os.fspath(from_dir),
488504
)
489505
elif os.fspath(from_dir) == os.fspath(to_dir):
490506
logging.info(

0 commit comments

Comments
 (0)