Do you ever wish you could run a particular set of TIBCO Spotfire® tasks automatically? At IQVIA we often see the need to automate rote tasks - e.g. refreshing embedded data in an analysis, deploying new versions from our test folder to our production folders, extracting SBDF data after data wrangling processes and so on. Spotfire provides a mechanism to support such automation, but it's hard to use and requires someone with c# skills to spend time working with the Spotfire SDK. This drove me to build a 'simple' wrapper for the Spotfire COM capability that implements a few capabillities and is easy to use from tools such as PowerShell.
As a simple example, consider the PowerShell code below, which connects to Spotfire and runs an automation services job script, outputing status information to the PowerShell window.:
Add-Type -Path .\IQVIA.Spotfire.ComClient.dll $spotfire = New-Object IQVIA.Spotfire.ComClient.Spotfire $spotfire.EnableConsoleLogging("Info") $spotfire.ConnectToSpotfire("/server:https://ourServerURL") $spotfire.RunAutomationJobFromFile("c:\temp\myjobfile.xml") $spotfire.Exit()
How do I install it?
Simply download the "Spotfire Automation.zip" file from this page and unzip to a folder on your drive. The only prerequisite is that you need to have a working Spotfire Analyst installation.
What can it do?
There are just a few simple capabilities
EnableConsoleLogging(logLevel)- set up simple console logging. Available levels are "Info", "Error", "Debug" and "Trace".
ConfigureLogging(configFilename)- set up log4net logging using a configuration file. Note that console based logging will not capture messages from Spotfire (unlike the simple method above).
ConnectToSpotfire(commandLine)- Connect to Spotfire using command line parameters (see Spotfire documentation for details on the command line, but at a minimum use /server:url).
Exit()- Closes Spotfire.
OpenFileFromLibrary(libraryPath)- Opens a file from the Spotfire library.
RunAutomationJobFromFile(filename)- Run an Automation Services job loaded from a file. Returns True or False based on success.
RunScript(script)- Runs an IronPython script. Note that scripts can be run with or without loading a Spotfire file first.
AddComView(viewType)- Use this for more complex COM automation where you provide your own 'view' that runs inside Spotfire (see Spotfire SDK documentation for details).
GetLastExceptionAsString()- this will return any exception messages from previous API calls.
What's that I see in your automation script about copying folders?
I also wrote a custom extension to Spotfire that adds various automation services tasks to help with things like deploying from test to production folders. If there's interest (and I can find time), I'll try and tidy it up and upload to another wiki page.
Why no 'save' or 'export data' methods?
Because you can easily write short IronPython scripts to perform those actions and run them via the
RunScript(script) method. I chose not to implement lots of methods in the library and instead have only implemented the bare bones, or where supported APIs don't exist (e.g. running automation scripts).
Is it supported?
Short answer - 'No'! I built this for our use and hope it might be useful for others. Feel free to pop questions in the feedback section and I'll endevour to reply or try and fix any issues.
In fact, I'm using several 'hacks' in order to implement features like running automation scripts because the Spotfire API doesn't provide supported mechanisms - so there's every chance that things will break in different versions of Spotfire. The current version of this tool was tested with Spotfire 7.10, but should work with other versions (we've been using similar capabillities since around Spotfire 5.5).