In the LocalJob class, which inherits from threading.Thread, the run() method uses os.chdir() to change the working directory before launching a background process, and then changes it back in a finally block
os.chdir(self.execution_dir)
self._process = subprocess.Popen(
self.command,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
encoding="utf-8",
bufsize=1,
env=self.env,
)
https://github.com/kubeflow/sdk/blob/57ac0138eefa2cac18729fa9da611bfbd8fc00ed/kubeflow/trainer/backends/localprocess/job.py#L76C1-L87C14
If multiple LocalJob threads run concurrently, they will mix up each other's working directories, leading to chaotic path-resolution failures.
So instead of changing the path using the os.chdir(), can't we provide the path as an argument for the subprocess creation time? since this prevents changing the main process's path.
self._process = subprocess.Popen(
self.command,
cwd=self.execution_dir,
......
)
In the
LocalJobclass, which inherits fromthreading.Thread, therun()method usesos.chdir()to change the working directory before launching a background process, and then changes it back in afinallyblockhttps://github.com/kubeflow/sdk/blob/57ac0138eefa2cac18729fa9da611bfbd8fc00ed/kubeflow/trainer/backends/localprocess/job.py#L76C1-L87C14
If multiple
LocalJobthreads run concurrently, they will mix up each other's working directories, leading to chaotic path-resolution failures.So instead of changing the path using the
os.chdir(), can't we provide the path as an argument for the subprocess creation time? since this prevents changing the main process's path.