Skip to content

Commit 7c59cde

Browse files
committed
more tmp_outdir_prefix
1 parent f081a89 commit 7c59cde

File tree

3 files changed

+25
-35
lines changed

3 files changed

+25
-35
lines changed

cwltool/executors.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,18 @@ def run_jobs(self,
4343
):
4444
pass
4545

46-
def execute(self, t, # type: Process
46+
def execute(self,
47+
t, # type: Process
4748
job_order_object, # type: Dict[Text, Any]
4849
logger=_logger,
49-
**kwargs # type: Any
50-
):
51-
# type: (...) -> Tuple[Dict[Text, Any], Text]
50+
**kwargs # type: Any
51+
): # type: (...) -> Tuple[Dict[Text, Any], Text]
5252

5353
if "basedir" not in kwargs:
5454
raise WorkflowException("Must provide 'basedir' in kwargs")
5555

5656
finaloutdir = os.path.abspath(kwargs.get("outdir")) if kwargs.get("outdir") else None
57-
kwargs["outdir"] = tempfile.mkdtemp(prefix=kwargs["tmp_outdir_prefix"]) if kwargs.get(
58-
"tmp_outdir_prefix") else tempfile.mkdtemp()
57+
kwargs["outdir"] = tempfile.mkdtemp(prefix=kwargs.get("tmp_outdir_prefix"))
5958
self.output_dirs.add(kwargs["outdir"])
6059
kwargs["mutation_manager"] = MutationManager()
6160
kwargs["toplevel"] = True

cwltool/job.py

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,14 @@ def _setup(self, kwargs): # type: (Dict) -> None
175175
_logger.debug(u"[job %s] initial work dir %s", self.name,
176176
json.dumps({p: self.generatemapper.mapper(p) for p in self.generatemapper.files()}, indent=4))
177177

178-
def _execute(self, runtime, env, rm_tmpdir=True, move_outputs="move", secret_store=None):
179-
# type: (List[Text], MutableMapping[Text, Text], bool, Text, SecretStore) -> None
178+
def _execute(self,
179+
runtime, # type:List[Text]
180+
env, # type: MutableMapping[Text, Text]
181+
rm_tmpdir=True, # type: bool
182+
move_outputs="move", # type: Text
183+
secret_store=None, # type: SecretStore
184+
tmp_outdir_prefix=None # type: Text
185+
): # type: (...) -> None
180186

181187
scr, _ = get_feature(self, "ShellCommandRequirement")
182188

@@ -228,14 +234,9 @@ def _execute(self, runtime, env, rm_tmpdir=True, move_outputs="move", secret_sto
228234
if builder is not None:
229235
job_script_contents = builder.build_job_script(commands)
230236
rcode = _job_popen(
231-
commands,
232-
stdin_path=stdin_path,
233-
stdout_path=stdout_path,
234-
stderr_path=stderr_path,
235-
env=env,
236-
cwd=self.outdir,
237-
job_script_contents=job_script_contents,
238-
)
237+
commands, stdin_path, stdout_path, stderr_path, env,
238+
self.outdir, tempfile.mkdtemp(prefix=tmp_outdir_prefix),
239+
job_script_contents)
239240

240241
if self.successCodes and rcode in self.successCodes:
241242
processStatus = "success"
@@ -415,16 +416,15 @@ def run(self, pull_image=True, rm_container=True,
415416

416417

417418
def _job_popen(
418-
commands, # type: List[Text]
419-
stdin_path, # type: Text
420-
stdout_path, # type: Text
421-
stderr_path, # type: Text
419+
commands, # type: List[Text]
420+
stdin_path, # type: Text
421+
stdout_path, # type: Text
422+
stderr_path, # type: Text
422423
env, # type: Union[MutableMapping[Text, Text], MutableMapping[str, str]]
423-
cwd, # type: Text
424-
job_dir=None, # type: Text
424+
cwd, # type: Text
425+
job_dir, # type: Text
425426
job_script_contents=None, # type: Text
426-
):
427-
# type: (...) -> int
427+
): # type: (...) -> int
428428
if not job_script_contents and not FORCE_SHELLED_POPEN:
429429

430430
stdin = None # type: Union[IO[Any], int]
@@ -471,9 +471,6 @@ def _job_popen(
471471

472472
return rcode
473473
else:
474-
if job_dir is None:
475-
job_dir = tempfile.mkdtemp(prefix="cwltooljob")
476-
477474
if not job_script_contents:
478475
job_script_contents = SHELL_COMMAND_TEMPLATE
479476

cwltool/workflow.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,8 @@ def __init__(self, workflow, **kwargs):
179179
self.state = None # type: Dict[Text, WorkflowStateItem]
180180
self.processStatus = None # type: Text
181181
self.did_callback = False
182-
183-
if "outdir" in kwargs:
184-
self.outdir = kwargs["outdir"]
185-
elif "tmp_outdir_prefix" in kwargs:
186-
self.outdir = tempfile.mkdtemp(prefix=kwargs["tmp_outdir_prefix"])
187-
else:
188-
# tmp_outdir_prefix defaults to tmp, so this is unlikely to be used
189-
self.outdir = tempfile.mkdtemp()
182+
self.outdir = kwargs.get("outdir")
183+
self.outdir = tempfile.mkdtemp(prefix=kwargs.get("tmp_outdir_prefix"))
190184

191185
self.name = uniquename(u"workflow %s" % kwargs.get("name", shortname(self.workflow.tool.get("id", "embedded"))))
192186

0 commit comments

Comments
 (0)