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.

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.

For details on creating Shiny apps, refer to Analyzing data with RStudio.

You can deploy Shiny apps from two different asset types:

For details on creating a code package, refer to Code packages.

Deploying a Shiny app

  1. Locate the package in the Assets list.
  2. Click the Deploy icon.
  3. Choose App as the deployment type.
  4. Provide a name for the deployment.
  5. In the Serving name field, provide the name to be used as the alternative for the deployment ID.
    • The name is validated to be unique within the namespace.
    • The name must contain only these characters: [a-z,0-9,_] and must be maximum 36 characters long.
  6. Adjust any optional settings for the deployment and then click Create.

When the deployment is complete, click the deployment name to view the details and to get the URL for sharing the app deployment.

Deploying a code package that contains a Shiny app

  1. Import a code package that contains your Shiny app files into your deployment space. For details, refer to Code packages.
  2. Locate the package in the Assets list.
  3. From the asset action menu, click Deploy.
  4. From the folder list, select the parent folder of your Shiny app and press the Create deployment button.
  5. Provide a name for the deployment.
  6. In the Serving name field, provide the name to be used as the alternative for the deployment ID.
    • The name is validated to be unique within the namespace.
    • The name must contain only these characters: [a-z,0-9,_] and must be maximum 36 characters long.
  7. Adjust any optional settings for the deployment and then click Create.

Optional settings for deployment

Setting Description
Hardware specification Choose a hardware configuration to match your app
Copies The number of copies to create if you want to increase the availability of the app. The maximum number of copies is 10.
Share with Choose whether to share with:
- Anyone who has the URL
- Authenticated users (logged in to Cloud Pak for Data)
- Collaborators in the deployment space

Connecting your Shiny application to a persistent storage volume

You can use deployed Shiny applications to read and write files to persistent storage volumes. To connect your Shiny application to a storage volume, follow these steps:

Note: You can also do these steps in your Cloud Pak for Data project. However, connections are unable to be promoted as they contain user credentials so connections need to be re-created in a space.

  1. Create a new storage volume connection.
    1. In your Cloud Pak for Data deployment space, click Add to space and then choose Connection.
    2. Search for storage volume and select Storage volume. Give your storage volume connection a name.
  2. If you don't have an available storage volume, click New volume.
  3. Give your new storage volume a name.
    1. If you have an existing persistent volume claim (PVC) or external connection that you would like to connect, select that. Otherwise, select New PVC. Complete the fields as required.
    2. If you do not have a storage space that is associated with your project, ask your Cloud Pak for Data admin to create one.
  4. Check Cloud Pak for Data authentication.
  5. Click Create.
  6. If your Shiny app was already running when you were creating the volume connection, deploy your Shiny app again.
  7. If your Shiny app was not running when you were creating the volume connection, save your Shiny app to the same deployment space (see previous instructions). Click Deploy.
  8. Optional: By default, auto-mounting is enabled. A few settings are available for tuning with API only. See the following API POST to:
    1. Disable auto-mount:
      {
       "r_shiny": {
         "authentication": "anyone_with_url",
         "parameters": {
           "auto_mount": false
         }
       }
      }
      
    2. Set individual mounts for more security in access. Only volumes that match mount paths will be mounted:
      {
       "r_shiny": {
         "authentication": "anyone_with_url",
         "parameters": {
           "mounts": [ "/mnts/same_dir" ]
         }
       }
      }
      
    3. Provide the parameter serving name:
      {
       "r_shiny": {
         "authentication": "anyone_with_url",
         "parameters": {
           "serving_name": "myapp"
         }
       }
      }
      

For more information, refer to WML API documentation.

Parent topic: Deploying assets