Skip to content
This repository was archived by the owner on Jan 21, 2025. It is now read-only.

Commit 3c68c82

Browse files
afrozenatorMesh TensorFlow Team
authored andcommitted
[MTF] Minor usability change in get_inputs_from_file for accidentally empty files.
PiperOrigin-RevId: 369484325
1 parent 3dc48f5 commit 3c68c82

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

mesh_tensorflow/transformer/utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,11 @@ def get_inputs_from_file(input_filename, ignore_comments=False):
12051205
with tf.io.gfile.GFile(input_filename, "r") as f:
12061206
inputs = [line.rstrip() for line in f]
12071207

1208+
# If this is an empty file (because of stripping), return early.
1209+
if not inputs:
1210+
tf.logging.info("input file is empty after rstrip: %s", input_filename)
1211+
return []
1212+
12081213
# Strip the last empty line.
12091214
if not inputs[-1]:
12101215
inputs.pop()

0 commit comments

Comments
 (0)