Skip to content

Commit 69d769c

Browse files
kannon92mr-c
authored andcommitted
feat: added callback for getting a log dir file path
1 parent 54e3502 commit 69d769c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

cwltool/context.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ def log_handler(
7070
if stderr_path:
7171
new_stderr_path = stderr_path.replace(base_path_logs, outdir)
7272
shutil.copy2(stderr_path, new_stderr_path)
73+
# Default handler for setting the log directory
74+
def set_log_dir(
75+
outdir: str,
76+
log_dir: str,
77+
subdir_name: str
78+
) -> str:
79+
if log_dir == "":
80+
return outdir
81+
else:
82+
return log_dir + "/" + subdir_name
7383

7484

7585
class LoadingContext(ContextBase):
@@ -135,6 +145,7 @@ def __init__(self, kwargs: Optional[Dict[str, Any]] = None) -> None:
135145
self.rm_container = True # type: bool
136146
self.move_outputs = "move" # type: str
137147
self.log_dir = "" # type: str
148+
self.set_log_dir = set_log_dir
138149
self.log_dir_handler = log_handler
139150
self.streaming_allowed: bool = False
140151

cwltool/job.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,7 @@ def is_streamable(file: str) -> bool:
226226
indent=4,
227227
),
228228
)
229-
if runtimeContext.log_dir == "":
230-
self.base_path_logs = self.outdir
231-
else:
232-
self.base_path_logs = runtimeContext.log_dir + "/" + uuid.uuid4().hex
229+
self.base_path_logs = runtimeContext.set_log_dir(self.outdir, runtimeContext.log_dir, self.name)
233230

234231
def _execute(
235232
self,

0 commit comments

Comments
 (0)