Introduction
The purpose of this article is to outline the steps necessary to package custom python modules, py files and deploy them to Spotfire Server for usage by Spotfire Clients (Analyst, Web Player) users
Prerequisites
- You must have administration access to Spotfire Server
- You myst have Spotfire Developer License enabled
Step 1: Create or gather the Custom Python Module file
In this example, we create a custom python module file.
-
Create new folder where you will place your custom python module file.
-
Launch a text editor such as Notepad. Add the following function definition:
def hello(string): return "Hello %s!" % (string,)
-
Save the file as mymodule.py into the new folder created in the previous step.
Step 2: Create a package file (*.spk)
This steps requires to use the Spotfire SDK. This is a separate software that can be obtained if you have a Spotfire Developer License. If this is the first time that you use the Spotfire SDK, see the referenced links below for installation instructions.
-
Launch the SDK Package Builder
-
Click the 'Add' button to add a new project
-
On the next window, leave selected the option 'Add project: From folder:' > Click Browse and select your python files folder (this is the directory where you have kept all the files needed for this implementation)
-
Un-check the button for 'Source code folder'
-
Click Next
-
Leave the default option for creating the module.xml file
-
Click Next
-
Select your PythonModule file to include within the package
- Make sure that you are giving the python module file (*.py file) a Public resource name with the same name.
-
Click Next
-
Change the intended client to "TIBCO Spotfire Any client" to use the custom python module on all TIBCO Spotfire clients and provide other information such as name and version number
-
Click Finish
-
Click the Validate and Save button
-
Right click on the module and build an SPK file
Step 3: Deploy the Package File onto Spotfire Server
- Launch your browser and navigate to the TIBCO Spotfire Server Administration Console. http://<host>:<port>/spotfire/#/deploymentsPackages
- Select a Deployment Area and click Add packages
- Browse and select the package file(.spk) file that you created
- Click Upload to add the package to the Deployment Area
- Click Validate area
- Then, click Save area
Step 4: Use your Custom Python Module in TIBCO Spotfire Analyst
- Start Spotfire Analyst client and connect to the Spotfire Server to install the package
- Create a script importing mymodule and calling 'hello' function as below:
from Spotfire.Dxp.Framework.ApplicationModel import NotificationService import sys sys.path.append(ModulesService.GetResourceDirectoryPath("mymodule.py")) from mymodule import hello # Call Hello function x= hello("world"); print x; # Notification service notify = Application.GetService[NotificationService](); notify.AddInformationNotification("Custom Python Module","Hello Function",str(x));
Results
mps-interface-tibco-spotfire-software.pdf
Recommended Comments
There are no comments to display.