1.1. Quick Start#
This section will show you a brief overview of what is CWL and where you can learn more about it. No previous knowledge of CWL is required, but you must be comfortable following instructions for the command-line.
1.1.1. “Hello World”#
CWL is a way to describe command-line tools and connect them together to create workflows. Because CWL is a specification and not a specific piece of software, tools and workflows described using CWL are portable across a variety of platforms that support the CWL standard.
CWL documents are written in YAML (and/or JSON). The example below shows a simple CWL “Hello World” workflow annotated with comments:
cwlVersion: v1.2
# What type of CWL process we have in this document.
class: CommandLineTool
# This CommandLineTool executes the linux "echo" command-line tool.
baseCommand: echo
# The inputs for this process.
inputs:
message:
type: string
# A default value that can be overridden, e.g. --message "Hola mundo"
default: "Hello World"
# Bind this message value as an argument to "echo".
inputBinding:
position: 1
outputs: []
The example above is just a wrapper for the echo
command-line tool.
Running the workflow above with the default input values, produces the
command-line echo "Hello World"
.
Note
There is a distinction in CWL between a command-line tool and a workflow. But for the sake of simplicity we are using the term “workflow” here. You will learn more about this in the basic concepts section.
1.1.2. Installing a CWL runner#
cwltool
is an implementation of the CWL specification. It is also the
CWL Reference Runner for the specification, and compliant with the
latest version of the specification, v1.2
. You can install
cwltool
using pip
:
$ pip install cwltool
Note
The prerequisites section contains a more detailed list
of software and libraries used for following the rest of this user guide.
It also contains other ways to install cwltool
.
1.1.3. Running “Hello World”#
The usage of the cwltool
command-line executable is basically
cwltool [OPTIONS] <CWL_DOCUMENT> [INPUTS_OBJECT]
. You can run the
hello_world.cwl
workflow without specifying any option:
$ cwltool hello_world.cwl
INFO /opt/hostedtoolcache/Python/3.9.13/x64/bin/cwltool 3.1.20220913185150
INFO Resolved 'hello_world.cwl' to 'file:///home/runner/work/user_guide/user_guide/src/_includes/cwl/hello_world.cwl'
INFO [job hello_world.cwl] /tmp/ww5lev2b$ echo \
'Hello World'
Hello World
INFO [job hello_world.cwl] completed success
{}
INFO Final process status is success
Or you can override the default value of the input parameter message
, similar
to how you would change the argument of the echo
base command:
$ cwltool hello_world.cwl --message="Hola mundo"
INFO /opt/hostedtoolcache/Python/3.9.13/x64/bin/cwltool 3.1.20220913185150
INFO Resolved 'hello_world.cwl' to 'file:///home/runner/work/user_guide/user_guide/src/_includes/cwl/hello_world.cwl'
INFO [job hello_world.cwl] /tmp/vd5dfj9l$ echo \
'Hola mundo'
Hola mundo
INFO [job hello_world.cwl] completed success
{}
INFO Final process status is success
Another way of passing values to your workflow input parameters is via an Inputs Object. This is a file containing the input fields with the corresponding values. This file can be written in JSON or YAML. For example:
{
"message": "こんにちは世界"
}
You can use this Inputs Object file now to execute the “Hello World” workflow:
$ cwltool hello_world.cwl hello_world-job.json
INFO /opt/hostedtoolcache/Python/3.9.13/x64/bin/cwltool 3.1.20220913185150
INFO Resolved 'hello_world.cwl' to 'file:///home/runner/work/user_guide/user_guide/src/_includes/cwl/hello_world.cwl'
INFO [job hello_world.cwl] /tmp/g85w9jbz$ echo \
こんにちは世界
こんにちは世界
INFO [job hello_world.cwl] completed success
{}
INFO Final process status is success
Note
We used a similar file name for the workflow and for the inputs object files. The -job.json suffix is very common in Inputs Object files, but it is not a requirement. You can choose any name for your workflows and inputs object files.
1.1.4. Learn more#
Continue reading the next sections of this User Guide!
List of CWL Implementations: https://www.commonwl.org/implementations/
The
common-workflow-language
organization at GitHub: https://github.com/common-workflow-languageCommon Workflow Language at Wikipedia: https://en.wikipedia.org/wiki/Common_Workflow_Language
YAML.org: http://yaml.org/ and YAML at Wikipedia: https://en.wikipedia.org/wiki/YAML
The CWL
v1.2
Specification: https://www.commonwl.org/v1.2/Workflow management system at Wikipedia: https://en.wikipedia.org/wiki/Workflow_management_system