aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2024-10-07 15:51:48 +0100
committerArun Isaac2024-10-07 16:02:35 +0100
commit394dca860e767df69562f3e5afa3ec3c588afbaa (patch)
tree5aac56fd24bd528232e273395d5bccba44c2ed39
parent454a0ff7744963433c03ab813cf9309be5c6b0a9 (diff)
downloadravanan-394dca860e767df69562f3e5afa3ec3c588afbaa.tar.gz
ravanan-394dca860e767df69562f3e5afa3ec3c588afbaa.tar.lz
ravanan-394dca860e767df69562f3e5afa3ec3c588afbaa.zip
bin: Pass manifest file paths, not manifests to other functions.
* bin/ravanan: Move to (ravanan command-line-tool). Add comment about declarative modules. (main): Pass manifest file path to run-workflow. * ravanan/command-line-tool.scm (run-command-line-tool, build-command-line-tool-script): Accept manifest file path instead of manifest. * ravanan/workflow.scm (workflow-scheduler, run-workflow): Accept manifest file path instead of manifest.
-rwxr-xr-xbin/ravanan26
-rw-r--r--ravanan/command-line-tool.scm40
-rw-r--r--ravanan/workflow.scm10
3 files changed, 40 insertions, 36 deletions
diff --git a/bin/ravanan b/bin/ravanan
index 19bb8b5..cc9005d 100755
--- a/bin/ravanan
+++ b/bin/ravanan
@@ -97,27 +97,6 @@ files that have the token in the @verbatim{SLURM_JWT=token} format."
string-trim-both
get-string-all)))
-(define (load-manifest manifest-file)
- "Load manifest from @var{manifest-file} and return it."
- ;; We load the manifest file into a dummy module of its own so that any
- ;; definitions from there don't leak out. We also ensure that this dummy
- ;; module is different for different manifest files so that definitions from
- ;; one manifest file don't leak into other manifest files.
- (let ((manifest-file-path (canonicalize-file-name manifest-file))
- (manifest-module (resolve-module (match (file-name-split manifest-file-path)
- (("" parts ...)
- (map string->symbol parts))))))
- ;; Import modules required for loading manifests.
- (for-each (lambda (module-name)
- (module-use! manifest-module (resolve-interface module-name)))
- '((guile)
- (gnu packages)
- (guix profiles)))
- (save-module-excursion
- (lambda ()
- (set-current-module manifest-module)
- (load manifest-file-path)))))
-
(define main
(match-lambda
((program args ...)
@@ -151,9 +130,8 @@ files that have the token in the @verbatim{SLURM_JWT=token} format."
;; We must not try to compile guix manifest files.
(set! %load-should-auto-compile #f)
(scm->json (run-workflow (file-name-stem workflow-file)
- (load-manifest
- (canonicalize-path
- (assq-ref args 'guix-manifest-file)))
+ (canonicalize-path
+ (assq-ref args 'guix-manifest-file))
(read-workflow workflow-file)
(read-inputs inputs-file)
(case (assq-ref args 'batch-system)
diff --git a/ravanan/command-line-tool.scm b/ravanan/command-line-tool.scm
index 54a92cf..19f3703 100644
--- a/ravanan/command-line-tool.scm
+++ b/ravanan/command-line-tool.scm
@@ -367,19 +367,19 @@ path."
(string-append (basename script) ".stderr"))
store))
-(define* (run-command-line-tool name manifest cwl inputs
+(define* (run-command-line-tool name manifest-file cwl inputs
scratch store batch-system
#:key guix-daemon-socket
slurm-api-endpoint slurm-jwt)
"Run @code{CommandLineTool} class workflow @var{cwl} named @var{name} with
-@var{inputs} using tools from Guix @var{manifest}.
+@var{inputs} using tools from Guix manifest in @var{manifest-file}.
@var{scratch}, @var{store}, @var{batch-system}, @var{guix-daemon-socket},
@var{slurm-api-endpoint} and @var{slurm-jwt} are the same as in
@code{run-workflow} from @code{(ravanan workflow)}."
;; TODO: Write to the store atomically.
(let* ((script
- (build-command-line-tool-script name manifest cwl inputs
+ (build-command-line-tool-script name manifest-file cwl inputs
scratch store batch-system
guix-daemon-socket))
(requirements (inherit-requirements (or (assoc-ref cwl "requirements")
@@ -547,12 +547,37 @@ maybe-monadic value."
class))
requirements))
-(define (build-command-line-tool-script name manifest cwl inputs
+(define (load-manifest manifest-file)
+ "Load Guix manifest from @var{manifest-file} and return it."
+ ;; We load the manifest file into a dummy module of its own so that any
+ ;; definitions from there don't leak into this module. We also ensure that
+ ;; this dummy module is different for different manifest files so that
+ ;; definitions from one manifest file don't leak into other manifest files.
+ (let ((manifest-module
+ (resolve-module (match (file-name-split (canonicalize-file-name manifest-file))
+ (("" parts ...)
+ (map string->symbol parts))))))
+ ;; Import modules required for loading manifests.
+ (for-each (lambda (module-name)
+ (module-use! manifest-module (resolve-interface module-name)))
+ '((guile)
+ (gnu packages)
+ (guix profiles)))
+ (save-module-excursion
+ (lambda ()
+ (set-current-module manifest-module)
+ ;; Our use of load triggers a "Add #:declarative? #f to your
+ ;; define-module invocation" warning during compilation. But, it is
+ ;; probably safe to ignore this warning since we use load only within a
+ ;; dummy module.
+ (load (canonicalize-path manifest-file))))))
+
+(define (build-command-line-tool-script name manifest-file cwl inputs
scratch store batch-system
guix-daemon-socket)
"Build and return script to run @code{CommandLineTool} class workflow @var{cwl}
-named @var{name} with @var{inputs} using tools from Guix manifest
-@var{manifest} and on @var{batch-system}.
+named @var{name} with @var{inputs} using tools from Guix manifest in
+@var{manifest-file} and on @var{batch-system}.
@var{scratch}, @var{store} and @var{guix-daemon-socket} are the same as in
@code{run-workflow} from @code{(ravanan workflow)}."
@@ -706,7 +731,8 @@ named @var{name} with @var{inputs} using tools from Guix manifest
(or (assoc-ref cwl "hints")
#())))
(initial-work-dir-requirement (find-requirement requirements
- "InitialWorkDirRequirement")))
+ "InitialWorkDirRequirement"))
+ (manifest (load-manifest manifest-file)))
(with-imported-modules (source-module-closure '((ravanan work command-line-tool)
(ravanan work monads)
(ravanan work ui)
diff --git a/ravanan/workflow.scm b/ravanan/workflow.scm
index 42fa349..95dfb73 100644
--- a/ravanan/workflow.scm
+++ b/ravanan/workflow.scm
@@ -245,7 +245,7 @@ propagator."
merge-values
scheduler))
-(define* (workflow-scheduler manifest scratch store batch-system
+(define* (workflow-scheduler manifest-file scratch store batch-system
#:key guix-daemon-socket
slurm-api-endpoint slurm-jwt)
(define (schedule proc inputs scheduler)
@@ -290,7 +290,7 @@ job state object. @var{proc} may either be a @code{<propnet>} object or a
((string=? class "CommandLineTool")
(command-line-tool-state
(run-command-line-tool name
- manifest
+ manifest-file
cwl
inputs
scratch
@@ -570,12 +570,12 @@ error out."
formal-inputs))
formal-inputs))
-(define* (run-workflow name manifest cwl inputs
+(define* (run-workflow name manifest-file cwl inputs
scratch store batch-system
#:key guix-daemon-socket
slurm-api-endpoint slurm-jwt)
"Run a workflow @var{cwl} named @var{name} with @var{inputs} using
-tools from Guix @var{manifest}.
+tools from Guix manifest in @var{manifest-file}.
@var{scratch} is the path to the scratch area on all worker nodes. The
scratch area need not be shared. @var{store} is the path to the shared
@@ -591,7 +591,7 @@ authenticate to the slurm API with. @var{slurm-api-endpoint} and
@var{slurm-jwt} are only used when @var{batch-system} is
@code{'slurm-api}."
(let ((scheduler (workflow-scheduler
- manifest scratch store batch-system
+ manifest-file scratch store batch-system
#:guix-daemon-socket guix-daemon-socket
#:slurm-api-endpoint slurm-api-endpoint
#:slurm-jwt slurm-jwt)))