Hands-On Exercise 5: using parameters

In this exercise we will study the usage of parameters in the workflow.

Prerequisites

Install the Hands-On

  • Install the Hands-On Exercise 5, just type:
cd
cd dcs-hands-on
mvn clean install -D hands.on=5 -P bash

Inspect the application.xml

  • Checking the updated application.xml, you will see now the parameter expression:
<?xml version="1.0" encoding="us-ascii"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" id="beam_arithm">
  <jobTemplates>
    <jobTemplate id="expression">
      <streamingExecutable>/application/expression/run</streamingExecutable>
      <defaultParameters>
        <parameter id="expression">l1_flags.INVALID?0:radiance_13>15?0:100+radiance_9-(radiance_8+(radiance_10-radiance_8)*27.524/72.570)</parameter>
      </defaultParameters>
    </jobTemplate>
  </jobTemplates>
    <workflow id="hands-on-5" title="Using parameters" abstract="Exercise 5, using parameters">
    <workflowVersion>1.0</workflowVersion>
    <node id="node_expression">
      <job id="expression"/>
      <sources>
        <source refid="file:urls">/application/inputs/list</source>
      </sources>
    </node>
  </workflow>
</application>

Inspect the run executable

  • Open the file expression/run and search for the lines containing the function ciop-getparam:
    # retrieve the parameters value from workflow or job default value
    expression="`ciop-getparam expression`"

    # run a check on the expression value, it can't be empty

Run and debug the workflow

  • Run the node node_expression:
ciop-run node_expression
Attempts output

Recap

  1. We added a parameter in the job template of a processing node, defined in the application workflow;
  2. We used the value of that parameter in our run executable.