EpiModel / EpiModeling

Tutorials for Using the EpiModel Software Platform for Research
4 stars 2 forks source link

Emeli's steps for using workflows #9

Closed ejanderson1 closed 2 years ago

ejanderson1 commented 2 years ago

Overview:

Before you begin

Step 1 - create workflow script

Step 2 - run workflow script

Step 3 - create wf directory on HPC

Step 4 - copy wf files to HPC

Step 5 - check that your copying worked

Step 6 - submit batch job

  1. Then: ./workflows/[name_of_wf]/start_workflow.sh
ejanderson1 commented 2 years ago

Notes on re-running a workflow

(i.e., if you want to make changes to workflow script and resubmit it)

ejanderson1 commented 2 years ago

Creating a workflow script

Step 1 - setup:

# 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

Step 2 - create workflow

wf <- create_workflow(
  wf_name = "test",
  default_sbatch_opts = hpc_configs$default_sbatch_opts
)

Step 3 - add a wf step to update renv on the HPC

Step 4 - specify your sims

Step 5 - specify your scenarios

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