Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sdk): fix multiple workers writing with gcsfuse bug [KFP SDK v2] #8455

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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