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 push-button publishing, or for content types that do not support push-button publishing. You can also use this method to publish from R session in a terminal outside of the RStudio IDE.
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>')
Quarto Content#
The rsconnect
package can deploy all Quarto content supported by RStudio Connect (Quarto support is included in version 0.8.26).
To use rsconnect::deployApp()
to deploy Quarto content, you need to pass the
path to a Quarto binary to function's quarto
argument:
rsconnect::deployApp(appDir, quarto = "path/to/quarto")
If Quarto is available on your PATH
, you can use "quarto"
. If this doesn't
work, you can use the function quarto_path()
from the quarto
package:
rsconnect::deployApp(quarto = quarto::quarto_path())
The function rsconnect::writeManifest()
can also generate manifests for Quarto
content when provided a quarto
argument.
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")"
.