JobLoader

JobLoader

JobLoader is a helper class for loading a Job to be run from the command line. The JobRunner class takes a single parameter, which is a Job object. That Job object may be specified on the command line in any of the following ways:

  • In opts.job as a Job UUID
  • In opts.job as a path to a JSON file containing a Job object
  • In opts.job as a path to a JSON file containing a JobParams object.
  • As raw JSON passed through STDIN representing a Job object
  • As raw JSON passed through STDIN representing a JobParams object

The JobLoader will figure out what was specified, and will return the appropriate Job object.

Note that valid Job objects are complete and ready to run, while JobParams objects refer to a Workflow and specify which files should be passed through that Workflow and what tag values or metadata values should be applied. The JobLoader will convert JobParams objects to full-fledged Job objects.

Although both params listed below are optional, you must specify at least one of the two. If you specify both, json takes precedence over opts.job.

Constructor

new JobLoader(opts, jsonopt)

Parameters:
Name Type Attributes Description
opts object

An object, typically the command line options.

Properties
Name Type Attributes Description
job string <optional>

The path to a file containing the Job in JSON format, or a job UUID. If this is a UUID, the loader will load the job from the database. If it's any other string, the loader will attempt to load it from a JSON file.

json string | Buffer <optional>

A string or buffer containing JSON data. Typically, this is read from STDIN when DART is run from the command line.

Source:

Methods

loadJob() → {Job}

Loads a job. If json is not empty, this tries to parse the data as Job JSON or as JobParams JSON. Otherwise if opts.job is a UUID, it tries to load the job with that UUID from the Jobs database. If opts.job is any string other than a UUID, this tries to read the file at the path specified by opts.job and parse it as Job JSON.

This will throw an error if it encounters unparsable JSON, is asked to read a non-existent or unopenable file, or cannot find a Job with the specified UUID.

Source:

looksLikeJob(data) → {boolean}

Returns true if the generic JavaScript object in param data looks like it may be a Job object.

Parameters:
Name Type Description
data object

Any generic JavaScript object.

Source:

looksLikeJobParams(data) → {boolean}

Returns true if the generic JavaScript object in param data looks like it may be a JobParams object.

Parameters:
Name Type Description
data object

Any generic JavaScript object.

Source: