Closed ejanderson1 closed 2 years ago
(i.e., if you want to make changes to workflow script and resubmit it)
# Setup ------------------------------------------------------------------------
library(slurmworkflow)
library(EpiModelHPC)
library(data.table)
library(EpiModelHIV)
hpc_configs <- swf_configs_rsph(
partition = "preemptable",
mail_user = "[email_address]@emory.edu"
)
sim_dir <- "data/intermediate/sims"
max_cores <- 5
hpc-configs
the partition can be preemptable
or epimodel
sim_dir
is the location that your sims will go on the HPCnncores
argument in control_msm
. If you want to run 32 sims per batch, then you need to set this to 32.wf <- create_workflow(
wf_name = "test",
default_sbatch_opts = hpc_configs$default_sbatch_opts
)
wf_name
argument. Here mine is called test
. If I look at the newly created workflows folder in my project there should be another folder within it called test
renv::restore()
on the HPC
wf <- add_workflow_step(
wf_summary = wf,
step_tmpl = step_tmpl_renv_restore(
git_branch = "main",
setup_lines = hpc_configs$r_loader
),
sbatch_opts = hpc_configs$renv_sbatch_opts
)
git_branch
) sim.R
codenetstats
, netest
, and epistats
files:
epistats <- readRDS("data/intermediate/estimates/epistats.rds")
netstats <- readRDS("data/intermediate/estimates/netstats.rds")
orig <- readRDS("data/intermediate/estimates/restart.rds")
Note that in replace of my epistats file I have a restart file from calibration
param.net
, for example:
param <- param.net(
data.frame.params = readr::read_csv("data/input/params-100000.csv"),
netstats = netstats,
epistats = epistats,
sti.cond.eff.rr = 0.9,
riskh.start = prep_start - 52,
prep.start = prep_start,
init_msm
:
init <- init_msm(
prev.ugc = 0.1,
prev.rct = 0.1,
prev.rgc = 0.1,
prev.uct = 0.1
)
control_msm
but here you will find some differences with the standard sim code:
control <- control_msm(
start = calib_end + 1,
nsteps = end_sim,
nsims = 1,
ncores = 1,
initialize.FUN = reinit_msm,
cumulative.edgelist = TRUE,
truncate.el.cuml = 0,
verbose = FALSE,
)
nsims
and ncores
should be set to 1. These will specified in a later stepreinit_msm
scenarios.df <- dplyr::tibble(
.scenario.id = c("base", "scen_1", "scen_2", "scen_3"),
.at = int_start,
part.index.prob= c(0, 0.333, 0.666, 0.999))
scenarios.list <- EpiModel::create_scenario_list(scenarios.df)
- The above code creates 4 scenarios, each using a different value for `part.index.prob`
- You can look at the dataframe to make sure it lists each scenario correctly
# Step 6 - netsim code
wf <- add_workflow_step( wf_summary = wf, step_tmpl = step_tmpl_netsim_scenarios( orig, param, init, control, scenarios_list = scenarios.list, output_dir = sim_dir, libraries = "EpiModelHIV", n_rep = 32, n_cores = max_cores, max_array_size = 500, setup_lines = hpc_configs$r_loader ), sbatch_opts = list( "mail-type" = "END", "cpus-per-task" = max_cores, "time" = "04:00:00", "mem" = "0" # special: all mem on node ) )
- This step is the one where `netsim` is run
- you give it your scenario df, est, param, init, and control objects, the output directory you created above, plus some additional inofrmation
- `n_rep` is the same as `nsims` in the control function; for example, you might want to do 64 sims
- `n_cores` is set to the number of cores you want allot to each batch; for example, if you do 64 sims and want to 2 batches, you would set this to 32
- Other parts you can leave the same
Overview:
sim.R
,runSim.sh
, andmainSim.sh
files and submitting your job usingbash
Before you begin
workflows/
to your gitignoreStep 1 - create workflow script
Step 2 - run workflow script
workflows
folder in your projectStep 3 - create wf directory on HPC
mkdir
command or you can run the following from terminal when not logged into the HPC:ssh <user>@clogin01.sph.emory.edu "mkdir -p ~/projects/BigNets/workflows"
where you insert the location that you want your workflows folder in place of the BigNets code on the right.Step 4 - copy wf files to HPC
scp -r workflows/[name_of_wf] <user>@clogin01.sph.emory.edu:/projects/epimodel/[user name]/[your project name]/workflows/
Step 5 - check that your copying worked
ls -lh workflows
git pull
now as wellStep 6 - submit batch job
chmod +x workflows/[name_of_wf]/start_workflow.sh
./workflows/[name_of_wf]/start_workflow.sh