Skip to content

Instantly share code, notes, and snippets.

@benfasoli
Created May 16, 2018 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benfasoli/134d0008f278c57da4b89cf1a9d6ca7a to your computer and use it in GitHub Desktop.
Save benfasoli/134d0008f278c57da4b89cf1a9d6ca7a to your computer and use it in GitHub Desktop.
Wait for rslurm::slurm_apply to complete
# Ben Fasoli
# Wait for rslurm::slurm_apply to complete
library(rslurm)
fun <- function(x) {
Sys.sleep(x)
return(T)
}
slurm_options <- list(
time = '300:00:00',
account = 'lin-kp',
partition = 'lin-kp'
)
output <- slurm_apply(fun, data.frame(x = c(5, 10)), nodes = 1,
cpus_per_node = 2, slurm_options = slurm_options)
wait_for_slurm <- function(slr_job) {
cmd <- paste('squeue -hn', slr_job$jobname)
while (length(system(cmd, intern = T)) > 0) {
Sys.sleep(1)
}
}
wait_for_slurm(output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment