From 5e2c7c85d001fde0600e77bfbd9d1078fcd561f4 Mon Sep 17 00:00:00 2001 From: Justin Bedo Date: Wed, 6 Feb 2019 10:18:20 +1100 Subject: qsub: parameterise queue and allow arbitrary flags to be passed --- default.nix | 2 +- lib/qsub.nix | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/default.nix b/default.nix index f3a582b..bd68277 100644 --- a/default.nix +++ b/default.nix @@ -32,7 +32,7 @@ let strelka = callBionix ./tools/strelka.nix {}; qsub = attrs: bionix.extend (self: super: with self; rec { - qsubDefs = { ppn = 1; mem = 1; walltime = "24:00:00"; tmpDir = "/tmp"; sleepTime = 60; } // attrs; + qsubDefs = { ppn = 1; mem = 1; walltime = "24:00:00"; tmpDir = "/tmp"; sleepTime = 60; queue = null; flags = null; } // attrs; qsub = attrs: (callPackage ./lib/qsub.nix {}) (qsubDefs // attrs); exec = f: x: y: qsub (builtins.intersectAttrs qsubDefs x) (f (builtins.removeAttrs x (builtins.attrNames qsubDefs)) y); }); diff --git a/lib/qsub.nix b/lib/qsub.nix index 53e5780..85036fb 100644 --- a/lib/qsub.nix +++ b/lib/qsub.nix @@ -1,6 +1,8 @@ {stdenv, lib, writeScript}: -{ ppn, mem, walltime, tmpDir, sleepTime}: drv: lib.overrideDerivation drv ({ args, builder, name, ... }: { +with lib; + +{ ppn, mem, walltime, queue ? null, flags ? null, tmpDir, sleepTime}: drv: lib.overrideDerivation drv ({ args, builder, name, ... }: { builder = "/bin/bash"; args = let script = writeScript "qsub-script" '' @@ -27,7 +29,11 @@ NIX_BUILD_CORES=${toString ppn} while : ; do - qsub -l nodes=1:ppn=${toString ppn},mem=${toString mem}gb,walltime=${walltime} -N "${name}" ${script} 2>&1 > id + qsub -l nodes=1:ppn=${toString ppn},mem=${toString mem}gb,walltime=${walltime} \ + -N "${name}" \ + ${optionalString (queue != null) "-q ${queue}"} \ + ${optionalString (flags != null) flags} \ + ${script} 2>&1 > id if [ $? -eq 0 ] ; then break fi -- cgit v1.2.3