From b2c97647a1827b19e02890c31e528a42d6c4b12c Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Thu, 5 Sep 2024 17:55:37 +0100 Subject: workflow: Refactor workflow output capture into separate function. * ravanan/workflow.scm (run-workflow)[capture-output]: New function. Use capture-output. --- ravanan/workflow.scm | 37 ++++++++++++++++++------------------- 1 file 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")))) -- cgit v1.2.3