Created
May 16, 2018 21:50
-
-
Save benfasoli/134d0008f278c57da4b89cf1a9d6ca7a to your computer and use it in GitHub Desktop.
Wait for rslurm::slurm_apply to complete
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
# 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