1 from cwltool.draft2tool import CommandLineTool
2 from .arvjob import ArvadosJob
3 from .arvcontainer import ArvadosContainer
4 from .pathmapper import ArvPathMapper
6 class ArvadosCommandTool(CommandLineTool):
7 """Wrap cwltool CommandLineTool to override selected methods."""
9 def __init__(self, arvrunner, toolpath_object, **kwargs):
10 super(ArvadosCommandTool, self).__init__(toolpath_object, **kwargs)
11 self.arvrunner = arvrunner
12 self.work_api = kwargs["work_api"]
14 def makeJobRunner(self):
15 if self.work_api == "containers":
16 return ArvadosContainer(self.arvrunner)
17 elif self.work_api == "jobs":
18 return ArvadosJob(self.arvrunner)
20 def makePathMapper(self, reffiles, stagedir, **kwargs):
21 # type: (List[Any], unicode, **Any) -> PathMapper
22 if self.work_api == "containers":
23 return ArvPathMapper(self.arvrunner, reffiles, kwargs["basedir"],
27 elif self.work_api == "jobs":
28 return ArvPathMapper(self.arvrunner, reffiles, kwargs["basedir"],
33 def job(self, joborder, output_callback, **kwargs):
34 if self.work_api == "containers":
35 kwargs["outdir"] = "/var/spool/cwl"
36 kwargs["docker_outdir"] = "/var/spool/cwl"
37 elif self.work_api == "jobs":
38 kwargs["outdir"] = "$(task.outdir)"
39 kwargs["docker_outdir"] = "$(task.outdir)"
40 kwargs["tmpdir"] = "$(task.tmpdir)"
41 kwargs["docker_tmpdir"] = "$(task.tmpdir)"
42 return super(ArvadosCommandTool, self).job(joborder, output_callback, **kwargs)