Deploying Shiny apps in Watson Machine Learning

Save a Shiny app to a deployment space, then deploy it as an app and make the URL available to users.

Use case for Shiny applications

Data scientists can build and deploy Shiny application dashboards to share access to the application.

For example, if you create an interactive map infographic, you can deploy the app to a server and socialize the link. Users with the link can click to interact with the infographic.

Available scenarios for running Shiny apps

Available scenarios for deploying a Shiny app depend on the type of project where the Shiny app was developed.

All projects

To deploy a Shiny app from any project type, follow one of these scenarios:

Note:

If you want to deploy a Shiny app that was transferred to the deployment space as a code package, you must first define its software specification. Refer to Preparing code packages that contain Shiny apps before deployment.

Projects with deprecated Git integration

To deploy a Shiny app from a project with deprecated Git integration:

  1. Export the Watson Studio project to a ZIP file on your desktop and then import it into a deployment space. The imported package becomes a code package asset in the space. For details, refer to:
  2. Deploy the Shiny app. Refer to Deploying Shiny apps from the deployment space.
Note:

If you want to deploy a Shiny app that was transferred to the deployment space as a code package, you must first define its software specification. Refer to Preparing code packages that contain Shiny apps before deployment.

Projects with default Git integration

To deploy a Shiny app from a project with default Git integration:

  1. Push files from a project to the Git repository and download the Git repository as a zip file.
  2. Import the zip file into a deployment space. The imported zip file becomes a code package asset in the space. For details, refer to:
  3. Deploy the Shiny app. Refer to Deploying Shiny apps from the deployment space.
Note:

If you want to deploy a Shiny app that was transferred to the deployment space as a code package, you must first define its software specification. Refer to Preparing code packages that contain Shiny apps before deployment.

The standard and recommended ways to move assets (for example, Shiny apps) to a deployment space are:

  • Exporting a Watson Studio project and importing it into a deployment space.
  • If applicable: making a snapshot of a Git repository and then downloading it.

Deploying Shiny apps from the deployment space

For details on deploying Shiny apps from the GUI, refer to Deploying Shiny Apps from the GUI.

If you want to share your deployed Shiny app with others, refer to Access modes for Shiny applications.

If your deployed application uses large files, such as custom R installation packages, consider using a Storage Volume. For more information, refer to Connecting your Shiny application to a persistent storage volume.

Tip: The initial load of a Shiny application might result in an empty page if the app is retrieving many dependent libraries from an external network. If this happens, try refreshing the app after a while. This issue can be corrected by sourcing the dependent libraries locally by bundling them into the Shiny app. For details, refer to Creating R scripts and Shiny apps.

Access modes for Shiny applications

To ensure that users can access the right amount of data, you can use the following security modes to limit or share access to your Shiny application deployment:

  • Use the Collaborators option in your deployment space if you want to keep your Shiny application private. For details, refer to Deployment space collaborator roles and permissions.
  • Use the Authenticated users option if you want to share you Shiny application with Cloud Pak for Data users.
  • Use the Anyone who has the URL option to share your Shiny application with anyone who has the link to access your application.

Note: Users that can access your Shiny application have no impact on what the application code is doing. Shiny applications do not display data specific to the user that accesses the application.

Preparing code packages that contain Shiny apps before deployment

Depending on the software specification that was used to create the Shiny app, before you deploy it, you must add a code-package.json file to the root of your package directory:

{
    "entry_points": [{
        "application_type":"RShiny",
        "dependencies": {
            "software_specification": "rstudio_r4.2"
        }
    }]
}

Software specifications available for Shiny apps: rstudio_r4.2 and rstudio-23.1-r4.2 (for x86) and shiny-r3.6 (deprecated, used for x86 and PPC).

Tip:

If a folder or a subfolder contains RShiny App files (that is files with the names app.R, ui.R or server.R), all files in that folder are considered to belong to the Shiny app (including .R files). Otherwise, all .R files are considered R script assets.

Accessing data with Shiny application deployment dashboard

You can use Shiny application dashbaords for a shared data connection with other users. Any data connection with personal credentials that is shared within the deployment space can be accessed by users that have access to the Shiny application.

Note:

You can use access modes in Shiny applications to modify user access to your data. For more information, see Access modes for Shiny applications.

Parent topic: Managing predictive deployments