aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2025-06-26 14:09:17 +0100
committerArun Isaac2025-06-26 16:03:13 +0100
commit422e0175ce4518ecd9d3a71aba052db41e2895cf (patch)
tree3abc42942e0351c221464080c119ab382b64e7ba
parent514642029d9c0664c8d88935b3f853ae77fda111 (diff)
downloadravanan-422e0175ce4518ecd9d3a71aba052db41e2895cf.tar.gz
ravanan-422e0175ce4518ecd9d3a71aba052db41e2895cf.tar.lz
ravanan-422e0175ce4518ecd9d3a71aba052db41e2895cf.zip
workflow: Re-use single connection to the Guix daemon.
Re-using the connection improves performance and is cleaner than passing around the Guix daemon socket specification. * ravanan/command-line-tool.scm (manifest-file->environment, software-packages->environment, manifest->environment, build-command-line-tool-script, build-gexp-script): Work with store connection instead of the Guix daemon socket. * ravanan/workflow.scm: Import (guix store). (workflow->scheduler-proc, workflow-class->propnet): Work with store connection instead of the Guix daemon socket. (build-workflow): Pass a store connection, not the Guix daemon socket, to workflow->scheduler-proc.
-rw-r--r--ravanan/command-line-tool.scm92
-rw-r--r--ravanan/workflow.scm54
2 files changed, 69 insertions, 77 deletions
diff --git a/ravanan/command-line-tool.scm b/ravanan/command-line-tool.scm
index 45c6155..0a3953a 100644
--- a/ravanan/command-line-tool.scm
+++ b/ravanan/command-line-tool.scm
@@ -285,19 +285,14 @@ G-expressions are inserted."
(< (command-line-binding-position binding1)
(command-line-binding-position binding2))))))
-(define* (build-gexp-script name exp #:optional guix-daemon-socket)
- "Build script named @var{name} using G-expression @var{exp}.
-
-When @var{guix-daemon-socket} is provided, connect to that Guix daemon."
- (if guix-daemon-socket
- (parameterize ((%daemon-socket-uri guix-daemon-socket))
- (build-gexp-script name exp))
- (with-store store
- (run-with-store store
- (mlet %store-monad ((drv (gexp->script name exp)))
- (mbegin %store-monad
- (built-derivations (list drv))
- (return (derivation->output-path drv))))))))
+(define* (build-gexp-script name exp store)
+ "Build script named @var{name} using G-expression @var{exp}. Connect to the Guix
+daemon using @var{store}."
+ (run-with-store store
+ (mlet %store-monad ((drv (gexp->script name exp)))
+ (mbegin %store-monad
+ (built-derivations (list drv))
+ (return (derivation->output-path drv))))))
(define* (run-command-line-tool name script inputs resource-requirement
store batch-system)
@@ -440,11 +435,10 @@ maybe-monadic value."
(guix profiles))))
(raise-exception (manifest-file-error manifest-file))))
-(define (manifest-file->environment manifest-file inferior guix-daemon-socket)
+(define (manifest-file->environment manifest-file inferior store)
"Build @var{manifest-file} and return an association list of environment
-variables to set to use the built profile. Connect to the Guix daemon specified
-by @var{guix-daemon-socket}. Build manifest in @var{inferior} unless it is
-@code{#f}."
+variables to set to use the built profile. Connect to the Guix daemon using
+@var{store}. Build manifest in @var{inferior} unless it is @code{#f}."
(if inferior
(cut inferior-eval
`(begin
@@ -455,16 +449,12 @@ by @var{guix-daemon-socket}. Build manifest in @var{inferior} unless it is
(guix gexp)
(guix profiles))
- (define (build-derivation drv guix-daemon-socket)
- (if guix-daemon-socket
- (parameterize ((%daemon-socket-uri guix-daemon-socket))
- (build-derivation drv))
- (with-store store
- (run-with-store store
- (mlet %store-monad ((drv drv))
- (mbegin %store-monad
- (built-derivations (list drv))
- (return (derivation->output-path drv))))))))
+ (define (build-derivation drv)
+ (run-with-store store
+ (mlet %store-monad ((drv drv))
+ (mbegin %store-monad
+ (built-derivations (list drv))
+ (return (derivation->output-path drv))))))
;; Do not auto-compile manifest files.
(set! %load-should-auto-compile #f)
@@ -477,18 +467,17 @@ by @var{guix-daemon-socket}. Build manifest in @var{inferior} unless it is
(manifest-search-paths manifest)
(list (build-derivation
(profile-derivation manifest
- #:allow-collisions? #t)
- ,guix-daemon-socket))))))
+ #:allow-collisions? #t)))))))
<>)
(manifest->environment (load-manifest manifest-file)
- guix-daemon-socket)))
+ store)))
-(define (software-packages->environment packages inferior guix-daemon-socket)
+(define (software-packages->environment packages inferior store)
"Build a profile with @var{packages} and return an association list
of environment variables to set to use the built profile. @var{packages} is a
vector of @code{SoftwarePackage} assocation lists as defined in the CWL
-standard. Connect to the Guix daemon specified by @var{guix-daemon-socket}. Look
-up packages in @var{inferior} unless it is @code{#f}."
+standard. Connect to the Guix daemon using @var{store}. Look up packages in
+@var{inferior} unless it is @code{#f}."
(define (software-package->package-specification package)
(string-append (assoc-ref* package "package")
(from-maybe
@@ -498,7 +487,7 @@ up packages in @var{inferior} unless it is @code{#f}."
"")))
(define packages->environment
- (compose (cut manifest->environment <> guix-daemon-socket)
+ (compose (cut manifest->environment <> store)
packages->manifest))
(if inferior
@@ -517,20 +506,16 @@ up packages in @var{inferior} unless it is @code{#f}."
software-package->package-specification)
packages))))
-(define (manifest->environment manifest guix-daemon-socket)
+(define (manifest->environment manifest store)
"Build @var{manifest} and return an association list of environment
-variables to set to use the built profile. Connect to the Guix daemon specified
-by @var{guix-daemon-socket}."
- (define (build-derivation drv guix-daemon-socket)
- (if guix-daemon-socket
- (parameterize ((%daemon-socket-uri guix-daemon-socket))
- (build-derivation drv #f))
- (with-store store
- (run-with-store store
- (mlet %store-monad ((drv drv))
- (mbegin %store-monad
- (built-derivations (list drv))
- (return (derivation->output-path drv))))))))
+variables to set to use the built profile. Connect to the Guix daemon using
+@var{store}."
+ (define (build-derivation drv)
+ (run-with-store store
+ (mlet %store-monad ((drv drv))
+ (mbegin %store-monad
+ (built-derivations (list drv))
+ (return (derivation->output-path drv))))))
(map (match-lambda
((specification . value)
@@ -540,19 +525,18 @@ by @var{guix-daemon-socket}."
(manifest-search-paths manifest)
(list (build-derivation
(profile-derivation manifest
- #:allow-collisions? #t)
- guix-daemon-socket)))))
+ #:allow-collisions? #t))))))
(define (build-command-line-tool-script name manifest-file inferior cwl
scratch store batch-system
- guix-daemon-socket)
+ guix-store)
"Build and return script to run @code{CommandLineTool} class workflow @var{cwl}
named @var{name} using tools from Guix manifest in @var{manifest-file} and on
@var{batch-system}. Use @var{inferior} to build manifests, unless it is
-@code{#f}.
+@code{#f}. Connect to the Guix daemon using @var{guix-store}.
-@var{scratch}, @var{store} and @var{guix-daemon-socket} are the same as in
-@code{run-workflow} from @code{(ravanan workflow)}."
+@var{scratch} and @var{store} are the same as in @code{run-workflow} from
+@code{(ravanan workflow)}."
(define (environment-variables env-var-requirement)
(just (vector-map->list (lambda (environment-definition)
#~(list #$(assoc-ref* environment-definition
@@ -1026,4 +1010,4 @@ directory of the workflow."
#$scratch))
#$scratch)))
#$scratch)))))
- guix-daemon-socket))
+ guix-store))
diff --git a/ravanan/workflow.scm b/ravanan/workflow.scm
index 6f53ab2..5622eb9 100644
--- a/ravanan/workflow.scm
+++ b/ravanan/workflow.scm
@@ -28,6 +28,7 @@
#:use-module (ice-9 match)
#:use-module (web uri)
#:use-module (guix inferior)
+ #:use-module (guix store)
#:use-module (ravanan batch-system)
#:use-module (ravanan command-line-tool)
#:use-module (ravanan job-state)
@@ -182,7 +183,7 @@ requirements and hints of the step."
(define* (workflow->scheduler-proc name cwl scheduler
manifest-file inferior scratch store
- batch-system guix-daemon-socket
+ batch-system guix-store
#:optional
(scatter %nothing)
(scatter-method %nothing))
@@ -190,9 +191,9 @@ requirements and hints of the step."
scheduled using @var{scheduler}. @var{scatter} and @var{scatter-method} are the
CWL scattering properties of this step.
-@var{manifest-file}, @var{scratch}, @var{store}, @var{batch-system} and
-@var{guix-daemon-socket} are the same as in @code{run-workflow}. @var{inferior}
-is the same as in @code{build-command-line-tool-script} from @code{(ravanan
+@var{manifest-file}, @var{scratch}, @var{store} and @var{batch-system} are the
+same as in @code{run-workflow}. @var{inferior} and @var{guix-store} are the same
+as in @code{build-command-line-tool-script} from @code{(ravanan
command-line-tool)}."
(scheduler-proc name
(let ((class (assoc-ref* cwl "class")))
@@ -205,7 +206,7 @@ command-line-tool)}."
scratch
store
batch-system
- guix-daemon-socket))
+ guix-store))
((string=? class "ExpressionTool")
(error "Workflow class not implemented yet" class))
((string=? class "Workflow")
@@ -216,7 +217,7 @@ command-line-tool)}."
scratch
store
batch-system
- guix-daemon-socket))
+ guix-store))
(else
(assertion-violation class "Unexpected workflow class"))))
(assoc-ref* cwl "inputs")
@@ -232,14 +233,14 @@ command-line-tool)}."
(define* (workflow-class->propnet cwl scheduler
manifest-file inferior scratch store
- batch-system guix-daemon-socket)
+ batch-system guix-store)
"Return a propagator network scheduled using @var{scheduler} on
@var{batch-system} for @var{cwl}, a @code{Workflow} class workflow.
@var{manifest-file}, @var{scratch}, @var{store}, @var{batch-system} and
@var{guix-daemon-socket} are the same as in @code{run-workflow}. @var{inferior}
-is the same as in @code{build-command-line-tool-script} from @code{(ravanan
-command-line-tool)}."
+and @var{guix-store} are the same as in @code{build-command-line-tool-script}
+from @code{(ravanan command-line-tool)}."
(define (normalize-scatter-method scatter-method)
(assoc-ref* '(("dotproduct" . dot-product)
("nested_crossproduct" . nested-cross-product)
@@ -263,7 +264,7 @@ command-line-tool)}."
scratch
store
batch-system
- guix-daemon-socket
+ guix-store
(maybe-assoc-ref (just step) "scatter")
(maybe-bind (maybe-assoc-ref (just step) "scatterMethod")
(compose just normalize-scatter-method)))))
@@ -590,24 +591,31 @@ Close @var{inferior} when done, even if @var{proc} exits non-locally."
(cut proc inferior)
(cut close-inferior inferior)))
-(define (build-workflow name cwl scheduler
- manifest-file channels scratch store
- batch-system guix-daemon-socket)
+(define* (build-workflow name cwl scheduler
+ manifest-file channels scratch store
+ batch-system
+ #:optional guix-daemon-socket)
"Build @var{cwl} workflow named @var{name} into a @code{<scheduler-proc>} object
-scheduled using @var{scheduler}.
+scheduled using @var{scheduler}. When @var{guix-daemon-socket} is specified,
+connect to the Guix daemon at that specific socket. Else, connect to the default
+socket.
-@var{manifest-file}, @var{channels}, @var{scratch}, @var{store},
-@var{batch-system} and @var{guix-daemon-socket} are the same as in
-@code{run-workflow}."
+@var{manifest-file}, @var{channels}, @var{scratch}, @var{store} and
+@var{batch-system} are the same as in @code{run-workflow}."
(define builder
(cut workflow->scheduler-proc name cwl scheduler
manifest-file <> scratch store
- batch-system guix-daemon-socket))
-
- (if channels
- (call-with-inferior (inferior-for-channels channels)
- builder)
- (builder #f)))
+ batch-system <>))
+
+ (if guix-daemon-socket
+ (parameterize ((%daemon-socket-uri guix-daemon-socket))
+ (build-workflow name cwl scheduler manifest-file channels
+ scratch store batch-system))
+ (with-store guix-store
+ (if channels
+ (call-with-inferior (inferior-for-channels channels)
+ (cut builder <> guix-store))
+ (builder #f guix-store)))))
(define* (run-workflow name manifest-file channels cwl inputs
scratch store batch-system