Skip to content

Commit 30a1ad0

Browse files
tomvdwThe TensorFlow Datasets Authors
authored andcommitted
Fix bug that initialized the alternative file formats incorrectly
It calls `self.add_alterative_file_format`, which assumes the info proto is already created, but this happens later in the __init__. Since the alternative file formats in the proto is also initialized later in the __init__, we do not need to call add_alternative_file_format PiperOrigin-RevId: 645331634
1 parent 58ae072 commit 30a1ad0

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tensorflow_datasets/core/dataset_info.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,13 @@ def __init__(
251251
else:
252252
self._identity = DatasetIdentity.from_builder(builder)
253253

254+
# Convert alternative_file_formats to a list of `FileFormat`.
254255
self._alternative_file_formats: list[file_adapters.FileFormat] = []
255-
if alternative_file_formats:
256-
for file_format in alternative_file_formats:
257-
if isinstance(file_format, str):
258-
file_format = file_adapters.FileFormat.from_value(file_format)
259-
self.add_alternative_file_format(file_format)
256+
if alternative_file_formats is not None:
257+
for f in alternative_file_formats:
258+
if isinstance(f, str):
259+
f = file_adapters.FileFormat.from_value(f)
260+
self._alternative_file_formats.append(f)
260261

261262
self._info_proto = dataset_info_pb2.DatasetInfo(
262263
name=self._identity.name,

0 commit comments

Comments
 (0)