Workspace 7.0.2
Saving and restoring workflow settings

Introduction

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


Note
This tutorial builds upon the workflow constructed in the Connecting a workflow to a user interface tutorial. If you have not completed this tutorial, you can use this sample workflow.

Contents


Pre-requisites

We're going to begin by opening the workflow we created in the Connecting a workflow to a user interface tutorial:

  1. Open up the workflow using the Workspace editor
  2. Make sure it executes successfully by clicking the execute button
The workflow we're going to execute

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.


Workflow settings (global name files)

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.

Exporting a workflow's global names to create a 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 Render Chart to Image and Image Writer operations (see them at the bottom left of the workflow).

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.

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 workflow_chart_area.wsg, then we can change some settings.

From the Query Sql Database Result output, we know that the input file has six columns to choose from.

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 workflow_chart_perimeter.wsg

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.

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:

  1. Choose which inputs you want the user to be able to change: assign a global name to each
  2. Start up a terminal window on your machine.
  3. Run your workflow through the workspace-batch application workspace-batch –globalNameFile <mysettings.wsg> <myworkflow.wsx>
  4. You can override any settings with the –globalName parameter For more information about running workflows from the command line, see Batch execution

Comparing two global settings files

If you want to compare two workflow settings files, then you can use the Workspace global-name-diff application, distributed with the Workspace package. You can access it the same way to access the Workspace editor.

Starting up the <em>Workspace global name diff</em> 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 Actions->Compare files or the Compare files toolbar button (see the arrow in the figure below)

By default, settings will only be displayed where they are different, but if you check the Show all global names box you can see everything.

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 Global Names window is a good place to do this).

For more information about using the Workflow tools that are provided in the Workspace package, see Workflow tools

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 global name diff tool to compare two global names files