Last active
August 28, 2025 19:02
-
-
Save Aariq/d52a0d861e5a2c90540548caa47021af to your computer and use it in GitHub Desktop.
A minimal template for using purrr ≥1.1.0 on the UAHPC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(purrr) | |
| library(mirai) | |
| library(carrier) | |
| #launch SLURM jobs | |
| daemons( | |
| n = 3, #number of SLURM jobs to launch | |
| url = host_url()["enp1s0f1np1"], | |
| remote = cluster_config( | |
| command = "sbatch", | |
| # For all options see: https://hpcdocs.hpc.arizona.edu/running_jobs/batch_jobs/batch_directives/ | |
| options = "#SBATCH --job-name=mirai | |
| #SBATCH --account <your account name> | |
| #SBATCH --partition=standard | |
| #SBATCH --nodes=1 | |
| #SBATCH --ntasks=1 | |
| #SBATCH --time=00:01:00 | |
| module load R/4.4" #load other necessary modules here | |
| ) | |
| ) | |
| # Use purrr with in_parallel() to parallelize using SLURM jobs | |
| # See more here: https://www.tidyverse.org/blog/2025/07/purrr-1-1-0-parallel/#distributed-computing-made-simple | |
| mtcars |> | |
| map_dbl(in_parallel(\(x) { | |
| Sys.sleep(10) | |
| mean(x) | |
| })) | |
| daemons(0) #close the SLURM jobs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment