Skip to content

R deployment template structure

The R code for a deployment has a few requirements in terms of structure. UbiOps supports R 4.0. The template can be found on our Github.


For R deployments, the deployment package directory is required to contain:

  • deployment.R - Main script for the deployment. It should include the following two functions:
    • An init function used for initialization and loading data which can be re-used between deployment requests. This function is called every time the deployment becomes active in UbiOps.
    • A request function that contains the main logic which is called at each deployment request.

In addition, the deployment package directory can contain the following:

  • renv.lock - A lockfile containing packages required for the deployment. UbiOps will install the packages defined in this file for you using renv::restore() once you upload your deployment. For more information, take a look at renv documentation.
  • install_packages.R - An R file containing instructions to install packages, like, install.packages("randomForest"). After this build step the dependencies are fixed and won't change.
  • ubiops.yaml - A yaml file to install OS level packages.
  • ... - Any custom files in any location of the deployment package directory.

The maximum size for a deployment package is 8 GiB.

Preinstalled packages

To speed up the package installation process, some standard R packages are preinstalled:

All preinstalled packages

askpass, assertthat, backports, base64enc, BH, blob, broom, callr, cellranger, cli, clipr, colorspace, cpp11, crayon, curl, DBI, dbplyr, digest, dplyr, ellipsis, evaluate, fansi, farver, forcats, fs, generics, ggplot2, glue, gtable, haven, here, highr, hms, htmltools, httr, isoband, jsonlite, knitr, labeling, lifecycle, lubridate, magrittr, markdown, mime, modelr, munsell, openssl, pillar, pkgconfig, prettyunits, processx, progress, ps, purrr, R6, RColorBrewer, Rcpp, readr, readxl, rematch, remotes, renv, reprex, rlang, rmarkdown, rprojroot, rstudioapi, rvest, scales, selectr, stringi, stringr, sys, tibble, tidyr, tidyselect, tidyverse, tinytex, utf8, vctrs, viridisLite, withr, xfun, xml2, yaml

Testing your deployment

The deployment template in our Github project contains an example script to test whether your deployment is working correctly within our deployment wrapper.

Edit and execute the file run_deployment.R according to your deployment to simulate the UbiOps back-end that initializes the deployment and makes a request. Please do not include these testing scripts in your deployment package.