summary refs log tree commit diff
diff options
context:
space:
mode:
authorArun Isaac2024-09-05 17:55:37 +0100
committerArun Isaac2024-09-05 18:05:34 +0100
commitb2c97647a1827b19e02890c31e528a42d6c4b12c (patch)
tree592601bde5dbfed9cfcb30ad90842d18a3c677fc
parent5879062693271a98b185aca40120a21c35581f51 (diff)
downloadravanan-b2c97647a1827b19e02890c31e528a42d6c4b12c.tar.gz
ravanan-b2c97647a1827b19e02890c31e528a42d6c4b12c.tar.lz
ravanan-b2c97647a1827b19e02890c31e528a42d6c4b12c.zip
workflow: Refactor workflow output capture into separate function.
* ravanan/workflow.scm (run-workflow)[capture-output]: New function.
Use capture-output.
-rw-r--r--ravanan/workflow.scm37
1 files changed, 18 insertions, 19 deletions
diff --git a/ravanan/workflow.scm b/ravanan/workflow.scm
index d3f2c7b..37df7ff 100644
--- a/ravanan/workflow.scm
+++ b/ravanan/workflow.scm
@@ -218,6 +218,21 @@ endpoint to connect to. @var{slurm-jwt}, a string, is the JWT token to
 authenticate to the slurm API with. @var{slurm-api-endpoint} and
 @var{slurm-jwt} are only used when @var{batch-system} is
 @code{'slurm-api}."
+  (define (capture-output cell-values output)
+    (let ((output-id (assoc-ref output "id")))
+      (cons output-id
+            (or (let ((class (assoc-ref* cwl "class")))
+                  (cond
+                   ((string=? class "CommandLineTool")
+                    (assoc-ref cell-values output-id))
+                   ((string=? class "ExpressionTool")
+                    (error "Workflow class not implemented yet"
+                           class))
+                   ((string=? class "Workflow")
+                    (assoc-ref cell-values
+                               (assoc-ref* output "outputSource")))))
+                (error "output not found" output-id)))))
+
   (let ((cell-values
          (run-propnet
           (propnet (workflow->propagators name cwl)
@@ -229,22 +244,6 @@ authenticate to the slurm API with. @var{slurm-api-endpoint} and
                     #:slurm-api-endpoint slurm-api-endpoint
                     #:slurm-jwt slurm-jwt))
           inputs)))
-    (let ((class (assoc-ref* cwl "class")))
-      (cond
-       ((string=? class "CommandLineTool")
-        (vector-map->list (lambda (output)
-                            (let ((output-id (assoc-ref output "id")))
-                              (cons output-id
-                                    (or (assoc-ref cell-values output-id)
-                                        (error "output not found" output-id)))))
-                          (assoc-ref cwl "outputs")))
-       ((string=? class "ExpressionTool")
-        (error "Workflow class not implemented yet" class))
-       ((string=? class "Workflow")
-        (vector-map->list (lambda (output)
-                            (let ((output-id (assoc-ref output "id")))
-                              (cons output-id
-                                    (or (assoc-ref cell-values
-                                                   (assoc-ref* output "outputSource"))
-                                        (error "output not found" output-id)))))
-                          (assoc-ref cwl "outputs")))))))
+    ;; Capture outputs.
+    (vector-map->list (cut capture-output cell-values <>)
+                      (assoc-ref* cwl "outputs"))))