2.11. Operations#

An Operation is a type of CWL process, just like a workflow, a command-line tool, or an expression tool. It is a step of a workflow that specifies inputs and outputs, but it does not provide enough information to be executed.

You can create operations to visualize a workflow during development, before you are ready to submit the workflow to a CWL runner:

operations.cwl#
cwlVersion: v1.2
class: Workflow


inputs:
  message: string
outputs: []

steps:
  echo:
    run: ../echo.cwl
    in:
      message: message
    out: [out]
  # Here you know you want an operation that changes the case of
  # the previous step, but you do not have an implementation yet.
  uppercase:
    run:
      class: Operation
      inputs:
        message: string
      outputs:
        uppercase_message: string
    in:
      message:
        source: echo/out
    out: [uppercase_message]

The uppercase step of the workflow is an operation. It can appear where a command line tool or an expression is expected. You can also plot it with the CWL Viewer or cwltool:

$ cwltool --print-dot operations.cwl
INFO /opt/hostedtoolcache/Python/3.9.19/x64/bin/cwltool 3.1.20240508115724
INFO Resolved 'operations.cwl' to 'file:///home/runner/work/user_guide/user_guide/src/_includes/cwl/operations/operations.cwl'
digraph G {
bgcolor="#eeeeee";
clusterrank=local;
labeljust=right;
labelloc=bottom;
"echo" [fillcolor=lightgoldenrodyellow, label=echo, shape=record, style=filled];
"uppercase" [fillcolor=lightgoldenrodyellow, label=uppercase, shape=record, style=dashed];
"echo" -> "uppercase";
subgraph cluster_inputs {
label="Workflow Inputs";
rank=same;
style=dashed;
"message" [fillcolor="#94DDF4", label=message, shape=record, style=filled];
}

"message" -> "echo";
subgraph cluster_outputs {
label="Workflow Outputs";
labelloc=b;
rank=same;
style=dashed;
}

}

The output of the command above can be rendered cwltool --print-dot operations.cwl | dot -Tsvg > operations.svg ; open operations.svg.

digraph G { bgcolor="#eeeeee"; clusterrank=local; labeljust=right; labelloc=bottom; "echo" [fillcolor=lightgoldenrodyellow, label=echo, shape=record, style=filled]; "uppercase" [fillcolor=lightgoldenrodyellow, label=uppercase, shape=record, style=dashed]; "echo" -> "uppercase"; subgraph cluster_inputs { label="Workflow Inputs"; rank=same; style=dashed; "message" [fillcolor="#94DDF4", label=message, shape=record, style=filled]; } "message" -> "echo"; subgraph cluster_outputs { label="Workflow Outputs"; labelloc=b; rank=same; style=dashed; } }

The operation file will fail to run with cwltool because cwltool lacks the necessary information to execute it:

cwltool does not know how to run operations#
$ cwltool operations.cwl --message Hello
INFO /opt/hostedtoolcache/Python/3.9.19/x64/bin/cwltool 3.1.20240508115724
INFO Resolved 'operations.cwl' to 'file:///home/runner/work/user_guide/user_guide/src/_includes/cwl/operations/operations.cwl'
ERROR Workflow error, try again with --debug for more information:
operations.cwl:19:7: Workflow has unrunnable abstract Operation

Note

CWL runners may come up with ways to bind operations to concrete steps. A CWL runner could, for instance, use abstract operations with ID’s that correspond to steps executed by a different workflow engine.