/background-jobs

Resources for demoing local and Launcher jobs with RStudio

Primary LanguageRApache License 2.0Apache-2.0

RStudio 1.2 Background Jobs

RStudio 1.2 introduced the ability to send long-running R scripts to local and remote background jobs. This functionality can dramatically improve the productivity of data scientists and analysts using R since they can continue working in an unblocked R session in RStudio while jobs are running in the background. Local background jobs are supported by all versions of RStudio, server and desktop. Remote background jobs are a feature of RStudio Server Pro and are orchestrated by the RStudio Job Launcher, which also supports running interactive R sessions on remote resource managers like Kubernetes.


Background jobs can be started manually or programatically. These jobs can be started from the RStudio IDE in three different ways:

As mentioned in the RStudio blog post, local background jobs are ideal for interactive, ad-hoc usage. The callr package provides a mechanism for programatically orchestrating background R processes. This repository is a collection of resources used to demonstrate various use cases for local and remote background jobs. In many cases, scripts can be run as local or remote jobs. For the resources collected here, 🏠 indicates examples for local Jobs while 🚀 indicates jobs suited for the Launcher.


Simple scripts that can be used to demonstrate local job environment options.

Running a Shiny application as a local background job allows the current R session to remain free to work on other things. This can be especially helpful for making changes to the Shiny code and seeing the changes in real time.

Similar to Shiny applications, plumber APIs can be run as a local background job. This allows the current R session to remain open for things like testing or interacting with the API.

Background and Launcher jobs are ideal for long running processes, like loading data from an external database or API.

Simulations 🏠 🚀

Long running tasks like simulation studies can be run as background or Launcher jobs in order to keep the original R session open for other work.

Model Training 🏠 🚀

Model training, which can often take a long time, is another great use case for background and Launcher jobs. Local jobs are ideal for sequential model training while Launcher jobs can be used to train multiple models in parallel.

Simple examples showcasing how to use the rstudioapi package to programmatically orchestrate local and Launcher background jobs.