From 203cf27a4d14e25df6203c3da10b16c87883c6c5 Mon Sep 17 00:00:00 2001 From: Toby Dylan Hocking Date: Mon, 9 Dec 2019 11:25:51 -0700 Subject: [PATCH 1/5] install/setup slurm --- .travis.yml | 15 ++++++++++++- inst/conf/slurm.conf | 53 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 inst/conf/slurm.conf diff --git a/.travis.yml b/.travis.yml index a708a663..d024bc17 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ dist: trusty -sudo: false +sudo: true language: r cache: packages @@ -13,6 +13,7 @@ addons: packages: - libopenmpi-dev - openmpi-bin + - slurm-llnl r: - oldrel @@ -23,5 +24,17 @@ r_packages: - covr - Rmpi +script: + - sudo cp inst/conf/slurm.conf /etc/slurm-llnl + - cp batchtools.conf.R tests/testthat + - 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.conf b/inst/conf/slurm.conf new file mode 100644 index 00000000..19821a64 --- /dev/null +++ b/inst/conf/slurm.conf @@ -0,0 +1,53 @@ +# 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 From 65b9d4a0b97d13404dae142bbf968722abbb9a41 Mon Sep 17 00:00:00 2001 From: Toby Dylan Hocking Date: Mon, 9 Dec 2019 11:26:14 -0700 Subject: [PATCH 2/5] ignore *~ --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c2e0b0f5..b241b1d6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +*~ .DS_Store /inst/doc /src/*.so From a3c1df0bbaa178ae67c5ffe79febbe90b26d1053 Mon Sep 17 00:00:00 2001 From: Toby Dylan Hocking Date: Mon, 9 Dec 2019 11:26:51 -0700 Subject: [PATCH 3/5] slurm test for directory with spaces/parens --- inst/conf/slurm.R | 4 ++++ tests/testthat/test_slurm.R | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 inst/conf/slurm.R create mode 100644 tests/testthat/test_slurm.R diff --git a/inst/conf/slurm.R b/inst/conf/slurm.R new file mode 100644 index 00000000..36163188 --- /dev/null +++ b/inst/conf/slurm.R @@ -0,0 +1,4 @@ +cluster.functions = makeClusterFunctionsSlurm(system.file( + file.path("templates", "slurm-simple.tmpl"), + package="batchtools", + mustWork=TRUE)) 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) +}) + From 8d82dda089f565b60b532eabdcde319e632c1839 Mon Sep 17 00:00:00 2001 From: Toby Dylan Hocking Date: Mon, 9 Dec 2019 14:05:53 -0700 Subject: [PATCH 4/5] not trustry --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d024bc17..1125532f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,3 @@ -dist: trusty sudo: true language: r cache: packages @@ -26,7 +25,6 @@ r_packages: script: - sudo cp inst/conf/slurm.conf /etc/slurm-llnl - - cp batchtools.conf.R tests/testthat - sudo service munge start - sudo /etc/init.d/slurmctld restart - sudo /etc/init.d/slurmd restart From 62ae838da98cb2efbcae5673e47d61b6f0929a12 Mon Sep 17 00:00:00 2001 From: Toby Dylan Hocking Date: Mon, 9 Dec 2019 14:55:44 -0700 Subject: [PATCH 5/5] shQuote(log.file) --- .gitignore | 1 + inst/conf/slurm.R | 1 + inst/conf/slurm.conf | 2 ++ inst/templates/slurm-dortmund.tmpl | 2 +- inst/templates/slurm-lido3.tmpl | 3 +++ inst/templates/slurm-simple.tmpl | 2 +- 6 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index b241b1d6..7fefa213 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.Rhistory *~ .DS_Store /inst/doc diff --git a/inst/conf/slurm.R b/inst/conf/slurm.R index 36163188..788e3cb5 100644 --- a/inst/conf/slurm.R +++ b/inst/conf/slurm.R @@ -1,3 +1,4 @@ +## this is used in tests/testthat/test_slurm.R cluster.functions = makeClusterFunctionsSlurm(system.file( file.path("templates", "slurm-simple.tmpl"), package="batchtools", diff --git a/inst/conf/slurm.conf b/inst/conf/slurm.conf index 19821a64..69d6ae58 100644 --- a/inst/conf/slurm.conf +++ b/inst/conf/slurm.conf @@ -1,3 +1,5 @@ +# 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. 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)) -%>