sbatch: assert types to avoid silent parse errors

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

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)