Hello everyone, I am trying out the cwl_utils
package to parse CWL documents.
Consider the following tool.cwl
:
cwlVersion: v1.0
class: CommandLineTool
baseCommand: echo
inputs:
message:
type: string
inputBinding:
position: 1
outputs: []
I am parsing this using
from cwl_utils.parser import load_document_by_uri
tool = load_document_by_uri('tool.cwl')
I can then get the inputs using tool.inputs
. What I am after is the name of the input parameter. In this example there is just one, i.e., message
, but I cannot find where to get it from. The tool.inputs
property returns a list of CommandInputParameters
instances, but as far as I can tell, there is no attribute/property that returns the name:
In [1]: tool = load_document_by_uri('tool.cwl')
In [2]: tool.inputs
Out[2]: [<cwl_utils.parser.cwl_v1_0.CommandInputParameter at 0x7f3e7bb735d0>]
In [3]: tool.inputs[0].id
Out[3]: 'file:///tool.cwl#message'
The id
returns a URI that contains it at the end after the #
, so I guess I could technically get it through tool.inputs[0].id.split('#')[-1]
but this feels really hacky and fragile. Surely there must be a better way of doing this?