Skip to content

Commit

Permalink
Try mkdir for final destination before in WriteFiles (#31690)
Browse files Browse the repository at this point in the history
* Try mkdir for final destination before in WriteFiles

* debug log when fail mkdir
  • Loading branch information
Abacn authored Jun 26, 2024
1 parent 46b0a71 commit 2f51718
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sdks/python/apache_beam/io/fileio.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,14 @@ def process(self, element, w=beam.DoFn.WindowParam):
self.path.get(),
move_to)

try:
filesystems.FileSystems.mkdirs(self.path.get())
except IOError as e:
cause = repr(e)
if 'FileExistsError' not in cause:
# Usually harmless. Especially if see FileExistsError so no need to log
_LOGGER.debug('Fail to create dir for final destination: %s', cause)

try:
filesystems.FileSystems.rename(
move_from,
Expand Down

0 comments on commit 2f51718

Please sign in to comment.