summary refs log tree commit diff
diff options
context:
space:
mode:
authorArun Isaac2024-10-09 23:35:10 +0100
committerArun Isaac2024-10-10 01:56:57 +0100
commit552919ee626a0c8ca3d6c43f7e771803d475d0db (patch)
tree9b4ba779ba049ee48e411e6e4ac03b353ebe55d0
parentbe8611f5274c01832e1d43886eef434b239cd69e (diff)
downloadravanan-552919ee626a0c8ca3d6c43f7e771803d475d0db.tar.gz
ravanan-552919ee626a0c8ca3d6c43f7e771803d475d0db.tar.lz
ravanan-552919ee626a0c8ca3d6c43f7e771803d475d0db.zip
slurm-api: Allow requesting for a nice adjustment.
* ravanan/batch-system.scm (<slurm-api-batch-system>)[nice]: Add
field.
* bin/ravanan (%options): Add slurm-nice.
(print-usage): Document it.
(main): Initialize nice field of <slurm-api-batch-system> object.
* ravanan/command-line-tool.scm (run-command-line-tool): Pass
#:nice argument to submit-job.
* ravanan/slurm-api.scm (submit-job): Accept #:nice argument.
-rwxr-xr-xbin/ravanan8
-rw-r--r--ravanan/batch-system.scm8
-rw-r--r--ravanan/command-line-tool.scm3
-rw-r--r--ravanan/slurm-api.scm19
4 files changed, 25 insertions, 13 deletions
diff --git a/bin/ravanan b/bin/ravanan
index 2bcf0db..eed7167 100755
--- a/bin/ravanan
+++ b/bin/ravanan
@@ -60,6 +60,10 @@ exec guile --no-auto-compile -e main -s "$0" "$@"
         (option (list "slurm-partition") #t #f
                 (lambda (opt name arg result)
                   (acons 'slurm-partition arg result)))
+        (option (list "slurm-nice") #t #f
+                (lambda (opt name arg result)
+                  (acons 'slurm-nice (string->number arg)
+                         result)))
         (option (list "help") #f #t
                 (lambda (opt name arg result)
                   (acons 'help #t result)))))
@@ -89,6 +93,7 @@ Slurm API batch system options:
   --slurm-api-endpoint=SLURM-API-ENDPOINT    slurm API endpoint to connect to
   --slurm-jwt=SLURM-JWT                      slurm JWT to authenticate with
   --slurm-partition=SLURM-PARTITION          slurm partition to request
+  --slurm-nice=SLURM-NICE                    slurm job priority adjustment
 "
           program))
 
@@ -157,7 +162,8 @@ files that have the token in the @verbatim{SLURM_JWT=token} format."
                                        (assq-ref args 'slurm-api-endpoint)
                                        (and (assq-ref args 'slurm-jwt)
                                             (read-jwt (assq-ref args 'slurm-jwt)))
-                                       (assq-ref args 'slurm-partition))))
+                                       (assq-ref args 'slurm-partition)
+                                       (assq-ref args 'slurm-nice))))
                                    #:guix-daemon-socket (assq-ref args 'guix-daemon-socket))
                      (current-output-port)
                      #:pretty #t)
diff --git a/ravanan/batch-system.scm b/ravanan/batch-system.scm
index 830b3a0..b5ead4c 100644
--- a/ravanan/batch-system.scm
+++ b/ravanan/batch-system.scm
@@ -22,11 +22,13 @@
             slurm-api-batch-system?
             slurm-api-batch-system-endpoint
             slurm-api-batch-system-jwt
-            slurm-api-batch-system-partition))
+            slurm-api-batch-system-partition
+            slurm-api-batch-system-nice))
 
 (define-immutable-record-type <slurm-api-batch-system>
-  (slurm-api-batch-system endpoint jwt partition)
+  (slurm-api-batch-system endpoint jwt partition nice)
   slurm-api-batch-system?
   (endpoint slurm-api-batch-system-endpoint)
   (jwt slurm-api-batch-system-jwt)
-  (partition slurm-api-batch-system-partition))
+  (partition slurm-api-batch-system-partition)
+  (nice slurm-api-batch-system-nice))
diff --git a/ravanan/command-line-tool.scm b/ravanan/command-line-tool.scm
index eaaf90b..cc6d0ab 100644
--- a/ravanan/command-line-tool.scm
+++ b/ravanan/command-line-tool.scm
@@ -448,7 +448,8 @@ the same as in @code{run-workflow} from @code{(ravanan workflow)}."
                                        script
                                        #:api-endpoint (slurm-api-batch-system-endpoint batch-system)
                                        #:jwt (slurm-api-batch-system-jwt batch-system)
-                                       #:partition (slurm-api-batch-system-partition batch-system))))
+                                       #:partition (slurm-api-batch-system-partition batch-system)
+                                       #:nice (slurm-api-batch-system-nice batch-system))))
                (format (current-error-port)
                        "~a submitted as job ID ~a~%"
                        script
diff --git a/ravanan/slurm-api.scm b/ravanan/slurm-api.scm
index 5d9b660..fa5614e 100644
--- a/ravanan/slurm-api.scm
+++ b/ravanan/slurm-api.scm
@@ -63,15 +63,15 @@ document and pass in as the body of the HTTP request."
                               (cut scm->json body-scm <>))))
 
 (define* (submit-job environment stdout-file stderr-file cpus name script
-                     #:key api-endpoint jwt partition)
+                     #:key api-endpoint jwt partition nice)
   "Submit job named @var{name} running @var{script} to slurm via @var{api-endpoint}
-and authenticating using @var{jwt}. Request slurm @var{partition} if it is not
-@code{#f}. @var{environment} is an association list of environment variables to
-set in the job. @var{stdout-file} and @var{stderr-file} are files in which to
-write the stdout and stderr of the job respectively. @var{cpus} is the number of
-CPUs (in slurm terminology, a CPU is a hyperthread; see
-@url{https://slurm.schedmd.com/faq.html#cpu_count, the Slurm FAQ}) to request
-for the job."
+and authenticating using @var{jwt}. Request slurm @var{partition} and @var{nice}
+adjustment if they are not @code{#f}. @var{environment} is an association list
+of environment variables to set in the job. @var{stdout-file} and
+@var{stderr-file} are files in which to write the stdout and stderr of the job
+respectively. @var{cpus} is the number of CPUs (in slurm terminology, a CPU is a
+hyperthread; see @url{https://slurm.schedmd.com/faq.html#cpu_count, the Slurm
+FAQ}) to request for the job."
   (define job-spec
     (append `(("name" . ,name)
               ("script" . ,(string-append "#!/bin/bash\n" script))
@@ -86,6 +86,9 @@ for the job."
               ("minimum_cpus" . ,cpus))
             (if partition
                 `(("partition" . ,partition))
+                '())
+            (if nice
+                `(("nice" . ,nice))
                 '())))
   
   (let ((response (slurm-http-post api-endpoint