Using `Directory` as an output type

I’m creating a pipeline and one of my tools (let’s call it Tool 2) accepts Directory as an input, like so:

    "inputs": [
        {
            "id": "analysis_inputs_id",
            "type": "Directory",
            "inputBinding": {
                "position": 11,
                "shellQuote": true
            }
        }
    ],

My preceding tool (Tool 1) performs some analysis and outputs several files into /tmp/

My question is how do I write the Tool 1’s CWL specification so that it outputs the directory /tmp/ into the input of Tool 2?

So far I’ve tried this for Tool 1:

    "outputs": [
        {
            "id": "outdir",
            "type": "Directory",
            "outputBinding": {
                "path": "/tmp"
            }
        }
    ]

and it fails like so:

Job error:
Error validating output record. the `outdir` field is not valid because
  is not a dict
 in {
    "outdir": null
}

Is there a commonly used way to specify directory outputs in CWL? The documentation seems scant about it.

Welcome @ash

Paths are not maintained between invocations of tools in CWL. This is to support execution on different machines, so we don’t rely upon a shared filesystem.

To output a type: Directory use a glob under outputBinding like you would for a type: File

Any other tool that needs this directory would have their own type: Directory in their inputs section.

You can put the location of this input directory on the command the same way you would with a type: File: via inputBinding or via $(inputs.directory_id.path) in the arguments section.

Ideally your script or program can accept the directory at any path. If a specific directory name is required then check out Staging Input Files – Common Workflow Language User Guide