Demonstrate the usage of the $import directive in the user guide ?
EricBoix opened this issue · comments
This is issue was moved to the the cwltool repository where is belongs...
Section 2.4 (Document preprocessing) (of the Common Workflow Language Command Line Tool Description v1.1) mentions the possible usage of the $import
directive. One can find some rare examples of usage of this $import
directive that don't seem that straightforward to transpose (at least for me and when using cwl-runner
version 1.0.20190831161204).
For example suppose we realized the following break down of the first example of the user guide as the following two workflows
to-be-imported.cwl
inputs:
message:
type: string
inputBinding:
position: 1
outputs: []
and
main.cwl
#!/usr/bin/env cwl-runner
cwlVersion: v1.1
class: CommandLineTool
baseCommand: echo
$import: to-be-imported.cwl
while keeping the echo-job.yml
argument file provided in the user guide. And further assume that you try to run this broken down first example with the following bash commands
virtualenv -p python3 venv
source venv/bin/activate
pip install cwlref-runner
cwl-runner main.cwl echo-job.yml
then you might probably get the following error message
ERROR Tool definition failed initialization:
main.cwl:6:1: '$import' must be the only field in ordereddict([('cwlVersion', 'v1.1'), ('class', 'CommandLineTool'), ('baseCommand', 'echo'), ('$import', 'to-be-imported.cwl'), ('id', 'file:///Users/eboix/SAVED/Divers/Ruses/CWL_examples/main.cwl')])
Wouldn't it be worth documenting the usage of the $import directive in the user guide ?
Notes:
- trying to use the line
in place of the line
{$import: to-be-imported.cwl}
as suggested by the "Workflow steps and wiring" section of this issue doesn't seem to help.$import: to-be-imported.cwl
- trying the following syntax
as suggested by this issue also fails but with the following different error message
"@import": to-be-imported.cwl
main.cwl:3:1: "outputs" section is not valid.
From my reading of https://www.commonwl.org/v1.1/SchemaSalad.html#Import
I see that
cwlVersion: v1.1
class: CommandLineTool
baseCommand: echo
$import: to-be-imported.cwl
is not valid.
From my reading it should be expressed as
cwlVersion: v1.1
class: CommandLineTool
baseCommand: echo
inputs:
$import: inputs.cwl
outputs: []
where inputs.cwl
is
message:
type: string
inputBinding:
position: 1
Ok, I can't get that to work with cwltool --validate
so my understanding is incomplete.
I tried with your trick of @include
and get
main.cwl:4:11: checking object `main.cwl#@include`
main.cwl:4:11: Field `type` references unknown identifier `inputs.cwl`, tried file:///Users/kghose/Downloads/main.cwl#inputs.cwl
Thanks @kaushik-work . Indeed the version that you propose, that is
cwlVersion: v1.1
class: CommandLineTool
baseCommand: echo
inputs:
$import: inputs.cwl
outputs: []
also fails to validate for me (thanks for letting me know about that --validate
options) with the message mapping values are not allowed here
.
I also tried (I'm pretty despaired on this matter :-) to add a first inputs:
line to inputs.cwl (and also fooled around with various indentation levels) but without success...
This is issue was moved to the the cwltool repository where is belongs...