Using Rstudio for classroom

OSC provides an isolated and custom R environment for each classroom project that requires Rstudio. The interface can be accessed at class.osc.edu. Before using this interface, please apply for a classroom project account that is unique for the course.  More details on the classroom project can be found here. The custom R environment for the course will be tied to this project ID. Please inform us if you have additional requirements for the class. Once we get the information, we will provide you a course_ID and add your course to the server with the class module created using the course_ID. After login to the class.osc.edu server, you will see several Apps listed. Pick Rstudio server and that will take you to the Rstudio Job submission page. Please pick your course from the drop-down menu under the Class materials and the number of hours needed. 

final-copy.jpg

Clicking on the Launch will submit the Rstudio job to the scheduler and you will see Connect to Rstudio server option when the resource is ready for the job. Each Rstudio launch will run on 1 core on Owens machine with 4GB of memory. 

 

final-copy22.jpg

Rstudio will open up in a new tab with a custom and isolated environment that is set through a container-based solution. This will create a folder under $HOME/osc_classes/course_ID for each user. Please note that inside the Rstudio, you won't be able to access any files other than class materials. However, you can access the class directory outside of Rstudio to upload or download files.

Screen Shot 2020-07-21 at 11.32.42 PM.png

You can quit a Rstudio session by clicking on File from the top tabs then on the Quit. This will only quit the session, but the resource you requested is still held until walltime limit is reached. To release the resource, please click on DELETE in the Rstudio launch page.

Shared Access

PI can use the existing path under their $HOME with proper permission to store and share materials like data, scripts, etc, and R packages with the class. PI can also request project space for the project ID of the course. This project space will be created under /fs/ess/project_ID. Once the project space is ready, please create a folder with the course_ID  and then two subfolders 1) Rpkgs 2) materials, e.g.

mkdir -p /fs/ess/project_ID/course_ID/Rpkgs
mkdir -p /fs/ess/project_ID/course_ID/materials

If you are using $HOME space as storage,

mkdir -p $HOME/osc_classes/course_ID/Rpkgs
mkdir -p $HOME/osc_classes/course_ID/materials 

Please do not install any R packages for the course yet. Please inform us of your preferred storage path for materials and R packages. We will add these paths to the class module that we will be setting for the course to ensure shared access.

If PI is storing materials to be shared in their $HOME path, please set the permission as follows;

Let's say PI's $HOME path is  /users/PYYYYY/PI's_username. On class.osc.edu server, click on Clusters from the top tabs, then on Owes Shell Access. This will open up a terminal on Owens where you can enter Unix commands for setting proper permissions.

chmod -R o+x /users/PYYYYY/PI_username
chmod -R o+r /users/PYYYYY/PI_username/osc_classes/course_ID

Shared R packages

Once the class module is ready, PI can access the course at class.osc.edu under the Rstudio job submission page. PI can launch the course environment and install R packages for the class. 

It is important to install R packages for the class only in the class R environment after launching the Rstudio interface for the course. If you install R packages without launching class Rstudio, R will have access to your personnel R libraries at $HOME and could affect the installation process. 

After launching Rstudio, please run the .libPaths() as follows

> .libPaths()
[1] "/users/PZS0680/soottikkal/osc_classes/OSCWORKSHOP/R" "/fs/ess/PZS0687/OSCWORKSHOP/Rpkgs"                  
[3] "/usr/local/R/gnu/9.1/3.6.3/site/pkgs"                "/usr/local/R/gnu/9.1/3.6.3/lib64/R/library" 

Here you will see four R library paths. The last two are system R library paths and are accessible for all OSC users. OSC installs a number of popular R packages at the site location. You can check available packages with library() command. The first path is a personal R library of each user in the course environment and is not shared with students. The second lib path is accessible to all students of the course. This can be PI's $HOME path or project space path depending on what you have chosen and how we set up the class module. PI should install R packages in this library to share with the class. As a precaution, it is a good idea to eliminate PI's personal R library from .libPaths() before R package installation as follows. Please note that this step is needed to be done only when preparing course materials by PI.

> .libPaths(.libPaths()[-1])
> .libPaths()
[1] "/fs/ess/PZS0687/OSCWORKSHOP/Rpkgs"          "/usr/local/R/gnu/9.1/3.6.3/site/pkgs"      
[3] "/usr/local/R/gnu/9.1/3.6.3/lib64/R/library"

Now there is only one writable R library path such that all packages will be installed into this library path and shared for all users.

PI can install all packages required for the class using install.packages() function. Once the installation is complete, students will have access to all those packages. 

Please note that students can also install their own packages. Those packages will be installed into their personable library in the class environment i.e., the first path listed under .libPaths()

Shared materials

PI can share materials like data, scripts, and rmd files with students in three different ways. Each student will have to copy materials from the shared path to their $HOME space.

  1. On class.osc.edu server, click on Files from the top tabs, then on $HOME directory. From the top right, click on Go to and enter the storage path (Eg: /fs/ess/PZS0687/) in the box and press OK. This will open up storage path and users can copy files. Open the class folder from the $HOME tree shown on left and paste files there. All files copied to  $HOME/osc_classes/course_ID will appear in the Rstudio FIle browser.

    Screen Shot 2020-07-21 at 11.38.18 PM.png
  2. On class.osc.edu server, Click on Clusters from the top tabs, then on Owens Shell Access. This will open up a terminal on Owens where students can enter Unix command for copying. Eg: 

    cp -r /fs/ess/PZS0687/OSCWORKSHOP/materials $HOME/osc_classes/course_ID

    Please note that $HOME/osc_classes/course_ID will be created only after launching Rstudio instance at least once.
  3. Students can also upload material directly to Rstudio using the upload tab located in the File browser of Rstudio from their local computer. This assumes they have already downloaded materials to their computers.

    arrow_1.png

Checklist for PIs

  • Apply for a classroom project ID that is unique to the course
  • Inform us about additional requirements such as R version or other software
  • Inform us preferred storage path location to be shared with the class
  • Once the class module is ready, create class materials under the storage path, and install R packages in the class environment.
  • Make a reservation on OSC cluster for the class schedule.
  • Invite students to the project at my.osc.edu to give them access to the project ID.

Please reach out to oschelp@osc.edu if you have any questions.