cwl-inspector provides a handy way to inspect properties of tools or workflows written in Common Workflow Language
- Ruby 2.7 or later
Input: echo.cwl
class: CommandLineTool
cwlVersion: v1.0
id: echo_cwl
baseCommand:
- cowsay
inputs:
- id: input
type: string?
inputBinding:
position: 0
label: Input string
doc: This is an input string
outputs:
output:
type: stdout
stdout: output
requirements:
- class: DockerRequirement
dockerPull: docker/whalesay
$ ./inspector.rb echo.cwl .cwlVersion
--- v1.0
$ ./inspector.rb echo.cwl .requirements.0.class
--- DockerRequirement
You can access an input parameter by using its index (specified by position
field) or its id.
$ ./inspector.rb echo.cwl .inputs.0.label
--- Input string
or
$ ./cwl-inspector.rb echo.cwl .inputs.input.label
--- Input string
$ ./inspector.rb echo.cwl 'keys(.)'
---
- inputs
- outputs
- class
- id
- requirements
- cwlVersion
- baseCommand
- stdout
$ ./inspector.rb echo.cwl commandline
docker run -i --read-only --rm --workdir=/private/var/spool/cwl --env=HOME=/private/var/spool/cwl --env=TMPDIR=/tmp --user=501:20 -v /Users/tom-tan/cwl-inspector/examples/echo:/private/var/spool/cwl -v /tmp:/tmp docker/whalesay cowsay > /Users/tom-tan/cwl-inspector/examples/echo/output
You can also specify the parameter to show the command with instantiated parameters.
$ cat inputs.yml
input: Hello!
$ ./inspector.rb echo.cwl commandline -i inputs.yml
docker run -i --read-only --rm --workdir=/private/var/spool/cwl --env=HOME=/private/var/spool/cwl --env=TMPDIR=/tmp --user=501:20 -v /Users/tom-tan/cwl-inspector/examples/echo:/private/var/spool/cwl -v /tmp:/tmp docker/whalesay cowsay 'Hello!' > /Users/tom-tan/cwl-inspector/examples/echo/output
You can use ghcr.io/tom-tan/cwl-inspector
image.
This image is built by Github Actions.
$ cat echo.cwl | docker run --rm -i ghcr.io/tom-tan/cwl-inspector:v0.1.1 - .cwlVersion
--- v1.0
$ cwltool --make-template echo.cwl > echo.yml
$ cat echo.yml
input: a_string # type "string" (optional)
$ cat echo.cwl | docker run --rm -i -v $PWD/echo.yml:/workdir/echo.yml --workdir=/workdir ghcr.io/tom-tan/cwl-inspector:v0.1.1 -i echo.yml - commandline
env HOME='/workdir' TMPDIR='/tmp' /bin/sh -c 'cd ~ && "cowsay" "a_string"' > /workdir/output
This software is released under the MIT License.
The following file in examples
is copied from common-workflow-language/common-workflow-language and is released under Apache 2.0 License.
examples/expression.cwl
(Source in common-workflow-language/common-workflow-language)