From d5fd734513671d957c20a66655c98d325bb1760f Mon Sep 17 00:00:00 2001 From: Justin Bedo Date: Thu, 16 May 2019 21:18:27 +1000 Subject: slurm: renamed from sbatch --- default.nix | 8 ++++---- lib/sbatch.nix | 28 ---------------------------- lib/slurm.nix | 28 ++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 32 deletions(-) delete mode 100644 lib/sbatch.nix create mode 100644 lib/slurm.nix diff --git a/default.nix b/default.nix index 575d176..15b8d87 100644 --- a/default.nix +++ b/default.nix @@ -36,10 +36,10 @@ let ascat = callBionix ./tools/ascat.nix {}; fastp = callBionix ./tools/fastp.nix {}; - sbatch = attrs: bionix.extend (self: super: with self; rec { - sbatchDefs = { ppn = 1; mem = 1; walltime = "24:00:00"; partition = null; slurmFlags = null; } // attrs; - sbatch = attrs: (callPackage ./lib/sbatch.nix {}) (sbatchDefs // attrs); - exec = f: x: y: sbatch (builtins.intersectAttrs sbatchDefs x) (f (builtins.removeAttrs x (builtins.attrNames sbatchDefs)) y); + slurm = attrs: bionix.extend (self: super: with self; rec { + slurmDefs = { ppn = 1; mem = 1; walltime = "24:00:00"; partition = null; slurmFlags = null; } // attrs; + slurm = attrs: (callPackage ./lib/slurm.nix {}) (slurmDefs // attrs); + exec = f: x: y: slurm (builtins.intersectAttrs slurmDefs x) (f (builtins.removeAttrs x (builtins.attrNames slurmDefs)) y); }); qsub = attrs: bionix.extend (self: super: with self; rec { qsubDefs = { ppn = 1; mem = 1; walltime = "24:00:00"; tmpDir = "/tmp"; sleepTime = 60; queue = null; qsubFlags = null; } // attrs; diff --git a/lib/sbatch.nix b/lib/sbatch.nix deleted file mode 100644 index d52c23e..0000000 --- a/lib/sbatch.nix +++ /dev/null @@ -1,28 +0,0 @@ -{stdenv, lib, writeScript, coreutils}: - -with lib; - -{ ppn, mem, walltime, partition ? null, slurmFlags ? null, salloc ? "/usr/bin/salloc" }: -drv: - let ppnReified = if drv.multicore then ppn else 1; - in lib.overrideDerivation drv ({ args, builder, name, ... }: { - builder = stdenv.shell; - args = let - script = writeScript "sbatch-script" '' - #!${stdenv.shell} - ${builder} ${lib.escapeShellArgs args} - ''; - - sbatch = writeScript "sbatch" '' - #!${stdenv.shell} - NIX_BUILD_CORES=${toString ppnReified} - - ${salloc} -c $NIX_BUILD_CORES --mem=${toString mem}G -t ${walltime} \ - -J "${name}" \ - ${optionalString (partition != null) "-p ${partition}"} \ - ${optionalString (slurmFlags != null) slurmFlags} \ - ${script} - ''; - - in [ "-c" sbatch ]; - }) diff --git a/lib/slurm.nix b/lib/slurm.nix new file mode 100644 index 0000000..daca4af --- /dev/null +++ b/lib/slurm.nix @@ -0,0 +1,28 @@ +{stdenv, lib, writeScript, coreutils}: + +with lib; + +{ ppn, mem, walltime, partition ? null, slurmFlags ? null, salloc ? "/usr/bin/salloc" }: +drv: + let ppnReified = if drv.multicore then ppn else 1; + in lib.overrideDerivation drv ({ args, builder, name, ... }: { + builder = stdenv.shell; + args = let + script = writeScript "slurm-script" '' + #!${stdenv.shell} + ${builder} ${lib.escapeShellArgs args} + ''; + + slurm = writeScript "slurm" '' + #!${stdenv.shell} + NIX_BUILD_CORES=${toString ppnReified} + + ${salloc} -c $NIX_BUILD_CORES --mem=${toString mem}G -t ${walltime} \ + -J "${name}" \ + ${optionalString (partition != null) "-p ${partition}"} \ + ${optionalString (slurmFlags != null) slurmFlags} \ + ${script} + ''; + + in [ "-c" slurm ]; + }) -- cgit v1.2.3