Exploring the flow definition examples
To help you design and build your own flows, you can refer to the examples installed with Flow Editor. To view the examples, select Importing an example definition.
and selectSample.xml: Simple flow example
View the example: Importing an example definition, Sample.xml in the Create Draft Definition dialog.
and selectDescription
Demonstrates a simple flow with three jobs and dependencies to complete successfully.
Prerequisites
Demonstrates a simple flow with three jobs: Start, Processing, Finish.
- The command for each job is sleep 5.
- Dependency arrows: each job starts after the previous one completes successfully.
- Default values set for everything else.
Functionality used in this example
- Jobs
- Dependencies: Completes successfully
jobs_and_dependencies.xml: flow with branches example
View the example: Importing an example definition, jobs_and_dependencies.xml in the Create Draft Definition dialog.
and selectDescription
Demonstrates a flow with three separate branches that run according to whether the first job in the flow completed successfully or ended with a specific exit code or exit codes.
If you run this flow as is, only Job_Exit_1 and Job_That_Always_Runs are run.
- To run the first branch, Job_Exit_1 has to complete successfully. However, Job_Exit_1 will never complete successfully because its exit code is always 1, so the subsequent job Job_That_Never_Runs will never be triggered.
- To run the second branch, Job_Exit_1 must end with an exit code > 0. Job_Exit_1 always ends with exit code 1, so the subsequent job Job_That_Always_Runs will always be triggered.
- To run the third branch, two conditions must be satisfied: Job_Exit_1 must end with exit code 1, 5, or 127, AND the job submission script must complete successfully.
Functionality used in this example
Dependencies:
- Completes successfully
- Multiple exit code dependency:
- Ends with exit code > 0
- Ends with exit code equal to 1, 5, 127
Non-zero success exit codes in job Job_with_success_code
Using a variable for the queue name. The variable FIRSTQUEUE=normal is specified in the Flow Attributes as an input variable and used in Job_Exit_1 in the Submit tab to indicate which queue to submit the job to #{FIRSTQUEUE}.
Job script for submitting jobs(SubmissionScript). To satisfy the condition that the script completes successfully, you need to create a job submission script file, copy it to the location specified in the SubmissionScript Job Script Definition. Check that the mysubmit script can run successfully by running it from the command-line outside of Process Manager.
- UNIX/Linux: Copy this sample script to /tmp/ on the Process Manager Server and name the script
mysubmit:
#!/bin/sh #any logic bsub -J $JS_JOB_NAME -q normal -o /tmp/myout echo my output
- Windows: Copy this sample script to c:\tmp on the Process manager Server and name the script
mysubmit:
bsub -J %JS_JOB_NAME% -q normal -o c:\tmp\myout echo my output
event_and_alarm.xml: automatically trigger a flow or alarm example
View the example: Importing an example definition, event_and_alarm.xml in the Create Draft Definition dialog.
and selectDescription
Demonstrates how to use time of day and arrival of a file in a specific directory to trigger a subflow. Also uses an alarm to send an email to the administrator.
This flow has a subflow that can only be triggered between 10-11 am on working days AND if myfile arrives in the tmp directory. If both conditions are not satisfied by 11 am, the flow sends an email to alert the administrator.
Prerequisites
- When you commit the flow definition, you also have to enable event triggers in the flow definition or the time event will never be triggered and the flow will never start. To enable event triggers: In the Workloadtab, select , select the flow definition and select . All flow definitions receive the status On Hold by default. No automatic events can trigger in this definition until event triggers have been explicitly released. You can, however, still submit the flow manually for testing purposes.
- For this example to work, there needs to be an alarm installed and enabled. An example alarm file example.alarm is installed in the directory JS_TOP/work/alarm and enabled. You may wish to modify this alarm file with a text editor to indicate a valid email address. Afer making any modifications to the alarm, run the command jreconfigalarm to make changes take effect.
Functionality used in this example
- File event to trigger a flow. When the file arrives in the specified directory on the Process Manager server host, the subflow that follows the event can be triggered.
- Time event to trigger a flow. Trigger the flow_simple flow at 10:00AM. If not triggered by 11:00AM, do not trigger as we missed the window of execution. Send an alarm if not triggered.
- Uses the system calendar Businessdays. This is a pre-built calendar that only includes weekdays. You can create your own calendars with the Calendar Editor. The Calendar Editor is a Java client installed separately.
- Alarm that sends an email to the administrator. The alarm is triggered when execution of the subflow does not start within the time window specified.
- Subflow copied into the main flow.
dynamic_flow.xml, target_flow.xml: inserting flows by reference example
View the example: Importing an example definition, dynamic_flow.xml in the Create Draft Definition dialog. Repeat the steps to also create the flow target_flow.xml.
and selectDescription
This example includes two flows: a main flow(dynamic_flow.xml), and a subflow(target_flow.xml).
Demonstrates how to link a subflow by reference, how to pass input variables from a main flow to a subflow, and how to pass a variable from a subflow to the parent flow and use it in a subsequent job in the main flow.
dynamic_flow.xml contains two linked subflows and passes the variable MYVAR=100 to one subflow, and MYVAR=200 to the other subflow. The last job in each subflow passes the variable result_#{JS_FLOW_SHORT_NAME}=xyz#{MYVAR} to the parent flow. The last job in this flow writes the value passed from the subflow to an output file.
The flow target_flow.xml is referenced as a subflow by the flow dynamic_flow.xml. It has 3 jobs: Start, Processing, Finish. The next job starts when the last one completes successfully. This flow receives the MYVAR input variable from the parent flow and writes it to a file #{JS_FLOW_SHORT_NAME}.%J.output. It then sets a variable based on the flow short name that can be accessed by the parent flow: result_#{JS_FLOW_SHORT_NAME}=xyz#{MYVAR}
Prerequisites
In order for the subflow to be referenced by the main flow, you need to publish the subflow target_flow.xml. You must be the Process Manager administrator to publish the flow.
Publish the flow: in the Workload tab, select , select the flow and select . When you publish a flow, the flow is available to anyone to be used.
Functionality used in this example
- Linked subflows: A linked subflow is a flow inserted by reference in the main flow. You maintain the subflow separately from the main flow. Changes made to the subflow are automatically updated in the main flow.
- Specifying input variables for a subflow from a main flow.
- Use of the command ppmsetvar -p to set a variable from a subflow that is accessible to the parent flow.
- Use of output files.
- Use of built-in variables for naming output files:
- Use the built-in variable #{JS_FLOW_SHORT_NAME} in the subflow to avoid potential naming conflicts when setting flow variables for the parent flow.
- Use %J in the file name for the job ID.
- Use of output files. By default, when no path is specified for the output file, the output file is written to the home directory of the user who submitted the flow.
- Use of built-in variables for naming output files:
- Use the built-in variable #{JS_FLOW_SHORT_NAME} to avoid potential naming conflicts when setting flow variables for the parent flow.
- Use %J in the file name for the job ID.
- Use of the command ppmsetvar -p to set a variable from a subflow that is accessible to the parent flow.
flowarray_eval.xml: evaluate variables and run flows sequentially or in parallel example
View the example: Importing an example definition, flowarray_eval.xml in the Create Draft Definition dialog.
and selectDescription
Demonstrates how to use the variable evaluator to decide which branch of a flow to run, how to run flow arrays in parallel or sequentially, and how to use a variable to set the array size.
This flow contains two subflows to be run as arrays, and a condition evaluator that decides whether to run the arrays in parallel or sequentially.
The Set_variable job sets the variable MYVAR=1 and VAR2=100.
When MYVAR=1 and VAR2 is larger than 40, the array runs in parallel. Otherwise, it runs sequentially.
The subflow is run as many times as the number of array elements. The number of array elements is defined by the variable ARRAYSIZE, set by the job Set_arraysize before the flow array.
To run the flow array sequentially, set MYVAR=0 in the Set_variable job.
Functionality used in this example
- Variable evaluator to determine what action to take based on the value of a specific variable.
- Flow array copied into the main flow(as opposed to a linked flow array in which the subflow would be inserted by reference and managed separately from this flow).
- Defining the number of array elements at runtime, using a variable #{ARRAYSIZE} to specify the last element.
- Built-in variables #{JS_FLOW_FULL_NAME}, #{JS_FLOW_INDEX} used in jobs in the subflow for output files. Use # {JS_FLOW_FULL_NAME} to get the name of the main flow, including the subflow name. Use #{JS_FLOW_INDEX} to get the number of the current array.- Input variables in the subflow specified in the Flow Attributes of each subflow.
- Use of the command ppmsetvar -f to set a variable that can be used by all work items in a flow.