aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2024-10-02 01:57:08 +0100
committerArun Isaac2024-10-02 02:14:57 +0100
commit998ffbd15af8884a48e6b6075fe2a5043d29b2bb (patch)
treeb34d6aabf538f4c980a4580a6a5f69e121aaa77a
parent1161e769e33e692bba48ea359725357c939612da (diff)
downloadravanan-998ffbd15af8884a48e6b6075fe2a5043d29b2bb.tar.gz
ravanan-998ffbd15af8884a48e6b6075fe2a5043d29b2bb.tar.lz
ravanan-998ffbd15af8884a48e6b6075fe2a5043d29b2bb.zip
command-line-tool: Support coresMin ResourceRequirement.
* ravanan/command-line-tool.scm: Import (ravanan reader). (%command-line-tool-supported-requirements): Add ResouceRequirement. (command-line-tool-supported-requirements): Remove ResourceRequirement for the single-machine batch system. * ravanan/command-line-tool.scm (run-command-line-tool): Request the number of CPUs specified in coresMin of the ResourceRequirement.
-rw-r--r--ravanan/command-line-tool.scm25
1 files changed, 22 insertions, 3 deletions
diff --git a/ravanan/command-line-tool.scm b/ravanan/command-line-tool.scm
index 2c48ca3..3357b05 100644
--- a/ravanan/command-line-tool.scm
+++ b/ravanan/command-line-tool.scm
@@ -37,6 +37,7 @@
#:use-module (guix store)
#:use-module (json)
#:use-module (ravanan job-state)
+ #:use-module (ravanan reader)
#:use-module (ravanan slurm-api)
#:use-module (ravanan work command-line-tool)
#:use-module (ravanan work monads)
@@ -69,10 +70,18 @@
(define %command-line-tool-supported-requirements
(list "EnvVarRequirement"
"InlineJavascriptRequirement"
- "InitialWorkDirRequirement"))
+ "InitialWorkDirRequirement"
+ "ResourceRequirement"))
(define (command-line-tool-supported-requirements batch-system)
- %command-line-tool-supported-requirements)
+ (case batch-system
+ ((single-machine)
+ (delete "ResourceRequirement"
+ %command-line-tool-supported-requirements))
+ ((slurm-api)
+ %command-line-tool-supported-requirements)
+ (else
+ (assertion-violation batch-system "Unknown batch system"))))
;; node executable for evaluating javascript on worker nodes
(define %worker-node
@@ -406,6 +415,16 @@ path."
(build-command-line-tool-script name manifest cwl inputs
scratch store batch-system
guix-daemon-socket))
+ (requirements (inherit-requirements (or (assoc-ref cwl "requirements")
+ #())
+ (or (assoc-ref cwl "hints")
+ #())))
+ (cpus (from-maybe
+ (maybe-let* ((cores-min (maybe-assoc-ref (find-requirement requirements
+ "ResourceRequirement")
+ "coresMin")))
+ (just (inexact->exact (ceiling (coerce-type cores-min 'number)))))
+ 1))
(store-files-directory (script->store-files-directory script store))
(store-data-file (script->store-data-file script store))
(stdout-file (script->store-stdout-file script store))
@@ -451,7 +470,7 @@ path."
,store-data-file))
stdout-file
stderr-file
- 1
+ cpus
name
script
#:api-endpoint slurm-api-endpoint