diff --git a/.gitignore b/.gitignore index c2e0b0f5..7fefa213 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +.Rhistory +*~ .DS_Store /inst/doc /src/*.so diff --git a/.travis.yml b/.travis.yml index a708a663..1125532f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ -dist: trusty -sudo: false +sudo: true language: r cache: packages @@ -13,6 +12,7 @@ addons: packages: - libopenmpi-dev - openmpi-bin + - slurm-llnl r: - oldrel @@ -23,5 +23,16 @@ r_packages: - covr - Rmpi +script: + - sudo cp inst/conf/slurm.conf /etc/slurm-llnl + - sudo service munge start + - sudo /etc/init.d/slurmctld restart + - sudo /etc/init.d/slurmd restart + - sinfo + - R CMD build . + - R CMD check *tar.gz + after_success: - if [[ "${TRAVIS_R_VERSION_STRING}" == "release" ]]; then Rscript -e 'covr::coveralls()'; fi + + \ No newline at end of file diff --git a/inst/conf/slurm.R b/inst/conf/slurm.R new file mode 100644 index 00000000..788e3cb5 --- /dev/null +++ b/inst/conf/slurm.R @@ -0,0 +1,5 @@ +## this is used in tests/testthat/test_slurm.R +cluster.functions = makeClusterFunctionsSlurm(system.file( + file.path("templates", "slurm-simple.tmpl"), + package="batchtools", + mustWork=TRUE)) diff --git a/inst/conf/slurm.conf b/inst/conf/slurm.conf new file mode 100644 index 00000000..69d6ae58 --- /dev/null +++ b/inst/conf/slurm.conf @@ -0,0 +1,55 @@ +# this file is used in tests/testthat/test_slurm.R + +# slurm.conf file generated by configurator easy.html. +# Put this file on all nodes of your cluster. +# See the slurm.conf man page for more information. +# +ControlMachine=localhost +#ControlAddr= +# +#MailProg=/bin/mail +MpiDefault=none +#MpiParams=ports=#-# +ProctrackType=proctrack/pgid +ReturnToService=1 +SlurmctldPidFile=/var/run/slurm-llnl/slurmctld.pid +#SlurmctldPort=6817 +SlurmdPidFile=/var/run/slurm-llnl/slurmd.pid +#SlurmdPort=6818 +SlurmdSpoolDir=/var/lib/slurm-llnl/slurmd +SlurmUser=slurm +#SlurmdUser=root +StateSaveLocation=/var/lib/slurm-llnl/slurmctld +SwitchType=switch/none +TaskPlugin=task/none +# +# +# TIMERS +#KillWait=30 +#MinJobAge=300 +#SlurmctldTimeout=120 +#SlurmdTimeout=300 +# +# +# SCHEDULING +FastSchedule=1 +SchedulerType=sched/backfill +SchedulerParameters=kill_invalid_depend +#SchedulerPort=7321 +SelectType=select/linear +# +# +# LOGGING AND ACCOUNTING +AccountingStorageType=accounting_storage/none +ClusterName=cluster +#JobAcctGatherFrequency=30 +JobAcctGatherType=jobacct_gather/none +#SlurmctldDebug=3 +SlurmctldLogFile=/var/log/slurm-llnl/slurmctld.log +#SlurmdDebug=3 +SlurmdLogFile=/var/log/slurm-llnl/slurmd.log +# +# +# COMPUTE NODES +NodeName=localhost CPUs=1 State=UNKNOWN +PartitionName=debug Nodes=localhost Default=YES MaxTime=INFINITE State=UP \ No newline at end of file diff --git a/inst/templates/slurm-dortmund.tmpl b/inst/templates/slurm-dortmund.tmpl index d81d265c..d63a78e8 100644 --- a/inst/templates/slurm-dortmund.tmpl +++ b/inst/templates/slurm-dortmund.tmpl @@ -14,7 +14,7 @@ if (backend == "mpi") { } # relative paths are not handled well by Slurm -log.file = fs::path_expand(log.file) +log.file = shQuote(fs::path_expand(log.file)) -%> #SBATCH --job-name=<%= job.name %> diff --git a/inst/templates/slurm-lido3.tmpl b/inst/templates/slurm-lido3.tmpl index 5c1f4532..f79bfc79 100644 --- a/inst/templates/slurm-lido3.tmpl +++ b/inst/templates/slurm-lido3.tmpl @@ -16,6 +16,9 @@ <% +# relative paths are not handled well by Slurm +log.file = shQuote(fs::path_expand(log.file)) + # queue walltime = asInt(resources$walltime, lower = 60L, upper = 31L * 24L * 60L * 60L) memory = asInt(resources$memory, lower = 100L, upper = 1024L * 1024L) diff --git a/inst/templates/slurm-simple.tmpl b/inst/templates/slurm-simple.tmpl index 4fb0a4ab..754e83b9 100644 --- a/inst/templates/slurm-simple.tmpl +++ b/inst/templates/slurm-simple.tmpl @@ -19,7 +19,7 @@ <% # relative paths are not handled well by Slurm -log.file = fs::path_expand(log.file) +log.file = shQuote(fs::path_expand(log.file)) -%> diff --git a/tests/testthat/test_slurm.R b/tests/testthat/test_slurm.R new file mode 100644 index 00000000..943f2de3 --- /dev/null +++ b/tests/testthat/test_slurm.R @@ -0,0 +1,32 @@ +if(interactive())library(testthat) +if(interactive())library(batchtools) +context("slurm") + +conf.file <- system.file( + "conf", "slurm.R", package="batchtools", mustWork=TRUE) +res.list <- list( + walltime = 3600, #in seconds. + ncpus=1, + ntasks=1) +sinResult <- function(reg.name){ + reg.path <- file.path(tempdir(), reg.name) + unlink(reg.path, recursive=TRUE) + reg <- makeRegistry(reg.path, conf.file=conf.file) + batchMap(sin, c(0, pi/2), reg=reg) + submitJobs(resources=res.list, reg=reg) + waitForJobs(reg=reg) + st <- getJobStatus(reg=reg) + sapply(st$job.id, loadResult) +} +expected <- c(0, 1) + +test_that("registry with NO spaces/parens works on slurm", { + computed <- sinResult("reg") + expect_equal(computed, expected) +}) + +test_that("registry WITH spaces/parens works on slurm", { + computed <- sinResult("reg (!)") + expect_equal(computed, expected) +}) +