Skip to content

Commit bbb65f9

Browse files
authored
Create working directory (#767)
* Create working directory if it does not exist before * fix flux spawner * always create working directory
1 parent ecfc2db commit bbb65f9

File tree

4 files changed

+7
-1
lines changed

4 files changed

+7
-1
lines changed

executorlib/standalone/interactive/spawner.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import subprocess
23
from abc import ABC, abstractmethod
34
from typing import Optional
@@ -93,6 +94,8 @@ def bootup(
9394
Args:
9495
command_lst (list[str]): The command list to execute.
9596
"""
97+
if self._cwd is not None:
98+
os.makedirs(self._cwd, exist_ok=True)
9699
self._process = subprocess.Popen(
97100
args=self.generate_command(command_lst=command_lst),
98101
cwd=self._cwd,

executorlib/task_scheduler/file/queue_spawner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def execute_with_pysqa(
6161
else:
6262
folder = command[-1].split("_i.h5")[0]
6363
cwd = os.path.join(cache_directory, folder)
64-
os.makedirs(cwd, exist_ok=True)
64+
os.makedirs(cwd, exist_ok=True)
6565
submit_kwargs = {
6666
"command": " ".join(command),
6767
"dependency_list": [str(qid) for qid in task_dependent_lst],

executorlib/task_scheduler/file/subprocess_spawner.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ def execute_in_subprocess(
5656
if resource_dict is None:
5757
resource_dict = {}
5858
cwd = resource_dict.get("cwd", cache_directory)
59+
if cwd is not None:
60+
os.makedirs(cwd, exist_ok=True)
5961
return subprocess.Popen(command, universal_newlines=True, cwd=cwd)
6062

6163

executorlib/task_scheduler/interactive/fluxspawner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def bootup(
113113
jobspec.setattr_shell_option("pmi", self._pmi_mode)
114114
if self._cwd is not None:
115115
jobspec.cwd = self._cwd
116+
os.makedirs(self._cwd, exist_ok=True)
116117
if self._flux_log_files and self._cwd is not None:
117118
jobspec.stderr = os.path.join(self._cwd, "flux.err")
118119
jobspec.stdout = os.path.join(self._cwd, "flux.out")

0 commit comments

Comments
 (0)