diff options
-rw-r--r-- | ravanan/command-line-tool.scm | 48 | ||||
-rw-r--r-- | ravanan/single-machine.scm | 40 |
2 files changed, 64 insertions, 24 deletions
diff --git a/ravanan/command-line-tool.scm b/ravanan/command-line-tool.scm index 7ce2ae8..f01c774 100644 --- a/ravanan/command-line-tool.scm +++ b/ravanan/command-line-tool.scm @@ -1,5 +1,5 @@ ;;; ravanan --- High-reproducibility CWL runner powered by Guix -;;; Copyright © 2024 Arun Isaac <arunisaac@systemreboot.net> +;;; Copyright © 2024, 2025 Arun Isaac <arunisaac@systemreboot.net> ;;; ;;; This file is part of ravanan. ;;; @@ -43,7 +43,8 @@ #:use-module (ravanan javascript) #:use-module (ravanan job-state) #:use-module (ravanan reader) - #:use-module (ravanan slurm-api) + #:use-module ((ravanan single-machine) #:prefix single-machine:) + #:use-module ((ravanan slurm-api) #:prefix slurm:) #:use-module (ravanan utils) #:use-module (ravanan work command-line-tool) #:use-module (ravanan work monads) @@ -439,33 +440,32 @@ path." (mkdir store-files-directory) (cond ((eq? batch-system 'single-machine) - (setenv "WORKFLOW_OUTPUT_DIRECTORY" store-files-directory) - (setenv "WORKFLOW_OUTPUT_DATA_FILE" store-data-file) - (format (current-error-port) - "Running ~a~%" - script) (single-machine-job-state script - (zero? (with-output-to-file stdout-file - (lambda () - (with-error-to-file stderr-file - (cut system* script))))))) + (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~%" script) - (let ((job-id (submit-job `(("WORKFLOW_OUTPUT_DIRECTORY" . - ,store-files-directory) - ("WORKFLOW_OUTPUT_DATA_FILE" . - ,store-data-file)) - stdout-file - stderr-file - cpus - name - 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) - #:nice (slurm-api-batch-system-nice batch-system)))) + (let ((job-id (slurm:submit-job `(("WORKFLOW_OUTPUT_DIRECTORY" . + ,store-files-directory) + ("WORKFLOW_OUTPUT_DATA_FILE" . + ,store-data-file)) + stdout-file + stderr-file + cpus + name + 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) + #:nice (slurm-api-batch-system-nice batch-system)))) (format (current-error-port) "~a submitted as job ID ~a~%" script diff --git a/ravanan/single-machine.scm b/ravanan/single-machine.scm new file mode 100644 index 0000000..eb7131f --- /dev/null +++ b/ravanan/single-machine.scm @@ -0,0 +1,40 @@ +;;; ravanan --- High-reproducibility CWL runner powered by Guix +;;; Copyright © 2025 Arun Isaac <arunisaac@systemreboot.net> +;;; +;;; This file is part of ravanan. +;;; +;;; ravanan is free software: you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; ravanan is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;; General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with ravanan. If not, see <https://www.gnu.org/licenses/>. + +(define-module (ravanan single-machine) + #:use-module (srfi srfi-26) + #:use-module (ice-9 match) + #:export (submit-job)) + +(define (submit-job environment stdout-file stderr-file script) + "Submit job running @var{script} to the single machine batch system. +@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)))))) |