Publishing from R#
This section describes how to publish content to RStudio Connect from R. This can be done from the RStudio IDE's R Console as an alternative to pushbutton publishing, or for content types that do not support pushbutton publishing.
This workflow uses the rsconnect
R package. See the
rsconnect documentation
or the package help for details.
Shiny Applications#
To publish a Shiny application, use the deployApp
function,
specifying your project's directory:
rsconnect::deployApp(appDir = '<project-dir>')
For more information:
install.packages('rsconnect')
library(rsconnect)
?rsconnect::deployApp
Plumber APIs#
To get started with publishing Plumber API endpoints, create a directory with
a plumber.R
file defining your endpoints. From the R console, execute the
following, replacing <project-dir>
with your project's directory:
rsconnect::deployAPI(api = '<project-dir>')
Tensorflow Model APIs#
TensorFlow Model APIs are easy to deploy to RStudio Connect. Export your model:
# `library(tensorflow)` version
export_savedmodel(session, "mysavedmodel")
# `library(keras)` version
export_savedmodel(model, "mysavedmodel")
or from Python:
# Keras version
tf.keras.models.save_model(model, "mysavedmodel")
# Low-level TensorFlow version
tf.saved_model.save(model, "mysavedmodel")
Then deploy it to RStudio Connect using the rsconnect
R package:
rsconnect::deployTFModel("mysavedmodel", account = "myaccount", server = "myserver")
Note
TensorFlow Saved Models up to TensorFlow version 1.13.1 are supported. To
find out what version of TensorFlow is installed, you can run the following
in the R console: tensorflow::tf_version()
.
If your installed TensorFlow version is greater than 1.13.1, you can install TensorFlow 1.13.1 by running the following in the R console: tensorflow::install_tensorflow(version = "1.13.1")"
.