OpenCPU release 1.5

July 5, 2015

Following a few weeks of testing, OpenCPU 1.5 has been released. OpenCPU is a production-ready framework for embedded statistical computing with R. The system provides a neat API for remotely calling R functions over HTTP via e.g. JSON or Protocol Buffers. The OpenCPU server implementation is very stable and has been thorougly tested. It runs on all major Linux distributions and plays nicely with the RStudio server IDE (demo).

Similarly to shiny, OpenCPU has a single-user/development edition that runs within the interactive R session, and a multi-user (cloud) server for deployments on Linux. Unlinke shiny however, the cloud server comes at no extra cost. On the contrary: you are encouraged to take advantage of the cloud server which is much faster and includes cool features like user libraries, concurrent sessions, continuous integration, customizable security policies, etc.

New in OpenCPU 1.5

The OpenCPU API itself has not changed from the 1.4 branch, but the entire underlying stack has been upgraded, hence the version bump. The server now builds on:

  • R 3.2.1
  • stringi 0.5-5
  • jsonlite 0.9.16
  • devtools 1.8.0
  • RStudio 0.99 (optional)

Navigate to /ocpu/info on your OpenCPU server to inspect the exact versions of all packages used by the system.

In addition to an upgraded package library, this version includes many small tweaks for the deb/rpm installation packages and docker files. Redhat distributions like Fedora and CentOS are now automatically configured with the required SELinux policies.

Installation and upgrading

The download page has instructions for installing the opencpu server on various distributions, either from source or using precompiled binaries. To upgrade an existing installation of opencpu on ubuntu, simply run:

sudo add-apt-repository ppa:opencpu/opencpu-1.5
sudo apt-get update
sudo apt-get dist-upgrade

Note that this will also upgrade the version of R to 3.2.1 (if you have not already done so) which might require that you reinstall some of your R packages.

Getting started

For those completely new to OpenCPU there several resources to get started. The presentation from last year’s useR conference gives a broad overview of the system including some basic demo’s. The example apps and jsfiddle scripts show how to use the opencpu.js JavaScript client. The server manual has contains documentation on configuring your opencpu cloud server (although installation should work out of the box).

Finally this paper from my thesis describes more generally the challenges of embedded scientific computing, and the benefits (both technical and human) of decoupling your statistical computing from your front-end or application layer.

The public demo server

To deploy your OpenCPU apps on the public server, simply push your R package to Github and configure the webhook in your repository. Whenever you push an update to Github the package will be reinstalled on the server and can directly be used remotely by anyone on the internet. You can either use the full url or the shorthand url:

  • https://{username}{package}/

These urls are fully equivalent. Simply replace {username} with your github username, and {package} with your package name. Note that the package name must be identical to the github repository name (as is usually the case).

On writing packages

One prerequisite for using OpenCPU is knowing how to create an R package. There is no way around this; packages are the natural container format for shipping and deploying code/data/manuals in R, and the OpenCPU API assumes this format. Luckily, writing R packages is super easy these days and can be done in less than (10 seconds) using for example RStudio.

The good thing is that once you passed this little hurdle, the full power and flexibility of R and it’s packaging become available to your applications and APIs. Hadley’s latest book on writing R packages gives a nice overview of the R packaging system, and the OpenCPU API provides an easy HTTP interface to all of these features.