diff options
-rwxr-xr-x | bin/ravanan | 80 | ||||
-rw-r--r-- | ravanan/verbosity.scm | 36 |
2 files changed, 84 insertions, 32 deletions
diff --git a/bin/ravanan b/bin/ravanan index ebd3835..71f7017 100755 --- a/bin/ravanan +++ b/bin/ravanan @@ -3,7 +3,7 @@ exec guile --no-auto-compile -e main -s "$0" "$@" !# ;;; 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. ;;; @@ -33,6 +33,7 @@ exec guile --no-auto-compile -e main -s "$0" "$@" (ravanan config) (ravanan reader) (ravanan utils) + (ravanan verbosity) (ravanan workflow) (ravanan work utils)) @@ -77,6 +78,15 @@ exec guile --no-auto-compile -e main -s "$0" "$@" (lambda (opt name arg result) (acons 'outdir arg result))) + (option (list "trace") #t #f + (lambda (opt name arg result) + (let ((accepted-values (list))) + (if (member arg accepted-values) + (assoc-set result + (cons 'traces + (cons (string->symbol arg) + (assq-ref result 'traces)))) + (error "Unknown trace subsystem" arg))))) (option (list "help") #f #t (lambda (opt name arg result) (acons 'help #t result))) @@ -115,7 +125,11 @@ Slurm API batch system options: --slurm-jwt=SLURM-JWT slurm JWT to authenticate with --slurm-partition=SLURM-PARTITION slurm partition to request --slurm-nice=SLURM-NICE slurm job priority adjustment -" + +Debugging options: + + --trace=SUBSYSTEM enable tracing on subsystem; + repeat to trace multiple subsystems" program)) (define (read-jwt file) @@ -182,7 +196,8 @@ files that have the token in the @verbatim{SLURM_JWT=token} format." `((batch-system . single-machine) (slurm-api-endpoint . ,(build-uri 'http #:host "localhost" - #:port 6820)))))) + #:port 6820)) + (traces . ()))))) (when (assq-ref args 'help) (print-usage program) (exit #t)) @@ -227,35 +242,36 @@ files that have the token in the @verbatim{SLURM_JWT=token} format." (error "Error loading manifest file" file) (raise-exception c)))))) - (run-workflow (file-name-stem workflow-file) - (and (assq 'guix-manifest-file args) - (canonicalize-path - (assq-ref args 'guix-manifest-file))) - (and (assq-ref args 'guix-channels-file) - (load-script - (canonicalize-path - (assq-ref args 'guix-channels-file)) - #:modules '((guile) - (guix channels)))) - (read-workflow workflow-file) - (read-inputs inputs-file) - (case (assq-ref args 'batch-system) - ((single-machine) - (or (assq-ref args 'scratch) - (getcwd))) - ((slurm-api) - (assq-ref args 'scratch))) - store - (case (assq-ref args 'batch-system) - ((single-machine) 'single-machine) - ((slurm-api) - (slurm-api-batch-system - (assq-ref args 'slurm-api-endpoint) - (and (assq-ref args 'slurm-jwt) - (read-jwt (assq-ref args 'slurm-jwt))) - (assq-ref args 'slurm-partition) - (assq-ref args 'slurm-nice)))) - #:guix-daemon-socket (assq-ref args 'guix-daemon-socket))))) + (parameterize ((%traces (assq-ref args 'traces))) + (run-workflow (file-name-stem workflow-file) + (and (assq 'guix-manifest-file args) + (canonicalize-path + (assq-ref args 'guix-manifest-file))) + (and (assq-ref args 'guix-channels-file) + (load-script + (canonicalize-path + (assq-ref args 'guix-channels-file)) + #:modules '((guile) + (guix channels)))) + (read-workflow workflow-file) + (read-inputs inputs-file) + (case (assq-ref args 'batch-system) + ((single-machine) + (or (assq-ref args 'scratch) + (getcwd))) + ((slurm-api) + (assq-ref args 'scratch))) + store + (case (assq-ref args 'batch-system) + ((single-machine) 'single-machine) + ((slurm-api) + (slurm-api-batch-system + (assq-ref args 'slurm-api-endpoint) + (and (assq-ref args 'slurm-jwt) + (read-jwt (assq-ref args 'slurm-jwt))) + (assq-ref args 'slurm-partition) + (assq-ref args 'slurm-nice)))) + #:guix-daemon-socket (assq-ref args 'guix-daemon-socket)))))) (scm->json (if (assq-ref args 'outdir) (symlink-to-output-directory store (assq-ref args 'outdir) diff --git a/ravanan/verbosity.scm b/ravanan/verbosity.scm new file mode 100644 index 0000000..957d72c --- /dev/null +++ b/ravanan/verbosity.scm @@ -0,0 +1,36 @@ +;;; 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 verbosity) + #:use-module (srfi srfi-19) + #:export (%traces + trace)) + +(define %traces + (make-parameter (list))) + +(define (trace subsystem message . args) + "Print out tracing @var{message} with @var{args} for @var{subsystem}. As a +convention, we expect @var{message} to be in lower case." + (when (memq subsystem (%traces)) + (display (date->string (current-date) "~5") (current-error-port)) + (display " " (current-error-port)) + (display subsystem (current-error-port)) + (display ": " (current-error-port)) + (apply format (current-error-port) message args) + (newline (current-error-port)))) |