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

Fix convert_format when the requested input format is already the default input format. #5715

Merged
merged 1 commit into from
Nov 6, 2024
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
26 changes: 21 additions & 5 deletions tensorflow_datasets/scripts/cli/convert_format_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,16 +475,32 @@ def _get_info_for_dirs_to_convert(
return None
in_file_format = file_adapters.FileFormat(dataset_info_proto.file_format)
if out_file_format == in_file_format:
raise ValueError(
f'The file format of the dataset ({in_file_format}) is the'
f' same as the specified out file format! ({out_file_format})'
)
if os.fspath(from_dir) == os.fspath(to_dir):
logging.warning(
'The file format to convert to (%s) is already the default file'
' format of the dataset in %s, and no different output folder is'
' specified. Skipping conversion.',
out_file_format.value,
os.fspath(from_dir),
)
return None
else:
logging.info(
'The file format to convert to (%s) is the same as the default file'
' format, but the converted output is being written to a different'
' folder. The shards will be converted anyway from: %s, to: %s',
out_file_format.value,
os.fspath(from_dir),
os.fspath(to_dir),
)
return dataset_info_proto
if out_file_format.file_suffix in dataset_info_proto.alternative_file_formats:
if overwrite:
logging.warning(
'The file format to convert to (%s) is already an alternative file'
' format. Overwriting the shards!',
' format for the dataset in %s. Overwriting the shards!',
out_file_format.value,
os.fspath(from_dir),
)
elif os.fspath(from_dir) == os.fspath(to_dir):
logging.info(
Expand Down
Loading