Skip to content

Commit 13d46ae

Browse files
author
The TensorFlow Datasets Authors
committed
Use reraise instead of add_note in naming.py and split_builder.py.
PiperOrigin-RevId: 651504582
1 parent 50001e8 commit 13d46ae

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

tensorflow_datasets/core/naming.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
from absl import logging
2828
from etils import epath
29+
from tensorflow_datasets.core.utils import py_utils
2930
from tensorflow_datasets.core.utils import version as version_lib
3031

3132
_NAME_CLASS = r'[a-zA-Z][\w]*'
@@ -185,8 +186,7 @@ def _dataset_name_and_kwargs_from_name_str(
185186
kwargs[attr] = val
186187
return name, kwargs
187188
except Exception as e: # pylint: disable=broad-except
188-
e.add_note(err_msg)
189-
raise e
189+
py_utils.reraise(e, prefix=err_msg) # pytype: disable=bad-return-type
190190

191191

192192
@dataclasses.dataclass(order=True)

tensorflow_datasets/core/split_builder.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,14 +399,14 @@ def _build_from_generator(
399399
try:
400400
example = self._features.encode_example(example)
401401
except Exception as e: # pylint: disable=broad-except
402-
e.add_note(f'Failed to encode example:\n{example}\n')
403-
raise
402+
utils.reraise(e, prefix=f'Failed to encode example:\n{example}\n')
404403
writer.write(key, example)
405404
try:
406405
shard_lengths, total_size = writer.finalize()
407406
except Exception as e: # pylint: disable=broad-except
408-
e.add_note(f'Failed to finalize writing of split "{split_name}"')
409-
raise
407+
utils.reraise(
408+
e, prefix=f'Failed to finalize writing of split "{split_name}"'
409+
)
410410

411411
split_info = splits_lib.SplitInfo(
412412
name=split_name,

0 commit comments

Comments
 (0)