Skip to content

Commit 7458114

Browse files
authored
Merge branch 'master' into py3
2 parents de5a7e1 + a774d7f commit 7458114

File tree

9 files changed

+71
-40
lines changed

9 files changed

+71
-40
lines changed

cwltool/draft2tool.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,18 @@ def run(self, **kwargs): # type: (**Any) -> None
6161
e, exc_info=kwargs.get('debug'))
6262
self.output_callback({}, "permanentFail")
6363

64-
def job(self, joborder, output_callback, **kwargs):
65-
# type: (Dict[Text, Text], Callable[[Any, Any], Any], **Any) -> Generator[ExpressionTool.ExpressionJob, None, None]
66-
builder = self._init_job(joborder, **kwargs)
64+
def job(self,
65+
job_order, # type: Dict[Text, Text]
66+
output_callbacks, # type: Callable[[Any, Any], Any]
67+
**kwargs # type: Any
68+
):
69+
# type: (...) -> Generator[ExpressionTool.ExpressionJob, None, None]
70+
builder = self._init_job(job_order, **kwargs)
6771

6872
j = ExpressionTool.ExpressionJob()
6973
j.builder = builder
7074
j.script = self.tool["expression"]
71-
j.output_callback = output_callback
75+
j.output_callback = output_callbacks
7276
j.requirements = self.requirements
7377
j.hints = self.hints
7478
j.outdir = None
@@ -166,8 +170,12 @@ def makePathMapper(self, reffiles, stagedir, **kwargs):
166170
dockerReq, _ = self.get_requirement("DockerRequirement")
167171
return PathMapper(reffiles, kwargs["basedir"], stagedir)
168172

169-
def job(self, joborder, output_callback, **kwargs):
170-
# type: (Dict[Text, Text], Callable[..., Any], **Any) -> Generator[Union[CommandLineJob, CallbackJob], None, None]
173+
def job(self,
174+
job_order, # type: Dict[Text, Text]
175+
output_callbacks, # type: Callable[[Any, Any], Any]
176+
**kwargs # type: Any
177+
):
178+
# type: (...) -> Generator[Union[CommandLineJob, CallbackJob], None, None]
171179

172180
jobname = uniquename(kwargs.get("name", shortname(self.tool.get("id", "job"))))
173181

@@ -176,7 +184,7 @@ def job(self, joborder, output_callback, **kwargs):
176184
cacheargs["outdir"] = "/out"
177185
cacheargs["tmpdir"] = "/tmp"
178186
cacheargs["stagedir"] = "/stage"
179-
cachebuilder = self._init_job(joborder, **cacheargs)
187+
cachebuilder = self._init_job(job_order, **cacheargs)
180188
cachebuilder.pathmapper = PathMapper(cachebuilder.files,
181189
kwargs["basedir"],
182190
cachebuilder.stagedir,
@@ -223,7 +231,7 @@ def job(self, joborder, output_callback, **kwargs):
223231
cachebuilder.outdir = jobcache
224232

225233
_logger.info("[job %s] Using cached output in %s", jobname, jobcache)
226-
yield CallbackJob(self, output_callback, cachebuilder, jobcache)
234+
yield CallbackJob(self, output_callbacks, cachebuilder, jobcache)
227235
return
228236
else:
229237
_logger.info("[job %s] Output of job will be cached in %s", jobname, jobcache)
@@ -232,19 +240,19 @@ def job(self, joborder, output_callback, **kwargs):
232240
kwargs["outdir"] = jobcache
233241
open(jobcachepending, "w").close()
234242

235-
def rm_pending_output_callback(output_callback, jobcachepending,
243+
def rm_pending_output_callback(output_callbacks, jobcachepending,
236244
outputs, processStatus):
237245
if processStatus == "success":
238246
os.remove(jobcachepending)
239-
output_callback(outputs, processStatus)
247+
output_callbacks(outputs, processStatus)
240248

241-
output_callback = cast(
249+
output_callbacks = cast(
242250
Callable[..., Any], # known bug in mypy
243251
# https://github.com/python/mypy/issues/797
244-
partial(rm_pending_output_callback, output_callback,
252+
partial(rm_pending_output_callback, output_callbacks,
245253
jobcachepending))
246254

247-
builder = self._init_job(joborder, **kwargs)
255+
builder = self._init_job(job_order, **kwargs)
248256

249257
reffiles = copy.deepcopy(builder.files)
250258

@@ -266,7 +274,7 @@ def rm_pending_output_callback(output_callback, jobcachepending,
266274
j.name,
267275
self.tool.get("id", ""),
268276
u" as part of %s" % kwargs["part_of"] if "part_of" in kwargs else "")
269-
_logger.debug(u"[job %s] %s", j.name, json.dumps(joborder, indent=4))
277+
_logger.debug(u"[job %s] %s", j.name, json.dumps(job_order, indent=4))
270278

271279
builder.pathmapper = None
272280
make_path_mapper_kwargs = kwargs
@@ -378,7 +386,7 @@ def rm_pending_output_callback(output_callback, jobcachepending,
378386
j.collect_outputs = partial(
379387
self.collect_output_ports, self.tool["outputs"], builder,
380388
compute_checksum=kwargs.get("compute_checksum", True))
381-
j.output_callback = output_callback
389+
j.output_callback = output_callbacks
382390

383391
yield j
384392

cwltool/factory.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,13 @@ def __call__(self, **kwargs):
3434

3535

3636
class Factory(object):
37-
def __init__(self, makeTool=workflow.defaultMakeTool,
38-
executor=main.single_job_executor,
39-
**execkwargs):
40-
# type: (tCallable[[Dict[Text, Any], Any], Process],tCallable[...,Tuple[Dict[Text,Any], Text]], **Any) -> None
37+
def __init__(self,
38+
makeTool=workflow.defaultMakeTool, # type: tCallable[[Any], Process]
39+
# should be tCallable[[Dict[Text, Any], Any], Process] ?
40+
executor=main.single_job_executor, # type: tCallable[...,Tuple[Dict[Text,Any], Text]]
41+
**execkwargs # type: Any
42+
):
43+
# type: (...) -> None
4144
self.makeTool = makeTool
4245
self.executor = executor
4346
self.execkwargs = execkwargs

cwltool/job.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ def run(self, dry_run=False, pull_image=True, rm_container=True,
206206

207207
scr, _ = get_feature(self, "ShellCommandRequirement")
208208

209+
shouldquote = None # type: Callable[[Any], Any]
209210
if scr:
210211
shouldquote = lambda x: False
211212
else:

cwltool/main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,11 @@ def arg_parser(): # type: () -> argparse.ArgumentParser
183183
return parser
184184

185185

186-
def single_job_executor(t, job_order_object, **kwargs):
187-
# type: (Process, Dict[Text, Any], **Any) -> Tuple[Dict[Text, Any], Text]
186+
def single_job_executor(t, # type: Process
187+
job_order_object, # type: Dict[Text, Any]
188+
**kwargs # type: Any
189+
):
190+
# type: (...) -> Tuple[Dict[Text, Any], Text]
188191
final_output = []
189192
final_status = []
190193

cwltool/process.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,8 +599,12 @@ def visit(self, op): # type: (Callable[[Dict[Text, Any]], None]) -> None
599599
op(self.tool)
600600

601601
@abc.abstractmethod
602-
def job(self, job_order, output_callbacks, **kwargs):
603-
# type: (Dict[Text, Text], Callable[[Any, Any], Any], **Any) -> Generator[Any, None, None]
602+
def job(self,
603+
job_order, # type: Dict[Text, Text]
604+
output_callbacks, # type: Callable[[Any, Any], Any]
605+
**kwargs # type: Any
606+
):
607+
# type: (...) -> Generator[Any, None, None]
604608
return None
605609

606610

cwltool/workflow.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
WorkflowStateItem = namedtuple('WorkflowStateItem', ['parameter', 'value'])
2323

2424

25-
def defaultMakeTool(toolpath_object, **kwargs):
26-
# type: (Dict[Text, Any], **Any) -> Process
25+
def defaultMakeTool(toolpath_object, # type: Dict[Text, Any]
26+
**kwargs # type: Any
27+
):
28+
# type: (...) -> Process
2729
if not isinstance(toolpath_object, dict):
2830
raise WorkflowException(u"Not a dict: `%s`" % toolpath_object)
2931
if "class" in toolpath_object:
@@ -436,15 +438,19 @@ def __init__(self, toolpath_object, **kwargs):
436438

437439
# TODO: statically validate data links instead of doing it at runtime.
438440

439-
def job(self, joborder, output_callback, **kwargs):
440-
# type: (Dict[Text, Text], Callable[[Any, Any], Any], **Any) -> Generator
441-
builder = self._init_job(joborder, **kwargs)
441+
def job(self,
442+
job_order, # type: Dict[Text, Text]
443+
output_callbacks, # type: Callable[[Any, Any], Any]
444+
**kwargs # type: Any
445+
):
446+
# type: (...) -> Generator[Any, None, None]
447+
builder = self._init_job(job_order, **kwargs)
442448
wj = WorkflowJob(self, **kwargs)
443449
yield wj
444450

445451
kwargs["part_of"] = u"workflow %s" % wj.name
446452

447-
for w in wj.job(builder.job, output_callback, **kwargs):
453+
for w in wj.job(builder.job, output_callbacks, **kwargs):
448454
yield w
449455

450456
def visit(self, op):
@@ -561,17 +567,23 @@ def receive_output(self, output_callback, jobout, processStatus):
561567
processStatus = "permanentFail"
562568
output_callback(output, processStatus)
563569

564-
def job(self, joborder, output_callback, **kwargs):
565-
# type: (Dict[Text, Any], Callable[...,Any], **Any) -> Generator
570+
def job(self,
571+
job_order, # type: Dict[Text, Text]
572+
output_callbacks, # type: Callable[[Any, Any], Any]
573+
**kwargs # type: Any
574+
):
575+
# type: (...) -> Generator[Any, None, None]
566576
for i in self.tool["inputs"]:
567577
p = i["id"]
568578
field = shortname(p)
569-
joborder[field] = joborder[i["id"]]
570-
del joborder[i["id"]]
579+
job_order[field] = job_order[i["id"]]
580+
del job_order[i["id"]]
571581

572582
try:
573-
for t in self.embedded_tool.job(joborder,
574-
functools.partial(self.receive_output, output_callback),
583+
for t in self.embedded_tool.job(job_order,
584+
functools.partial(
585+
self.receive_output,
586+
output_callbacks),
575587
**kwargs):
576588
yield t
577589
except WorkflowException:

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ ruamel.yaml==0.13.7
33
rdflib==4.2.1
44
rdflib-jsonld==0.4.0
55
shellescape==3.4.1
6-
schema-salad>=2.1.20161227155225,<3
6+
schema-salad>=2.1.20170208112505,<3
77
typing==3.5.2.2 ; python_version>="2.7"

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
'ruamel.yaml >= 0.12.4',
4848
'rdflib >= 4.2.0, < 4.3.0',
4949
'shellescape >= 3.4.1, < 3.5',
50-
'schema-salad >= 2.2.20170111180227, < 3',
51-
'typing >= 3.5.2, < 3.6',
50+
'schema-salad >= 2.2.20170208112505, < 3',
51+
'typing >= 3.5.2, < 3.6' ,
5252
'six >= 1.10.0',
5353
],
5454
test_suite='tests',

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tox]
22
#envlist = py35-lint,py34-lint,py33-lint,py27-lint,py35-unit,py34-unit,py33-unit,py27-unit
3-
envlist = py27-lint, py27-unit, pip27-pipconflictchecker, py35-mypy, py36-lint, py35-lint, py34-lint, py33-lint
3+
envlist = py27-lint, py27-unit, py27-pipconflictchecker, py35-mypy, py36-lint, py35-lint, py34-lint, py33-lint
44
skipsdist = True
55

66
[tox:travis]
@@ -14,7 +14,7 @@ deps = -rrequirements.txt
1414
commands = make mypy
1515
whitelist_externals = make
1616
deps =
17-
mypy-lang>=0.4.4
17+
mypy>=0.470
1818
typed-ast
1919
-rrequirements.txt
2020

0 commit comments

Comments
 (0)