Deploying R code for the Function client interface

Most client applications that use the Spotfire Statistics Services Function Client Interface call custom functions that were written for the client application. Typically, they are not part of the packages included with TERR. The Spotfire Statistics Services Function Client Interface calls one function, and then it releases the engine. To use the Function Client Interface, follow these steps.

Important: By default, certain Spotfire Statistics Services capabilities are disabled. If you have functions that you created or used in a previous release, you might find that they no longer work as expected. Additionally, any expression that TERR determines to be potentially malicious is disabled. Below is a non-exhaustive example of some of the capabilities disabled by default in Spotfire Statistics Services.
  • Sending TERR expressions that perform I/O to the file system or the internet.
  • Spawning new OS processes by calling the system function.
  • Calling into Java using the terrJava package, or using functions in the parallel package.
  • Loading new packages, except for those included with TERR.
  • Calling .C or .Fortran.
  • Send expressions to the server using the Expression Service.
  • Calling ExtendedServerInfo or sending other expressions that read from, or write to, your server.
  • Sending potentially malicious expressions to the server using the URL API.
Additionally, the Function Service can execute only one function, which allows a connection from Spotfire. If you have functions that you want to have enabled on Spotfire Statistics Services, or if you have additional questions about the configuration settings that control these capabilities, see your server administrator.

Procedure

  1. Develop a set of custom functions containing your complete request.
  2. Create a binary package to hold your custom functions.
  3. Upload the package to Spotfire Statistics Services.
    Packages you create to deploy on the server must be compiled as binaries and uploaded as zipped files (with a .zip or tar.gz extension). See Package updating tools for TIBCO Spotfire Statistics Services.
  4. Make sure the client application function begins with a call to load the package (library(packagename)).
    Remember that each time you call a function, a new R engine is started, and when the function is completed, the engine is released. This means that the package must be loaded with each function call.

    Optionally, you can ask your system administrator to add your package to the engine init script, so the package is loaded automatically whenever the engine starts. In a clustered environment, when a package is deployed to a Manager node, the package is automatically made available to all of the cluster’s Worker nodes.

  5. Provide the client developer with the function names, the package name, and all the function arguments.
    The client developer calls each function using the Function Client Interface API eval().
  6. After your package is deployed, if you find you need to change it, you can make any necessary changes, and then redeploy it easily.
    If you are uploading open-source R or TERR packages using the Eclipse plug-in TSSS Connector, see Package updating tools for TIBCO Spotfire Statistics Services for more information.
Related tasks