Skip to content

Job Options

Introduction

Job options can be specified in the joboptions.json file in the input directory of the playpen. However, this file is not required to run a process. When you run a process, an override JSON file can be specified, using the --options flag, which overrides any matching option in the joboptions.json file and adds non-matching options. The resulting job options will be put in the output directory as reference for auditing purposes.

There are two parts to the job options specifications:

  1. system options
  2. process options

System Options

These are options the VOR Stream system knows how to use. The structure of these options is fixed. The following is an example JSON for the system options:

{
   "system": {
      "machines": {
         "localhost": "box.corp.com,",
         "othermachine": "1.1.1.1.1,"
      },
      "nodes": {
         "nodename@localhost": 1,
         "node2": 5,
         "node6@othermachine": 30
      },
      "lookthroughpath":"",
      "output": {
         "usedate": true
      },
      "scenario":"dfast",
      "debug": {
         "trace": true,
         "sniff": {
            "nobs": 10,
            "queues": [
               "queue1,",
               "queue2,",
               "queuen,"
            ]
         }
      }
   }
}

Process Options

User-provided process options are options ignored by VOR Stream and passed to computational nodes for user-written code to consume. These options are user-specified and can contain a category and a sub-category, followed by name value pairs. The following is an example of a process options JSON:

{
   "processoptions": {
      "category1": {
         "subcat1": {
            "name": "value,",
            "name2": "value2"
         },
         "subcatbar": {
            "name": "value,",
            "name2": [
               1,
               2,
               "3.14,"
            ]
         }
      },
      "categorymine": {
         "subcat1": {
            "name": "value,",
            "name2": "value2"
         },
         "subcatbar": {
            "name": "value,",
            "name2": "value2"
         }
      }
   }
}

The processoptions tag is the only required tag.

Using Process Options in a Computational Node

The process options are available at run time in the user structure of the computational node. The structure entry is called options and has the type:

map[string]map[string]map[string]interface{} 

To access the value of a specific option:

value := u.options["<category>"]["<sub-category>"]["<name>"].(type) 

To access the floating-point value "defaultProbability" from "products" category and the "mortgage" sub-category use:

default := u.options["products"]["mortgage"]["defaultProbability"].(float64) 

To avoid missing or misspecified options, check the existence of the options before accessing. A good coding practice would be to expand the user structure and initialize it in the initialization block. For example, add a mortgage entry to the user structure:

mort map[string]interface{} 

Then add the following code to the initialization function:

   if products, found := u.options["products"]; found {
      if mort, found2 := products["mortgage"]; found2 {
         u.mort = mort
      } else { 
       // set some defaults or error
      }
   } else {
       // Set defaults or error
   }

In this way, the mortgage option is validated once and can be accessed more directly and safely in the worker function using the u.mort variable.