about summary refs log tree commit diff
diff options
context:
space:
mode:
authorArun Isaac2025-08-17 22:55:47 +0100
committerArun Isaac2025-08-18 14:40:40 +0100
commit2e488b15f383aff1a6a020597ecc3fe284c43077 (patch)
treed03f2dae51b158f1ffb630b21b20990f84274a25
parent8d81ab89a858bf2c963a92d659c55205e2fb07e8 (diff)
downloadravanan-2e488b15f383aff1a6a020597ecc3fe284c43077.tar.gz
ravanan-2e488b15f383aff1a6a020597ecc3fe284c43077.tar.lz
ravanan-2e488b15f383aff1a6a020597ecc3fe284c43077.zip
Use the new logging functions for all logging.
This will enable us to effect global control over the log level.
-rw-r--r--ravanan/command-line-tool.scm14
-rw-r--r--ravanan/single-machine.scm6
-rw-r--r--ravanan/store.scm16
-rw-r--r--ravanan/workflow.scm9
4 files changed, 20 insertions, 25 deletions
diff --git a/ravanan/command-line-tool.scm b/ravanan/command-line-tool.scm
index 62785cc..356fb37 100644
--- a/ravanan/command-line-tool.scm
+++ b/ravanan/command-line-tool.scm
@@ -111,7 +111,7 @@
                              supported-requirements
                              #:optional hint?)
   "Error out if any of @var{requirements} are not supported by @var{batch-system}.
-If @var{hint?} is @code{#t}, only print a warning.
+If @var{hint?} is @code{#t}, only log a warning.
 @var{supported-requirements-for-batch-system} is a function that when passed a
 batch system returns the requirements supported by it.
 @var{supported-requirements} is the list of requirements supported by at least
@@ -321,9 +321,8 @@ the built script as a monadic value."
         ;; been run successfully.
         (state-return
          (begin
-           (format (current-error-port)
-                   "~a previously run; retrieving result from store~%"
-                   script)
+           (log-info "~a previously run; retrieving result from store"
+                     script)
            (single-machine-job-state script inputs #t)))
         ;; Run script if it has not already been run.
         (begin
@@ -359,10 +358,9 @@ the built script as a monadic value."
                                               #: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
-                        job-id)
+                (log-info "~a submitted as job ID ~a~%"
+                          script
+                          job-id)
                 (state-return (slurm-job-state script inputs job-id))))
              (else
               (assertion-violation batch-system "Invalid batch system"))))))))
diff --git a/ravanan/single-machine.scm b/ravanan/single-machine.scm
index 854dd2c..b03137f 100644
--- a/ravanan/single-machine.scm
+++ b/ravanan/single-machine.scm
@@ -20,6 +20,7 @@
   #:use-module (srfi srfi-26)
   #:use-module (ice-9 match)
   #:use-module (ravanan work monads)
+  #:use-module (ravanan work ui)
   #:export (submit-job))
 
 (define (submit-job environment stdout-file stderr-file script)
@@ -34,9 +35,8 @@ else @code{#f}. The return value is state-monadic."
                  ((name . value)
                   (setenv name value)))
                environment)
-     (format (current-error-port)
-             "Running ~a~%"
-             script)
+     (log-info "Running ~a~%"
+               script)
      (zero? (with-output-to-file stdout-file
               (lambda ()
                 (with-error-to-file stderr-file
diff --git a/ravanan/store.scm b/ravanan/store.scm
index ba66076..6de7d21 100644
--- a/ravanan/store.scm
+++ b/ravanan/store.scm
@@ -26,6 +26,7 @@
   #:use-module (guix build utils)
   #:use-module (ravanan work command-line-tool)
   #:use-module (ravanan work monads)
+  #:use-module (ravanan work ui)
   #:use-module (ravanan work utils)
   #:use-module (ravanan work vectors)
   #:export (%store-files-directory
@@ -52,9 +53,8 @@
   "Make @var{store} directory and initialize with subdirectories. If @var{store}
 already exists, do nothing."
   (unless (file-exists? store)
-    (format (current-error-port)
-            "store ~a does not exist; creating it~%"
-            store)
+    (log-warning "store ~a does not exist; creating it"
+                 store)
     (make-directories store)
     (for-each (lambda (directory)
                 (mkdir (expand-file-name directory store)))
@@ -147,13 +147,11 @@ interned path and location."
                                        (basename path))
                       store)))
                 (if (file-exists? interned-path)
-                    (format (current-error-port)
-                            "~a previously interned into store as ~a~%"
-                            path interned-path)
-                    (begin
-                      (format (current-error-port)
-                              "Interning ~a into store as ~a~%"
+                    (log-info "~a previously interned into store as ~a~%"
                               path interned-path)
+                    (begin
+                      (log-info "Interning ~a into store as ~a~%"
+                                path interned-path)
                       (mkdir (dirname interned-path))
                       ;; Hard link if on the same filesystem. Else, copy.
                       ((if (same-filesystem? path
diff --git a/ravanan/workflow.scm b/ravanan/workflow.scm
index 2de254b..3f0ef27 100644
--- a/ravanan/workflow.scm
+++ b/ravanan/workflow.scm
@@ -479,11 +479,10 @@ is the class of the workflow."
             (inputs (job-state-inputs (command-line-tool-state-job-state state))))
         (state-return
          (begin
-           (format (current-error-port)
-                   "~a completed; logs at ~a and ~a~%"
-                   script
-                   (step-store-stdout-file script inputs store)
-                   (step-store-stderr-file script inputs store))
+           (log-info "~a completed; logs at ~a and ~a~%"
+                     script
+                     (step-store-stdout-file script inputs store)
+                     (step-store-stderr-file script inputs store))
            (filter-outputs "CommandLineTool"
                            (capture-command-line-tool-output script inputs store)
                            (command-line-tool-state-formal-outputs state))))))))