Jump to content
  • How to deploy custom Python modules for use in the Spotfire® clients.


    This article outlines the steps necessary to package Python custom modules in .py files to use with IronPython, and deploy them on Spotfire Server for use in the Spotfire desktop client and Spotfire Web Player.

    Procedure

    Step 1: Create or gather the custom Python module file.

    We create a custom Python module file in this example, but you could use an existing file.

    1. Create a new folder where you will place your custom Python module file.

    2. Launch a text editor and add the following function definition:

      def hello(string): return "Hello %s!" % (string,)
       
    3. Save the file as mymodule.py into the newly created folder.

    Step 2: Create a package file (*.spk).

    This step requires use of the TIBCO Spotfire SDK (TIBCO Spotfire Developer Software). This is a separate software product that can be obtained if you have a Spotfire Developer license. If this is your first time using the TIBCO Spotfire SDK, see the reference 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."

    image.png.1e531f2f4220980f0b25e6e3f4e47b22.png

    • Click Next.
    • Leave the default option for creating the module.xml file.

    image.png.b7fbc7a3ac8f71d1641d8964eea09dbe.png

    • Click Next.

    • Select your Python module file to include within the package.

    • Make sure that you are giving the Python module file (*.py file) a Public resource name that matches the same name as the file.

    image.png.a2a1998a6e648d4bf3b6016b5f72e5bb.png

    • 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 the name and version number.

    image.png.330516d0c93f3e400b974376959b1cad.png

    • Click Finish.

    • Click the Validate and Save button.

    image.png.d2f15431fd0c971cc6e1858339d98ccf.png

    • Right-click on the module and build an SPK file.
      image.png.faeeeb104a1b7d66382da05f40a4b64e.png

    Step 3: Deploy the Package File onto the Spotfire Server

    • Launch your browser, and navigate to the TIBCO Spotfire Server Administration Console. http://<host>:<port>/spotfire

    • Click on "Deployments and Packages"

    • Select a Deployment Area and click Add.

    • Browse to select the package file that you created.

    • Click upload to add the package to the Deployment area.

    • Click Validate (if present)

    • Click Save
      image.thumb.png.21060d70d368a8c2790ef5608b739ff6.png

    Step 4: Use your custom Python module in Spotfire Clients

    • Start TIBCO Spotfire Professional/Analyst client, and connect to the Spotfire Server to install the package.

    • Create an Iron Python script importing mymodule and calling the "hello" function as follows:

      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));
      image.thumb.png.f9ef3976420d07f64fa98c5937c2b9ed.png
     

    Results

    image.png.852213e91f9ddee19359330b36bce0c5.png

    References

     

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...