Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This guide walks you through the process of running an R script as an sbatch job on Sol.
This is useful when you have a long-running, computationally-intensive R script that you
want to run on Sol.

Step 1: Convert an R markdown file to an R script

If you already have an R script (.R) file, you can skip this step and proceed to Step
2.
If you are working with an R markdown file (.Rmd), you will need to convert it to an
R script (.R) before you can run it as an sbatch job.
You can do this by following these steps:

  1. Open an RStudio session on sol.asu.edu or request a lightwork interactive session
    with aux-interactive, load R with module load r-4.4.0-gcc-12.1.0 and start an R
    session with R.

  2. Use the knitr package to convert the R markdown file to an R script:

...

Review the generated example.R script and make any necessary adjustments to ensure
compatibility with non-interactive execution. A few common adjustments include:

  • Removing or modifying any interactive elements (e.g., readline, shiny).

  • Ensuring any file paths, inputs, or outputs are explicitly defined and relative to the
    working directory where the script will run.

  • If the script includes plotting or graphical outputs, consider saving them to files
    (e.g., PNG, PDF) instead of displaying them interactively.

  • Removing any cells that are not necessary for the sbatch job.

  • Adding necessary imports and environment setup at the beginning of the script.

...

To submit the R script as an sbatch job, you need to create an sbatch script that
specifies the resources and the commands required to run the job.
Below is an example sbatch script (submit_job.sbatch).
Note that you must load the appropriate R module on the script; interactive sessions
use the latest version by default.

...

  • Make sure to save your work in the R markdown before converting it to an R script.

  • Ensure that all necessary files and dependencies are available in the working directory
    where the sbatch job will run.

  • You can test and troubleshoot the R script using the debug QOS by running
    interactive -q debug -t 15.