Skip to content

Commit

Permalink
Make sure that WriteTransformFn.publish_outputs is idempotent.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 700817208
  • Loading branch information
tf-transform-team authored and tfx-copybara committed Nov 27, 2024
1 parent 9ab3ebc commit a14023c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tensorflow_transform/beam/tft_beam_io/transform_fn_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,15 @@ def publish_outputs(unused_element, metadata_source_path,
if not tf.io.gfile.exists(self._path):
tf.io.gfile.makedirs(self._path)

if tf.io.gfile.exists(metadata_path):
tf.io.gfile.rmtree(metadata_path)
tf.io.gfile.rename(metadata_source_path, metadata_path, overwrite=True)

if tf.io.gfile.exists(transform_fn_path):
tf.io.gfile.rmtree(transform_fn_path)
tf.io.gfile.rename(
transform_fn_source_path, transform_fn_path, overwrite=True)

# TODO(b/211615643): Remove the exists check once importing TFIO in S3
# addresses NotFoundError.
if tf.io.gfile.exists(base_temp_dir):
Expand Down

0 comments on commit a14023c

Please sign in to comment.