Workspace 6.21.5
|
In the previous tutorial Connecting a workflow to a user interface, we learned about how you can use global names to connect inputs and outputs to a user interface. In this tutorial we are going to see how we can use global name files to save and restore workflow settings, or to simplify setting multiple globalName parameters when running a workflow from the command line
We're going to begin by opening the workflow we created in the Connecting a workflow to a user interface tutorial:
As in the previous tutorial, the workflow takes a CSV file, calculates some values for a new column, writes out the new CSV data, as well as an image of a chart of the data.
So far, we have been looking for a few special inputs and/or outputs and assigning them global names. What if we want to be able to control all of the workflow settings from an application or command line? Maybe the workflow is so complex that even a small subset runs into the hundreds. We can consider a workflow's set of global name values as the workflow's settings, and Workspace provides a mechanism for saving and loading them via exporting and exporting global name files.
settings file" Lets's have another look at our workflow. In this diagram, all the input racks have been pinned open so that you can see all the values that we can vary. So far, we've only assigned global names to inputs to the <em>Render Chart to Image</em> and <em>Image Writer</em> operations (see them at the bottom left of the workflow). @image html tutglobalnames_workflow-showing-all-inputs.png "You may want to consider more inputs" Suppose we want to use this workflow to chart any column from any column-separated (csv) file. While we don't need any more operations, if we want to use a custom interface or command line, we'll want to be able to set quite a few more global names: - The input and data output filenames - File format values - The column name - Chart properties such as the title, key and axis labels Let's see what that might look like. @image html tutglobalnames_extended_globalnames.png "Adding global names for file format and chart labels" Even if we want to execute the workflow directly, it will simplify things a lot if we can save groups of settings - perhaps the format of files from a particular site. Global name files have suffix "wsg" Let's save these settings by exporting this file as <em>workflow_chart_area.wsg</em>, then we can change some settings. @image html tutglobalnames_exportglobalnames_small.png From the <em>Query Sql Database</em> Result output, we know that the input file has six columns to choose from. @image html tutglobalnames_inputfilecolumns.png "The input file has six columns of data" Let's change the settings so that we are plotting the perimeter rather than the area column. We can save this file as <em>workflow_chart_perimeter.wsg</em> @image html tutglobalnames_extended_globalnames_perimeter.png "Changing some global names so we plot the perimeter" Now we have two Workflow settings files saved. If the input file were updated regularly, we could load and execute the appropriate workflow to see the latest area or perimeter data. While this is a trivial example, there are actually many reasons why you may want to use a workflow settings file: - Saving them gives you a record of the settings you used. - When you next need to run the workflow you can load a global name file to return to a previous known good set of parameters. - You want to run the workflow from the command line, but not have to set lots of parameters: you can just set one, the global name filename You can save multiple global names files for the same the workflow. - This saves time and errors. - You can run the same workflow but for totally different reasons, for example some days you look for all overdrawn accounts but other times you look for your largest depositors, then you may be able to use the same workflow, just use different global name files (one that looks for the lowest balances and one that looks for the highest.) - You can run the same workflow using different resources, for example - remote servers (so different IP addresses), - a SQL database (with different SQL queries and different regular expressions to filter outputs) If you use a global name file then you won't need to enter (or modify) different sets of these values every time you run the workflow or application. @section tutglobalnamesrunbatchfile Running workflows from the command line using a global names file The steps involved in running a workflow from the command line using a global-name-based settings file are: -# Choose which inputs you want the user to be able to change: assign a global name to each -# Start up a terminal window on your machine. -# Run your workflow through the workspace-batch application <em>workspace-batch –globalNameFile <mysettings.wsg> <myworkflow.wsx></em> -# You can override any settings with the –globalName parameter For more information about running workflows from the command line, see \ref tutbatch @section tutglobalnamescomparingworkflowsettings Comparing two global settings files If you want to compare two workflow settings files, then you can use the Workspace <em>global-name-diff</em> application, distributed with the Workspace package. You can access it the same way to access the Workspace editor. @image html tutglobalnames-global-diff-startup.png "Starting up the Workspace global name diff application under Windows" - Open the application, and enter the names of two files you have saved as File A and File B. - Click on the menu item <em>Actions->Compare files</em> or the <em>Compare files</em> toolbar button (see the arrow in the figure below) @image html tutglobalnames_comparefiles.png By default, settings will only be displayed where they are different, but if you check the <em>Show all global names</em> box you can see everything. @image html tutglobalnames_globalnamescomparison.png Legend: - Global names in purple are only found in Workflow A - Global names in green are only found in Workflow B - Global names in purple and green are found in both workflows, but have changed - Global names in white exist in both files and are unchanged We recommend that you make any changes to globalname files through the Workspace editor (the <em>Global Names</em> window is a good place to do this). For more information about using the Workflow tools that are provided in the Workspace package, see \ref workflowtools @section tutglobalnamefilessummary Summary This concludes the tutorial on using workflow settings files. You should now know why global name files are useful in many different contexts, and how to: - Import and export global name (settings) files - Run a workflow from the command line using a global name file as a parameter - Start up and use the Workspace <em>global name diff</em> tool to compare two global names files <div class="navlinks">[ Previous: Connecting a workflow to a user interface ] [ Up: Introductory Tutorials ] [ Next: Visualising data with charts ]