Create cwl workflows by writing a simple Python script
Python Common Workflow Language
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.



codacy_grade codacy_coverage travis documentation pypi_version pypi_supported DOI

scriptcwl is a Python package for creating workflows in Common Workflow Language (CWL). If you give it a number of CWL CommandLineTools, you can create a workflow by writing a Python script. This can be done interactively using Jupyter Notebooks. The full documentation can be found on Read the Docs.

add multiply example workflow

Given CWL CommandLineTools for add and multiply (these are available in scriptcwl), a CWL specification of this workflow can be written as:

from scriptcwl import WorkflowGenerator

with WorkflowGenerator() as wf:

  num1 = wf.add_input(num1='int')
  num2 = wf.add_input(num2='int')

  answer1 = wf.add(x=num1, y=num2)
  answer2 = wf.multiply(x=answer1, y=num2)


The workflow has two integers as inputs (num1 and num2), and first adds these two numbers (wf.add(x=num1, y=num2)), and then multiplies the answer with the second input (num2). The result of that processing step is the output of the workflow. Finally, the workflow is saved to a file. The result looks like:

#!/usr/bin/env cwl-runner
cwlVersion: v1.0
class: Workflow
  num1: int
  num2: int
    type: int
    outputSource: multiply/answer
    run: add.cwl
      y: num2
      x: num1
    - answer
    run: multiply.cwl
      y: num2
      x: add/answer
    - answer

The Python and CWL files used in the example can be found in the examples folder.


Install using pip:

pip install scriptcwl

For development:

git clone
cd scriptcwl
git checkout develop
pip install -r requirements.txt
python develop

Run tests (including coverage) with:

python develop test

Useful tools

To use scriptcwl for creating CWL workflows, you need CWL CommandLineTools. There are some software packages that help with generating those for existing command line tools written in Python:

  • argparse2tool: Generate CWL CommandLineTool wrappers (and/or Galaxy tool descriptions) from Python programs that use argparse. Also supports the click argument parser.
  • pypi2cwl: Automatically run argparse2cwl on any package in PyPi.
  • python-cwlgen: Generate CommandLineTool and DockerRequirement programmatically