sbatch: assert types to avoid silent parse errors

This commit is contained in:
Rodrigo Arias Mallo 2021-03-19 16:37:31 +01:00
parent 9c8282362a
commit 87fa3bb336
2 changed files with 31 additions and 1 deletions

13
NOISE
View File

@ -120,5 +120,18 @@ ABSTRACT
we build within Nix, they will be copied with the current data and
consequently not updated during the Nix compilation process.
1.9 Sbatch silently fails on parsing
When submitting a job with a wrong specification in MN4 with SLURM
17.11.9-2, for example this bogus line:
#SBATCH --nodes=1 2
It silently fails to parse the options, falling back to the defaults,
without any error.
We have improved our checking to detect bogus options passed to SLURM,
so we prevent this problem from happening.
/* vim: set ts=2 sw=2 tw=72 fo=watqc expandtab spell autoindent: */

View File

@ -22,7 +22,6 @@
, time ? null
, output ? "stdout.log"
, error ? "stderr.log"
, contiguous ? null
, extra ? null
, acctgFreq ? null
}:
@ -30,6 +29,24 @@
with stdenv.lib;
with garlicTools;
# sbatch fails silently if we pass garbage, so we assert the types here to avoid
# sending `nodes = [ 1 2 ]` by mistake.
assert (jobName != null) -> isString jobName;
assert (chdir != null) -> isString chdir;
assert (nixPrefix != null) -> isString nixPrefix;
assert (ntasks != null) -> isInt ntasks;
assert (ntasksPerNode != null) -> isInt ntasksPerNode;
assert (ntasksPerSocket != null) -> isInt ntasksPerSocket;
assert (cpusPerTask != null) -> isInt cpusPerTask;
assert (nodes != null) -> isInt nodes;
assert (exclusive != null) -> isBool exclusive;
assert (qos != null) -> isString qos;
assert (reservation != null) -> isString reservation;
assert (time != null) -> isString time;
assert (output != null) -> isString output;
assert (error != null) -> isString error;
assert (extra != null) -> isString extra;
let
sbatchOpt = name: value: optionalString (value!=null)