Use float as input, "massage" to a string

I’d like my Workflow to take a float as an input (defining a scalar resolution) and pass a string containing “resolution $myresolution” as an input to a step. I tried something like this:

#!/usr/bin/env cwl-runner

cwlVersion: v1.0
class: Workflow
inputs:
  resolution: float

requirements:
  - class: StepInputExpressionRequirement
  - class: InlineJavascriptRequirement

steps:
  generate_resolution_cutter:
    run: create_file.cwl
    in:
      keywords:
        valueFrom: $("resolution "+resolution)
    out: [output_file]

But got the following error:

ERROR [step generate_resolution_cutter] Cannot make job: Expression evaluation error:
Expecting value: line 1 column 1 (char 0)
script was:
01 "use strict";
02 var inputs = {
03     "keywords": null
04 };
05 var self = null;
06 var runtime = {
07     "tmpdir": null,
08     "outdir": null
09 };
10 (function(){return (("resolution "+resolution));})()
stdout was: ''
stderr was: 'evalmachine.<anonymous>:10
(function(){return (("resolution "+resolution));})()

Is it not possible for me to access the workflow inputs from a step input?

You need to connect resolution to the step, and use inputs.resolution:

    in:
      resolution: resolution
      keywords:
        valueFrom: $("resolution "+inputs.resolution)
1 Like

Or more concisely, obviating the need for InlineJavascriptRequirement

    in:
      resolution: resolution
      keywords:
        valueFrom: resolution $(inputs.resolution)