def test_commandtool(self): c = cwlgen.CommandLineTool("reqs") docker = cwlgen.DockerRequirement(docker_pull="ubuntu:latest") c.requirements.append(docker) d = c.get_dict() self.assertIn("requirements", d) self.assertIn(docker.get_class(), d["requirements"])
def setUp(self): self.dock_req = cwlgen.DockerRequirement( docker_pull='pull', docker_load='load', docker_file='file', docker_import='import', docker_image_id='id', docker_output_dir='dir' )
def createGenericStep(id, docker_image, base_command, type, doc, input_doc, extension, output_doc): cwl_tool = cwlgen.CommandLineTool(tool_id=id, base_command=base_command) cwl_tool_docker = cwlgen.DockerRequirement(docker_pull=docker_image) implementation_file_binding = cwlgen.CommandLineBinding(position=1) cases_file_binding = cwlgen.CommandLineBinding(position=2) return createStep(cwl_tool, cwl_tool_docker, implementation_file_binding, cases_file_binding, type, doc, input_doc, extension, output_doc, base_command)
def createKNIMEStep(id, type, doc, input_doc, extension, output_doc): cwl_tool = cwlgen.CommandLineTool( tool_id=id, base_command='/home/kclhi/knime_4.1.1/knime') cwl_tool_docker = cwlgen.DockerRequirement( docker_pull="kclhi/knime:amia", docker_output_dir="/home/kclhi/.eclipse") cwl_tool.arguments = [ '-data', '/home/kclhi/.eclipse', '-reset', '-nosplash', '-nosave', '-application', 'org.knime.product.KNIME_BATCH_APPLICATION' ] implementation_file_binding = cwlgen.CommandLineBinding( prefix="-workflowFile=", separate=False) cases_file_binding = cwlgen.CommandLineBinding( prefix="-workflow.variable=dm_potential_cases,file://", separate=False, value_from=" $(inputs.potentialCases.path),String") return createStep(cwl_tool, cwl_tool_docker, implementation_file_binding, cases_file_binding, type, doc, input_doc, extension, output_doc, "knime")
def test_missing_export(self): dr = cwlgen.DockerRequirement() self.assertDictEqual(dr.get_dict(), {})
def translate_tool_internal(cls, tool, with_docker=True, with_resource_overrides=False): metadata = tool.metadata if tool.metadata else ToolMetadata() stdouts = [ o.output_type for o in tool.outputs() if isinstance(o.output_type, Stdout) and o.output_type.stdoutname ] stdout = stdouts[0].stdoutname if len(stdouts) > 0 else None if isinstance(stdout, InputSelector): stdout = translate_input_selector(stdout, code_environment=False) tool_cwl = cwlgen.CommandLineTool( tool_id=tool.id(), base_command=tool.base_command(), label=tool.id(), doc=metadata.documentation, cwl_version=CWL_VERSION, stdin=None, stderr=None, stdout=stdout, ) # if any(not i.shell_quote for i in tool.inputs()): tool_cwl.requirements.append(cwlgen.ShellCommandRequirement()) tool_cwl.requirements.extend([cwlgen.InlineJavascriptReq()]) inputs_that_require_localisation = [ ti for ti in tool.inputs() if ti.localise_file and (issubclass(type(ti.input_type), File) or ( issubclass(type(ti.input_type), Array) ) and issubclass(type(ti.input_type.subtype()), File)) ] if inputs_that_require_localisation: tool_cwl.requirements.append( cwlgen.InitialWorkDirRequirement([ "$(inputs.%s)" % ti.id() for ti in inputs_that_require_localisation ])) if with_docker: tool_cwl.requirements.append( cwlgen.DockerRequirement( docker_pull=tool.container(), # docker_load=None, # docker_file=None, # docker_import=None, # docker_image_id=None, # docker_output_dir=None )) tool_cwl.inputs.extend(translate_tool_input(i) for i in tool.inputs()) tool_cwl.outputs.extend( translate_tool_output(o, tool=tool.id()) for o in tool.outputs()) args = tool.arguments() if args: tool_cwl.arguments.extend( translate_tool_argument(a) for a in tool.arguments()) if with_resource_overrides: # work out whether (the tool of) s is a workflow or tool tool_cwl.inputs.extend([ cwlgen.CommandInputParameter("runtime_memory", param_type="float?"), cwlgen.CommandInputParameter("runtime_cpu", param_type="int?"), # cwlgen.CommandInputParameter("runtime_disks", param_type="string?"), ]) tool_cwl.requirements.append( cwlgen.ResourceRequirement( cores_min="$(inputs.runtime_cpu ? inputs.runtime_cpu : 1)", ram_min= "$(inputs.runtime_memory ? Math.floor(1024 * inputs.runtime_memory) : 4096)", )) return tool_cwl