Workflow as a Tool¶
This tutorial is the second in series of three tutorials that provide a general practical introduction to pSeven. It discusses certain features that can be used to customize the workflow interface in Run. Such customization allows to prepare a workflow for users who focus on performing studies and analyzing results and may be not experienced in workflow editing.
This tutorial continues the Simple Workflow tutorial and requires the workflow created there.
- Open the Tutorials project.
- Open SimpleWorkflow (SimpleWorkflow.p7wf).
- Select File ‣ Save Workflow As... to create a copy of the workflow. Save the workflow as SimpleWorkflowTool.
- Verify that you are editing SimpleWorkflowTool and continue with the tutorial.
Taking the toy workflow from the Simple Workflow tutorial as an example, assume it was a first step in the following task:
Create a workflow that generates random experimental designs. The user must be able to set sample dimension, the number of points to generate, and value range. The user may be unfamiliar with workflow editing and block configuration.
The current workflow does not suffice because:
- Matrix dimensions are fixed (in Size). To change sample dimension or the number of points, you have to reconfigure the Size block.
- Similarly, the value range is fixed in RandGen configuration and you have to reconfigure the block to change settings.
This is too much handwork for such a simple task. The solution requires several changes to workflow structure (blocks and links) and configuration (Run settings).
In order to resolve the issues noted above, this tutorial suggests the following improvements:
- Instead of using constants, add a workflow input and link it to RandGen input ports. The user can then specify the number of rows and columns in Run instead of configuring the Size block in Edit.
- To show results in Run immediately, add a workflow output and link it to RandGen.value.
- Add value range settings in RandGen to workflow parameters. Again, the user can change parameters in Run without switching to Edit.
As a result, the workflow will become a simple tool with a custom Run interface which can be used even by a person with no experience in workflow editing.
In fact, every workflow is contained inside a special block. This block has no editable name; in various configuration dialogs it is shown as <root>, and in Edit you can only see its “bounds” labeled [In] and [Out].
Aside from the above aspects, the workflow root is just a Composite block which you can find in the block library. In particular, this root block can have input and output ports (root ports) which serve two purposes:
- Root ports enable using a workflow as a block. This advanced feature is intended for creating complex workflows and custom components, and is discussed in more details in the Workflow as a Block tutorial.
- In Run, root ports are shown as workflow inputs and outputs.
Thus, to make the settings for the sample dimension and the number of points available to the user, you can add root inputs and link them to RandGen. The Size block will no longer be needed.
There are two possible ways:
- Add root ports and create links manually.
- Use the uplink function to add all required ports and links automatically.
Let us compare these two methods using uplinks first.
- Remove the Size block (select it and hit Delete on your keyboard). The link from Size to RandGen is removed automatically.
- Select RandGen and click on the edit toolbar to open the Uplink dialog .
- Select two ports: cols and rows (hold Ctrl or Shift for multiselection). Do not select value yet.
- Click to uplink the selected ports.
- The dialog will show two new workflow inputs that are going to be created. Their names are generated automatically, but you can change them right here if you wish (to edit, double-click the name, or hover it and click ). As a side note, this makes it possible to specify the same name in the Uplinked to column. Such configuration is allowed and will result in adding a one-to-many connection.
- Accept default names and click to apply changes.
The above instructions describe uplinking a specific block, but you can bring up the Uplink dialog without selecting a block first. In this case, it will show all blocks and ports, allowing you to uplink many blocks at once. Since a full list of ports may be very long, the Uplink dialog provides a filter which accepts partial block and port names. You can see that selecting RandGen before opening the Uplink dialog in fact simply filtered the list automatically by the block name: “RandGen/” in the filter means “show all ports of the RandGen block” (the forward slash is used as a block/port name separator).
Uplinking created a new link in the workflow.
The sources of this link are new input ports automatically added to the workflow root block. These ports are shown in Run as workflow inputs. To see them in Edit, double-click any of the workflow boundaries to open the root block configuration.
Switch to the Ports tab and note there are two inputs. Their types and descriptions are copied from uplinked ports. Both of them are editable; such edits do not change properties of uplinked ports (RandGen.cols and RandGen.rows), because they apply to the root block configuration.
To avoid confusion: port names and descriptions in the root block configuration are intended for workflow designers. Workflow inputs and outputs shown in Run have additional descriptions and can be assigned aliases, much like port monitors. It is recommended to use port descriptions in the root block configuration for technical details, such as the location of uplinked port. Then, to customize workflow’s Run interface, you can override “technical” port names and descriptions in workflow configuration (see further for an example).
While on the Ports tab, note that you can add (and remove) ports here. This is the manual method of adding workflow inputs and outputs which was mentioned above. Let us now use it to add a workflow output.
- Click in the Outputs pane.
- Name: value (to automatically match with RandGen.value when linking).
- Description: any text, can be empty or include a developer-style comment. In the final workflow this description will not be shown in Run (see the above note on root port descriptions).
- Type: select RealMatrix by ticking the appropriate box. Note that this is required since the default type is RealScalar which will not accept a matrix generated by RandGen.
- Leave other settings default.
Back in the configuration dialog you can see that the value output is added.
Click to finalize configuration. Note that this time the link from RandGen.value is not created automatically. Now you should manually add this link to send the block output to the workflow output.
After adding the output link, switch to Run to see the effect of the latest changes.
Verify that links and exist, and workflow inputs and output now appear on side panes. Note that the monitor for RandGen.value created earlier is no longer needed: this port is now uplinked to a workflow output, and all workflow inputs and outputs are monitored automatically. You can safely disable this monitor in Run or even remove it in workflow configuration so that it does not distract users.
Finally, you can make the names and descriptions shown in the Inputs and Outputs panes more relevant. To edit them, open workflow configuration and take a look at input and output details on the General tab.
Similar to monitoring, you can set aliases and descriptions which are then shown in Run instead of port details.
- Edit aliases and descriptions as you wish.
- Optional: switch to the Monitoring tab and remove existing monitor.
- Click to apply changes.
Note the changes in the Inputs pane, for example.
Now when you run the workflow, it reads values entered here and sends them from root input ports to RandGen inputs, starting the block.
Let us summarize how the sample size input works, for example:
- RandGen has rows input. This port is required to start and it sets the number of matrix rows.
- To make this setting available to the user, RandGen.rows is uplinked to the root port rows. It makes the Run input appear.
- The root port name is somewhat irrelevant for the end task (sample generation). To explain its role, it is assigned an alias (“Sample Size”) in workflow configuration . Also, the default port description is replaced with a better one.
- Now the user has an understandable control which sets the sample size.
Now you can note that there are a couple of warnings in the Issues pane.
These warnings appear because pSeven sees that workflow inputs are not specified. To resolve these issues, you can add input defaults by assigning values to the root input ports. Note that defaults also give a user a hint about expected inputs, which is another reason to add them.
- Switch back to Edit and open the root block configuration.
- Switch to the Ports tab.
- Specify port values in the Inputs pane (make sure they are valid).
A value on port is used when there is no other data source (such as a link connected to the port).
Save the workflow and try running it without specifying inputs.
The workflow runs, accepting defaults , and generates a 2x10 matrix which you can now view in Run thanks to the added workflow output (to open the matrix viewer, double-click the output value and click the details button ).
Parameters are used to make some block options and ports accessible from Run. With parameters, you can:
- Give the user in Run a simple control over selected block options — for example, some options that are changed frequently. Parameters can be changed quickly without opening block configuration. We are going to use this feature to add workflow parameters that set the range of values in the generated sample.
- Send values to ports directly without uplinking them to workflow inputs.
- Set the same value to many options at once. Parameters have aliases, and if two or more options use the same alias, specifying its value sets all these options.
- Similarly, send the same value to many ports. As an example, this can be useful if there are two blocks which require the same input constants.
The range of sample values is set by the high and low options in RandGen (the lower and upper value bound).
- Switch back to Edit and open RandGen configuration.
- Switch to the Options tab.
- Select the high and low options in the Parameter column.
- Click to apply settings and close the configuration dialog.
New parameters now appear in the Configuration tab in Run.
You can change parameter aliases and descriptions in workflow configuration on the Parameters tab. Note that you can also add parameters from here (click on the toolbar to see available ports and options).
Details you input in workflow configuration are now shown in Run instead of original option names and descriptions.
Note that the configuration shows some default values (displayed in gray italics). These defaults are option values specified in block configuration. You can try changing option values in RandGen to see how it affects the parameter default shown in Run.
Option parameters work in the following way:
- If a parameter value is not specified in Run, the workflow accepts option value from the block.
- If a parameter is specified, its value overrides the option value from block configuration.
Note that changing parameter values has no effect on option values in block configuration which you see in Edit. Parameters are run settings, related option values work as defaults.
Introducing parameters in a workflow provides another advantage: you can create preset combinations of parameter values.
Currently the workflow has only one default preset . Let us keep it default indeed (do not specify parameter values) and add another preset with a different value range.
- Click on the context menu and input the name for a new preset. For example: range: [-1, 1].
- This action creates a new preset with empty values and automatically makes it active. Specify parameter values for this preset (-1.0 and 1.0) to make them agree with the preset’s name.
Note that the lower bound value is in bold, indicating that it is different from the option value in RandGen configuration. Compare it to the upper bound one displayed in plain font: this value is specified by the preset, but it is the same as the option value set by the block. So both values are shown in a different font as compared to the default gray italics.
Presets can be switched quickly, allowing to change between different workflow setups. Moreover, the workflow user can manage presets (add, rename, duplicate, remove) using the context menu.
Presets are not saved until you save the workflow. They are a part of the workflow’s configuration, so there is no specific function to save presets.
Finally there is workflow which provides a customized Run interface with main settings.
- Save the updated workflow: it will be required in the Results and Reports tutorial.
The next important improvement would be configuring a report that processes workflow results. The Results and Reports tutorial provides an example of such a report and continues using the workflow from this tutorial to generate test data.
Note that it is strongly recommended to complete the Results and Reports tutorial because it is the main introduction to Analyze.