Skip to content

Commit 7ee0436

Browse files
author
Anton Khodak
committed
Add default command line arguments for cwltool as Factory
1 parent c2a6d85 commit 7ee0436

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

cwltool/argparser.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,16 @@ def arg_parser(): # type: () -> argparse.ArgumentParser
217217
return parser
218218

219219

220+
def get_default_args():
221+
# type: () -> Dict[str, Any]
222+
"""
223+
Get default values of cwltool's command line options
224+
"""
225+
ap = arg_parser()
226+
args = ap.parse_args()
227+
return vars(args)
228+
229+
220230
class FSAction(argparse.Action):
221231
objclass = None # type: Text
222232

cwltool/factory.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from typing import Any, Dict, Text, Tuple, Union
55

66
from . import load_tool, main, workflow
7+
from .argparser import get_default_args
78
from .process import Process
89

910

@@ -41,7 +42,13 @@ def __init__(self,
4142
# type: (...) -> None
4243
self.makeTool = makeTool
4344
self.executor = executor
44-
self.execkwargs = execkwargs
45+
46+
kwargs = get_default_args()
47+
kwargs.pop("job_order")
48+
kwargs.pop("workflow")
49+
kwargs.pop("outdir")
50+
kwargs.update(execkwargs)
51+
self.execkwargs = kwargs
4552

4653
def make(self, cwl):
4754
"""Instantiate a CWL object from a CWl document."""

tests/test_examples.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,16 @@ def test_factory(self):
136136
echo = f.make(get_data("tests/echo.cwl"))
137137
self.assertEqual(echo(inp="foo"), {"out": "foo\n"})
138138

139+
def test_default_args(self):
140+
f = cwltool.factory.Factory()
141+
assert f.execkwargs["use_container"] is True
142+
assert f.execkwargs["on_error"] == "stop"
143+
144+
def test_redefined_args(self):
145+
f = cwltool.factory.Factory(use_container=False, on_error="continue")
146+
assert f.execkwargs["use_container"] is False
147+
assert f.execkwargs["on_error"] == "continue"
148+
139149
def test_partial_scatter(self):
140150
f = cwltool.factory.Factory(on_error="continue")
141151
fail = f.make(get_data("tests/wf/scatterfail.cwl"))

0 commit comments

Comments
 (0)