Purpose
Some jobs share a need for the same set of task sequences. For this situation, you can create a separate workflow containing a single instance of those tasks and call them from other jobs.
The childJob task starts a job inside the running job. The calling or parent job waits for the child to finish (complete or cancel) before progressing to its next task. If the child job is cancelled, the childJob task will error and progress to the next task along its error transition. Anything that is a job variable in the child job is placed in an object with the <job_variable__name> : <job_variable_value>
key/value pair format and is returned as the outgoing data from the child job task to the parent. Then if you want a particular job variable, you use a query task to query out that key (job variable name) and now you have your value.
Multiple iterations of the same child job can be run using one childJob task sequentially or in parallel. If run sequentially, each child job iteration is run after the previous child job iteration is finished. When run in parallel, all iterations are started at once, and the childJob task finishes after the final child job finishes. Each element of the input Loop Array specifies the job variables passed into the corresponding child job iteration. The transformation input is run on each element of the Loop Array to produce the job variables for each child job if the Loop Array does not match the input schema of the child job. The childJob task results in an error if all the child jobs are cancelled, but otherwise results in status complete. The final job variables and status of each child job iteration is returned in the task output under the loop
property.
Properties
Property | Description |
---|---|
Actor | Set to Job to run the child job as the same user that started the parent.Set to Pronghorn for the child job to be run as the global Pronghorn user. |
Workflow | Required. Select a child workflow in the Workflow dropdown. |
Job Variables | When the child job requires job variables, those variables will be listed in the Job Variables section. The name of each job variable will be listed with Location and Value fields. Specify where to find values for each child's job variables in the Location dropdown. Values can come from a job variable, a static value, or an earlier task's outgoing variable. If the Location is a job variable or earlier task, the Value shows a dropdown of available variable names for selection. If the Location is static, the Value variable becomes a text edit box. |
Loop Type | Specifies the type of loop. If the loop type is None , only one child job is started. Parallel starts multiple child jobs in parallel, and Sequential starts them sequentially. |
Loop Array | Array of job variables to pass into each child job iteration. Each element of the array must be type object and either match the child's input schema or be transformed to match it for the child jobs to be started successfully. |
Transformation (JST) | Transformation (JST) to run on each element of Loop Array. The result of each transformation run is passed into the corresponding child job as job variables and should match the child's input schema. |
Without Loop Example
In the following example, the child workflow named child
requires three (3) variables to start: ping
, time
, and pong
. The Loop Type is set to None
in the loop settings menu, so only one child job starts.
Task Details for Without Loop
Pictured below are task details for the child job.
Job Variables for Without Loop
Pictured below are the required job variables.
Loop Settings for Without Loop
Pictured below is the Loop Type
option that was selected.
Without Loop Results
The following result occurs after the child job finishes with status complete. All created job variables are included in the result.
With Loop Example
In the following example, the child workflow named child
is run with the Loop Type set to Parallel
. The number of child jobs started is the length of the Loop Array at runtime of the job. The job variables passed into each child job is the result of running numberTransformation
on each element of the Loop Array.
Task Details for With Loop
Pictured below are task details for the child job.
Loop Settings for With Loop
Pictured below are the required Loop Settings
.
Results for With Loop
The following result includes the loop
property, which contains the resulting job variables and status of each child job iteration.
Example Error Outputs
If all the child jobs of a loop are cancelled, the childJob
will be in an error state. This is done to maintain the precedent that human intervention is required to progress the workflow. On the other hand, if at least one job completes successfully, the childJob
will end in a completed state.
All Child Jobs Cancelled
Picture below is the error that returns when all child jobs are cancelled.
One Cancelled Job
Pictured below is the outgoing job_details
variable that returns for one cancelled job.