common-workflow-lab / python-cwlgen

Generation of CWL programmatically. Available types: CommandLineTool and DockerRequirement
https://github.com/common-workflow-language/cwl-utils
MIT License
29 stars 13 forks source link

Unable to use in: and out: arguments from workflowstep method #34

Closed achintamiri closed 4 years ago

illusional commented 4 years ago

Hey @achintamiri, often it makes it easier to debug if you provide sample code.

Nevertheless, you’re right there’s no in and out variables on the workflow object, partly because in is a reserved keyword in python.

You can however set the inputs after initialisation with workflow.inputs = []

achintamiri commented 4 years ago

Hi @illusional Below is the code which I am writing to define workflow with multiple steps where output from 1st node should act as input to another node in my cwl file .From CWL perpective this is usuallu defined under steps using arguments in: and out:

` src_file_binding = cwlgen.CommandLineBinding(position=1)

                src_file = cwlgen.workflow.InputParameter("src",
                                                        param_type="File",
                                                        input_binding=src_file_binding,
                                                        doc="Main program of {0}".format(node))

                tool_object.inputs.append(src_file)
                st1 = cwlgen.workflow.WorkflowStep(step_id=node, run=export_path, label='ff', doc='po', scatter='uy', scatter_method='ui')
                tool_object.steps.append(st1)`

This only helps to add workflow input and output parameters but not for defining input and output from each step

and in the output i can see in but it is black in:{}

illusional commented 4 years ago

Thanks for posting code. Similar to the step, workflow step inputs is the property inputs on a WorkflowStep, which is an array of WorkflowStepInputs. You can’t set it on initialisation.

IE st1.inputs.append(cwlgen.WorkflowStepInput(**kwargs)) I’m pretty sure

illusional commented 4 years ago

Hi @achintamiri, thanks for the report. I've inputs, steps, and outputs to the cwlgen.Workflow constructor, so you can now do this:

cwlgen.Workflow(**kwargs, inputs=[cwlgen.InputParameter(**morekwargs)])

This is released in v0.4.1. Feel free to reopen this if it doesn't quite solve your problem.