Difference between revisions of "Shiny App"

From UFRC
Jump to navigation Jump to search
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
[[Category:Shiny]]
 
 
[[Category:AlexReview]]
 
[[Category:AlexReview]]
 
To use a '<code>shiny</code>' R app on the HiPerGator and access it via your web browser you can follow these steps:
 
To use a '<code>shiny</code>' R app on the HiPerGator and access it via your web browser you can follow these steps:
Line 7: Line 6:
 
The example is using the 01_hello histogram Demo from the Shiny demo gallery.
 
The example is using the 01_hello histogram Demo from the Shiny demo gallery.
 
* Log into the HiPerGator
 
* Log into the HiPerGator
* Start a screen session on a login node
+
* Start an [[Development and Testing|interactive job]]: e.g. <code>srun --mem=4gb --time=08:00:00 --pty bash -i</code>
$ screen
+
* Load the R module and launch R, get the IP address of the machine your job is on:
 
  $ module load R
 
  $ module load R
 
  $ R
 
  $ R
 +
> system('hostname -i')
 +
172.16.201.61 # Example output; your IP will likely be different!
 
  > library(shiny)
 
  > library(shiny)
  > runExample("01_hello", host="172.xx.yyy.zzz") where the 10* is the ip address of the interface of the node you are on.
+
  > runExample("01_hello", host="172.16.201.61")  
  
If the app needs to do data processing for more than a half an hour at a time do the above from within an 'Interactive' SLURM session submitted from within a screen session. E.g. for a 4gb memory job that will run for 12 hours:
 
$ sbatch --ntasks=1 --mem=4gb --time=12:00:00 --pty bash -i
 
user@job_node $ module load R
 
...
 
  
 
One you run the above for a demo or from within your Shiny App directory for a real app you will see the
 
One you run the above for a demo or from within your Shiny App directory for a real app you will see the
 
  Listening on http://172.xxx.yyy.zzz:pppp
 
  Listening on http://172.xxx.yyy.zzz:pppp
 
message that shows you the IP address and the port to connect to. That completes the HiPerGator part. Please note that we will not be connecting to that IP address and the port directly. See below.
 
message that shows you the IP address and the port to connect to. That completes the HiPerGator part. Please note that we will not be connecting to that IP address and the port directly. See below.
 +
 +
{{Note|Your output may look like:
 +
Listening on http://172.16.201.61:5856
 +
/usr/bin/xdg-open: 869: www-browser: not found
 +
/usr/bin/xdg-open: 869: links2: not found
 +
/usr/bin/xdg-open: 869: elinks: not found
 +
/usr/bin/xdg-open: 869: links: not found
 +
/usr/bin/xdg-open: 869: lynx: not found
 +
/usr/bin/xdg-open: 869: w3m: not found
 +
xdg-open: no method available for opening 'http://172.16.201.61:5856'
 +
 +
Do not worry, shiny should still work.|warn}}
  
 
==Connect to the Shiny App==
 
==Connect to the Shiny App==
Line 31: Line 40:
  
 
E.g.
 
E.g.
  ssh -L 6808:172.xxx.yyy.zzz:6808 jdoe@gator .rc.ufl.edu
+
  ssh -L 5856:172.xxx.yyy.zzz:5856 jdoe@hpg.rc.ufl.edu
  
Once the tunnel is created go to your web browser and connect to [http://localhost:6808 http://localhost:6808]. You should see the Shiny App interface in the browser.
+
Once the tunnel is created go to your web browser and connect to [http://localhost:5856 http://localhost:5856]. You should see the Shiny App interface in the browser.

Latest revision as of 20:23, 3 June 2022

To use a 'shiny' R app on the HiPerGator and access it via your web browser you can follow these steps:

App Development

Start Shiny

The example is using the 01_hello histogram Demo from the Shiny demo gallery.

  • Log into the HiPerGator
  • Start an interactive job: e.g. srun --mem=4gb --time=08:00:00 --pty bash -i
  • Load the R module and launch R, get the IP address of the machine your job is on:
$ module load R
$ R
> system('hostname -i')
172.16.201.61 # Example output; your IP will likely be different!
> library(shiny)
> runExample("01_hello", host="172.16.201.61") 


One you run the above for a demo or from within your Shiny App directory for a real app you will see the

Listening on http://172.xxx.yyy.zzz:pppp

message that shows you the IP address and the port to connect to. That completes the HiPerGator part. Please note that we will not be connecting to that IP address and the port directly. See below.

Your output may look like:
Listening on http://172.16.201.61:5856
/usr/bin/xdg-open: 869: www-browser: not found
/usr/bin/xdg-open: 869: links2: not found
/usr/bin/xdg-open: 869: elinks: not found
/usr/bin/xdg-open: 869: links: not found
/usr/bin/xdg-open: 869: lynx: not found
/usr/bin/xdg-open: 869: w3m: not found
xdg-open: no method available for opening 'http://172.16.201.61:5856'
Do not worry, shiny should still work.

Connect to the Shiny App

On the 'local' side i.e. the desktop or the laptop you are on create an SSH tunnel to your shiny app:

For a MacOSX or Linux system it's as simple as running the following command:

ssh -L local_port:shiny_IP:shiny_port myuser@hpg.rc.ufl.edu

E.g.

ssh -L 5856:172.xxx.yyy.zzz:5856 jdoe@hpg.rc.ufl.edu

Once the tunnel is created go to your web browser and connect to http://localhost:5856. You should see the Shiny App interface in the browser.