Skip to content

Commit

Permalink
fix(sdk): fix multiple workers writing with gcsfuse bug [KFP SDK v2] (k…
Browse files Browse the repository at this point in the history
…ubeflow#8455)

* fix(sdk): fix multiple workers writing with gcsfuse bug [KFP SDK v1]

* add comment for context
  • Loading branch information
connor-mccarthy authored and gkcalat committed Nov 23, 2022
1 parent 7981629 commit 9a468cd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions sdk/python/kfp/components/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,12 @@ def _write_executor_output(self, func_output: Optional[Any] = None):
' subclass of `Artifact`, or a NamedTuple collection of these types.'
.format(self._return_annotation))

import os
os.makedirs(
os.path.dirname(self._input['outputs']['outputFile']),
exist_ok=True)
with open(self._input['outputs']['outputFile'], 'w') as f:
f.write(json.dumps(self._executor_output))
executor_output_path = self._input['outputs']['outputFile']
# This check is to reduce the likelihood that two or more workers (in a distributed training/compute strategy) attempt to write to the same executor output file at the same time using gcsfuse. Do not remove until fixed by gcsfuse.
if not os.path.exists(executor_output_path):
os.makedirs(os.path.dirname(executor_output_path), exist_ok=True)
with open(executor_output_path, 'w') as f:
f.write(json.dumps(self._executor_output))

def execute(self):
annotations = inspect.getfullargspec(self._func).annotations
Expand Down

0 comments on commit 9a468cd

Please sign in to comment.