TIBCO Spotfire® Service Python Installation and Administration

Creating a Spotfire Package for Python Packages on the Node Manager

An installation of Spotfire Service for Python on the node manager includes a Python interpreter and a set of packages to enable using Python in Spotfire.

About this task

The package named 'spotfire' provides tools for building SPKs to share Python packages with other data function authors in an organization, or to enable Spotfire Business Author and Consumer users to see Python-enabled analyses in a web browser.

Important: You must build a package for the operating system on which your Spotfire Server node manager is installed. You can build the SPK from either a Linux or a Windows computer running the node manager. This topic describes building the SPK using the spotfire package that is included in the download bundle.
  • If you are building an SPK for Linux only, then the SPK is deployed to the node manager. The packages it contains are used by data functions in analyses accessed through a web browser by Business Author and Consumer users.
  • If you are building an SPK for Windows only, then the SPK can be deployed to the node manager, to other Spotfire Analyst users, or to both. Packages deployed to the node manager are used by data functions in analyses accessed through a web browser by Business Author and Consumer users. (Alternatively, you can build the SPK from an installation of Spotfire Analyst. For those details, see Creating a Spotfire Package for Python Packages from a Windows Computer.

The package builder relies on pip, the Python command-line application to install Python packages. The package builder uses a requirements.txt file to specify the packages to include in your SPK.

Note: By default, the file requirements.txt searches the PyPI package site for the specified package and version.
  • To include a package from a different repository or in a local file path, in the requirements.txt file, use the option -i or --index-url, followed by the location URL.
    #example
    #
    mylib -i http://my.domain.org/lib/1.0.0/mylib/
  • To include a .whl package, in the requirements.txt file, provide the relative path to the package from the current working directory.
    #simple-example
    #
    ./my_path/my_package.whl
    packaging==1.0.0
Note: If you are building an SPK intended for the Spotfire Service for Python, then you must avoid installing packages that are already included in the installation. Installing a different version of a package that is included in the service installation can cause unexpected errors. If a package you are installing depends on or requires one of the included packages, then it is filtered out when the SPK is built. For a list of included packages, see Included Packages.

For more information about creating a requirements.txt file for your package list, see its documentation at the following location.

This task creates an SPK for the Spotfire Service for Python, running on a node available to Spotfire Server. If you need to build a package to distribute to Spotfire Analyst users, see Python Data Functions in TIBCO Spotfire®.

Perform this task from a command prompt on the Linux or Windows computer where the installed node manager includes the installation of Spotfire Service for Python.

Before you begin

  • You must have write access to the computer running the node manager where Spotfire Service for Python is installed.
  • You must have created the file requirements.txt containing the list of packages to include in your SPK.
    The following example specifies these packages and versions from PyPI.
    ####### example-requirements.txt #######
    		#
    scipy==1.6.3
    matplotlib == 3.4.1
    statsmodels == 0.12.2
    		

Procedure

  1. From the command line, type the command to create the SPK.
    "%Python_Service_Home%/python/python" -m spotfire.spk packages  
    [--name "<package-name>"] 
    <name.spk> 
    <path-to>requirements.txt
    "%Python_Service_Home% is the Python Service installation location. On Linux, this is usually /opt/tibco/tsnm/<server-version#>/nm/services/Python Service Linux-<installed-service-guid>. Specify the values for the installed Python Interpreter <version#>, the package-name, name.spk, and the path to the requirements.txt file. See the Options table for more information.
    Note: Remember that the path to the Python interpreter has spaces in it, so you must quote the path string.
    Option Description
    spotfire.spk The package containing the Python code to download and bundle the needed packages specified in requirements.txt.
    Tip: From the command prompt, you can view help for the spotfire package by typing the following command:

    "<path-to-python-interpreter>\python\python.exe" -m spotfire.spk packages --help

    packages The subcommand that creates the package bundle.
    --name A string that sets the internal name of the generated package (for deploying multiple SPK files).
    Note: If you do not specify the --name argument, then the package builder reverts to the package name that is embedded in the spotfire.spk stamp in the requirements file (located beneath "BuiltName"), to match the previous version of the package, or, if it is missing entirely, it reverts to "Python Packages Linux" for server packages.
    --analyst This option is available, but it is not used in this example.

    This option specifies that the Spotfire Server should distribute the packages in the SPK to other Spotfire Analyst clients connected to the Spotfire Server. For more information about using this option, see Python Data Functions in TIBCO Spotfire®.

    Tip: Everyone should use the same packages and package versions as those deployed on Spotfire Server.
    name.spk The name of the SPK file that is created by this task.
    requirements.txt The full path to the file requirements.txt.
    The following example creates an SPK named my_pkgs.spk, containing the packages specified in requirements.txt.
    "%Python_Service_Home%/python/python" 
    -m spotfire.spk packages 
    --name "example-packages" 
    my-pkgs.spk opt/files/requirements.txt
    The packages and all of their dependencies are written to the SPK named my-pkgs.spk in the current working directory where the command was run, and the version information is recorded in the file opt/files/requirements.txt. For example:
    #
    ####### example-requirements.txt #######
    #
    scipy == 1.6.3
    matplotlib == 3.4.1
    statsmodels == 0.12.2
    ## spotfire.spk: {"BuiltBy":"3.8.12 (tags/v3.8.12:024d805, May 3 2021, 13
    ## spotfire.spk: :18:16) [MSC v.1928 64 bit (AMD64)]","BuiltAt":"Mon May
    ## spotfire.spk:   3 12:31:10 2021","BuiltFile":"approved-packages.spk",
    ## spotfire.spk: "BuiltName":"my-packages","BuiltId":"6f976bb8-2db2-4e5b
    ## spotfire.spk: -882f-f10e14510cc0","BuiltVersion":"1.0.0.0","BuiltPack
    ## spotfire.spk: ages":{"cycler":"0.10.0","kiwisolver":"1.3.1","matplotl
    ## spotfire.spk: ib":"3.4.1","patsy":"0.5.1","pillow":"8.2.0","pyparsing
    ## spotfire.spk: ":"2.4.7","scipy":"1.6.3","statsmodels":"0.12.2"}}
  2. Locate the SPK you created in the working directory where you ran the command.
  3. Add the SPK to the Spotfire Server Deployment area, and then validate and save the area.

Results

  • The packages are added to the Spotfire Server node manager, where Business Author and Consumer users can access analyses that use the functions in the packages from their web browsers.

For an overview of the entire process, see Package Management for Spotfire Service for Python.