Introduction
Workspace can be used to parallelise (and distribute) aspects of a workflow. In this tutorial we will run multiple nested workspaces asynchronously (i.e. in parallel). Our nested Workspace will simulate a lengthy operation via the Pause operation. We will then mark this workflow as running asynchrously, copying it and then set up our workflow to run both copies simultaneously. Once both parallel workflows have completed we will write some text to indicate completion to the workspace log window.
Contents
Configuring a workspace for parallel execution
- Open the workspace editor.
- In the operation catalogue, locate the LogText operation and drag this onto your workflow.
- In the operation catalogue, locate the Pause operation and drag this onto your workflow.
- Connect the LogText operation's dependency output to the Pause operation's dependency input.
Connecting LogText to Pause
.
- Right click the Pause operation's Dependencies output and choose the "Create workspace output" menu item.
Pause output
.
- In the operation catalogue, locate the WorkspaceInput operation and drag this onto your workflow.
- Connect the WorkspaceInput's output labelled "Input" to the LogText's "Text to log" input.
Connecting WorkspaceInput to LogText
.
- Select all the operations, right click and choose the "Nested workspace from selection" menu item.
Nested workspace
.
- Select the nested workspace, right click and select the "Properties..." menu item.
- Set the Update behaviour to Atomic.
Nested workspace properties
.
- Remove the WorkspaceInput and the WorkspaceOutput operation from your workflow.
- In the operation catalogue, locate the RunOperationsInParallel operation and drag onto your workflow.
- Select your nested workspace, and copy it (CTRL + C) and then paste it (CTRL + V) into your main workflow, connect both nested workspace's dependency output to RunOperationsInParallel's "Parallel operations" input.
Nested workspace copy connected to the RunOperationsInParallel operation
.
- In the operation catalogue, locate the LogText operation and drag this onto your workflow.
- Set the LogText's "Text to Log" input to the string "Tasks complete!" (excluding quotes).
- Connect the Dependencies output of RunOperationsInParallel to the LogText's Dependencies input.
- Create a workspace output for LogText's output.
Our final workspace
.
- Select your first nested workspace and set the input labelled "Input" value to 1.
- Select your second nested workspace and set the input labelled "Input" value to 2.
- Run the workspace.
- You should see both nested workspaces execute simultaneously and once both are complete (and ONLY when both are complete) the text "Tasks complete!" is logged to the workspace log window.
Workflow output
- Try experimenting with different values for Pause in each of your nested workspaces and re-run. You can force a clean re-run of your workflow by selecting all the operations in your main workflow (CTRL + A), right clicking and choose the "Reset selected operation(s)" menu.
- Try also tagging a nested workflow with a feature as per the Directing the execution of parallel loops to specific machines tutorial. In doing so you can force your nested workflows to execute not only in parallel but also to run on specific remote machines and / or clusters.
Summary
This concludes the tutorial on running multiple workflow asynchronously.