Closed ejanderson1 closed 2 years ago
Notes on step 2: Setting up your HPC environment
ssh-keygen -t rsa -b 4098
.ssh
folder on your computer. For example, my .ssh
folder is here C:\Users\emeli\.ssh\
scp <path to ida_rsa.pub on your local computer> NETID@clogin01.sph.emory.edu:.
(this will require you to enter your HPC password)cat id_rsa.pub >> .ssh/authorized_keys
Second: chmod 0600 .ssh/authorized_keys
Using git pull
Git pull does not work in an interactive R session (i.e. when you are on a node to run code) unless you load git first.
spack load git@2.35.1
spack load r@4.1.2
(or whatever version you are using)To create an alias that does all 3 of the above steps use:
alias lR='lspack; spack load git@2.35.1; spack load r@4.1.2; R
Creating and using a shell script
.sh
bash main.sh
into the terminalUsing renv with your project on the HPC
export RENV_PATHS_ROOT="/projects/epimodel/renv/"
in your HPC session.Renviron
file setup with your GitHub Private Access Token, you'll need to run export GITHUB_PAT="\<your github private access token\>"
so that you can use code from private repos (like ArtNet)install.packages("renv")
. You will see the following prompt:Warning in install.packages("renv") : 'lib = "/projects/epimodel/spack/opt/spack/linux-centos8-cascadelake/gcc-11.2.0/r-4.1.3-gpyu76r3akwrtruy2syewy526o6d7ghy/rlib/R/library"' is not writable Would you like to use a personal library instead? (yes/No/cancel)
Select yes. This will install renv in your personal library on the HPC. All the other packages you use will be in your renv library.
renv::activate
to activate your project.renv::restore
to sync your libraryREMINDER: you must run renv::restore()
on HPC any time you make changes to your library locally and push those to GitHub
REMINDER 2: if you update your EpiModelHIV branch you have to renv::update()
the package on the HPC as well
Steps to start an interactive R session
cd /projects/epimodel/NETID/ProjectName
srun
using: srun --cpus-per-task=32 -p epimodel --time=24:00:00 --mem=0 --pty /bin/bash
Note: any output you generate will default save to your project directory on the HPC
slrum workflow
Link to vignette: https://github.com/EpiModel/EpiModelHPC/blob/main/vignettes/epimodelhiv-slurmworkflow.Rmd
Side note on the use of renv: I previously ran into an issue in my local machine where renv::snapshot()
was not updating the list of packages in my lockfile (i.e., newly installed packages were not found in my lockfile). I found running renv::settings$snapshot.type("all")
helpful in my case. However, please note that running "all" option could include potentially undesired development dependencies in the lockfile.
@ynchen08 this is by design, renv::snapshot()
does not save all the installed packaged by default but only the ones that are used by the project.
For instance, most of my projects have languageserver
and lintr
installed but this is for my text editor and not the project itself. What renv
does is looking for library
, require
or package::function
calls on the scripts to find out what packages are actually necessary for the project. renv::settings$snapshot.type("all")
should be used parsimoniously as it can lead to weird behavior or at least an imperinflated list of packages to be installed
Using EMHIV after making changes to your branch
Method 1:
renv::update()
to pull the changes you made to EMHIV from GitHubrenv::snpshot()
to record the updated EMHIV to your renv.lock
fileMethod 2 (for quick development & testing locally):
pkgload::load_all(path/to/EpiModelHIV)
Note from Sam For quick development and testing locally, I always use the latter approach. For longer-term and bigger changes, including those that have to be tested against local versus HPC setups, I use the first approach. Here is an example:
# pkgload::load_all("~/git/EpiModelCOVID")
control <- [control.net](http://control.net/)(nsteps = 100,
nsims = 1,
ncores = 1,
[initialize.FUN](http://initialize.fun/) = init_covid_corporate,
[aging.FUN](http://aging.fun/) = aging_covid,
[departures.FUN](http://departures.fun/) = deaths_covid_corporate,
[arrivals.FUN](http://arrivals.fun/) = arrival_covid_corporate,
[resim_nets.FUN](http://resim_nets.fun/) = resim_nets_covid_corporate,
[infection.FUN](http://infection.fun/) = infect_covid_corporate,
[recovery.FUN](http://recovery.fun/) = progress_covid,
[dx.FUN](http://dx.fun/) = dx_covid,
[vax.FUN](http://vax.fun/) = vax_covid,
[prevalence.FUN](http://prevalence.fun/) = prevalence_covid_corporate,
module.order = c("[aging.FUN](http://aging.fun/)",
"[departures.FUN](http://departures.fun/)",
"[arrivals.FUN](http://arrivals.fun/)",
"[resim_nets.FUN](http://resim_nets.fun/)",
"[infection.FUN](http://infection.fun/)",
"[recovery.FUN](http://recovery.fun/)",
"[dx.FUN](http://dx.fun/)",
"[vax.FUN](http://vax.fun/)",
"[prevalence.FUN](http://prevalence.fun/)"),
resimulate.network = TRUE,
tergmLite = TRUE)
sim <- netsim(est, param, init, control)
Notes on the issue directly above added to a new wiki page here: https://github.com/EpiModel/EpiModeling/wiki/Writing-and-Debugging-EpiModel-Code
All of the windows-specific comments have been incorporated into the Wiki. Thanks @ejanderson1!
Notes on using R Studio's terminal
To login to Emory HPC in terminal before typing in the
ssh
command you must type this code:set DISPLAY=
. Then log in as you normally would. Note that this command must be typed every time you start a new R Studio session before you can log in to the HPC.