How to return an output file¶
Questions¶
Where does the output of a command go?
How can I save the output of a command?
Objectives¶
- Learn how to describe and handle outputs from a tool.
Explanation¶
The outputs
of a tool is a list of output parameters that should be returned after running the tool. Each parameter has an id
for the name of parameter, and type
describing what types of values are valid for that parameter.
When a tool runs under CWL, the starting working directory is the designated output directory. The underlying tool or script must record its results in the form of files created in the output directory. The output parameters returned by the CWL tool are either the output files themselves, or come from examining the content of those files.
The following example demonstrates how to return a file generated by rasterio's rio
command-line tool.
-rw-r--r-- 1 runner docker 1068 Dec 11 09:03 ../cwl/01-output/return-output-file.cwl
INFO /opt/hostedtoolcache/Python/3.12.7/x64/bin/cwltool 3.1.20241112140730
INFO Resolved '../cwl/01-output/return-output-file.cwl' to 'file:///home/runner/work/how-to/how-to/cwl/01-output/return-output-file.cwl'
INFO [workflow ] start
INFO [workflow ] starting step step-convert
INFO [step step-convert] start
INFO [job step-convert] /tmp/1pvw2wrv$ docker \
run \
-i \
--mount=type=bind,source=/tmp/1pvw2wrv,target=/ClHURi \
--mount=type=bind,source=/tmp/_8_jk23l,target=/tmp \
--workdir=/ClHURi \
--read-only=true \
--user=1001:127 \
--rm \
--cidfile=/tmp/oisom_7b/20241211090836-565319.cid \
--env=TMPDIR=/tmp \
--env=HOME=/ClHURi \
ghcr.io/eoap/how-to/how-to-container:1.1.0 \
rio \
convert \
--driver \
PNG \
--dtype \
uint8 \
https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/10/T/FK/2021/7/S2B_10TFK_20210713_0_L2A/TCI.tif \
preview.png
WARNING:rasterio._env:CPLE_NotSupported in driver PNG does not support creation option BLOCKXSIZE
WARNING:rasterio._env:CPLE_NotSupported in driver PNG does not support creation option BLOCKYSIZE
WARNING:rasterio._env:CPLE_NotSupported in driver PNG does not support creation option TILED
WARNING:rasterio._env:CPLE_NotSupported in driver PNG does not support creation option COMPRESS
WARNING:rasterio._env:CPLE_NotSupported in driver PNG does not support creation option INTERLEAVE
INFO [job step-convert] Max memory used: 1137MiB
INFO [job step-convert] completed success
INFO [step step-convert] completed success
INFO [workflow ] completed success
INFO Final process status is success
{
"preview": {
"location": "file:///home/runner/work/how-to/how-to/docs/preview.png",
"basename": "preview.png",
"class": "File",
"checksum": "sha1$e1538ef65976d4748dc58393fe8d0b78b4736f38",
"size": 237388032,
"path": "/home/runner/work/how-to/how-to/docs/preview.png"
}
}
preview:
type: File
outputBinding:
glob: preview.png
Workflow Inputs
Input Name | Type |
---|
geotif: type: string
geotif:
type: string