aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2025-01-12 03:15:26 +0000
committerArun Isaac2025-01-20 01:47:23 +0000
commit54e83118a2f99eb7c3c916878afc6f8132e9aeef (patch)
tree64c7762adcc27cb6cf4476b7a99f10bd6b9aef5e
parent66e77e13bad82e622bbf26c36375d67057cfddc3 (diff)
downloadravanan-54e83118a2f99eb7c3c916878afc6f8132e9aeef.tar.gz
ravanan-54e83118a2f99eb7c3c916878afc6f8132e9aeef.tar.lz
ravanan-54e83118a2f99eb7c3c916878afc6f8132e9aeef.zip
single-machine: Make interface state-monadic.
* ravanan/single-machine.scm: Import (ravanan work monads). (submit-job): Convert to a state-monadic function. * ravanan/command-line-tool.scm (run-command-line-tool): Run state-monadic return value from single-machine:submit-job.
-rw-r--r--ravanan/command-line-tool.scm17
-rw-r--r--ravanan/single-machine.scm27
2 files changed, 24 insertions, 20 deletions
diff --git a/ravanan/command-line-tool.scm b/ravanan/command-line-tool.scm
index acab4af..7da91e3 100644
--- a/ravanan/command-line-tool.scm
+++ b/ravanan/command-line-tool.scm
@@ -441,14 +441,15 @@ path."
(cond
((eq? batch-system 'single-machine)
(single-machine-job-state script
- (single-machine:submit-job
- `(("WORKFLOW_OUTPUT_DIRECTORY" .
- ,store-files-directory)
- ("WORKFLOW_OUTPUT_DATA_FILE" .
- ,store-data-file))
- stdout-file
- stderr-file
- script)))
+ (run-with-state
+ (single-machine:submit-job
+ `(("WORKFLOW_OUTPUT_DIRECTORY" .
+ ,store-files-directory)
+ ("WORKFLOW_OUTPUT_DATA_FILE" .
+ ,store-data-file))
+ stdout-file
+ stderr-file
+ script))))
((slurm-api-batch-system? batch-system)
(format (current-error-port)
"Submitting job ~a~%"
diff --git a/ravanan/single-machine.scm b/ravanan/single-machine.scm
index eb7131f..854dd2c 100644
--- a/ravanan/single-machine.scm
+++ b/ravanan/single-machine.scm
@@ -19,6 +19,7 @@
(define-module (ravanan single-machine)
#:use-module (srfi srfi-26)
#:use-module (ice-9 match)
+ #:use-module (ravanan work monads)
#:export (submit-job))
(define (submit-job environment stdout-file stderr-file script)
@@ -26,15 +27,17 @@
@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. Return @code{#t} if job succeeded,
-else @code{#f}."
- (for-each (match-lambda
- ((name . value)
- (setenv name value)))
- environment)
- (format (current-error-port)
- "Running ~a~%"
- script)
- (zero? (with-output-to-file stdout-file
- (lambda ()
- (with-error-to-file stderr-file
- (cut system* script))))))
+else @code{#f}. The return value is state-monadic."
+ (state-return
+ (begin
+ (for-each (match-lambda
+ ((name . value)
+ (setenv name value)))
+ environment)
+ (format (current-error-port)
+ "Running ~a~%"
+ script)
+ (zero? (with-output-to-file stdout-file
+ (lambda ()
+ (with-error-to-file stderr-file
+ (cut system* script))))))))