From 808e44bd4e717f0ad7f89c5f97ee8d401935d856 Mon Sep 17 00:00:00 2001
From: Arun Isaac
Date: Tue, 7 Nov 2023 23:04:36 +0000
Subject: cwl: Deduplicate input to CWL rendering.
* ccwl/cwl.scm (input->cwl-scm): New function.
(workflow->cwl-scm, command->cwl-scm): Use input->cwl-scm.
---
ccwl/cwl.scm | 39 ++++++++++++++++++++-------------------
1 file changed, 20 insertions(+), 19 deletions(-)
diff --git a/ccwl/cwl.scm b/ccwl/cwl.scm
index f5d7f6a..d751def 100644
--- a/ccwl/cwl.scm
+++ b/ccwl/cwl.scm
@@ -65,14 +65,7 @@ association list."
(class . Workflow)
(requirements (SubworkflowFeatureRequirement))
,@(workflow-other workflow)
- (inputs . ,(map (lambda (input)
- `(,(input-id input)
- ,@(filter-alist
- `((type . ,(input-type input))
- (label . ,(input-label input))
- (default . ,(and (not (unspecified-default? (input-default input)))
- (input-default input)))))
- ,@(input-other input)))
+ (inputs . ,(map input->cwl-scm
(workflow-inputs workflow)))
(outputs . ,(map (lambda (output)
`(,(output-id output)
@@ -117,6 +110,24 @@ CWL YAML specification."
(scm->yaml (command->cwl-scm command)
port))
+(define (input->cwl-scm input)
+ "Render @var{input}, a @code{} object, into a CWL tree."
+ `(,(input-id input)
+ (type . ,(input-type input))
+ ,@(or (filter-alist
+ `((label . ,(input-label input))
+ (default . ,(and (not (unspecified-default? (input-default input)))
+ (input-default input)))
+ ;; inputBinding is only relevant to commands, not
+ ;; workflows. But, the input position and prefix are not set
+ ;; for worklow inputs and therefore this sub-expression has
+ ;; no effect. So, leave this be.
+ (inputBinding . ,(filter-alist
+ `((position . ,(input-position input))
+ (prefix . ,(input-prefix input)))))))
+ '())
+ ,@(input-other input)))
+
(define (command->cwl-scm command)
"Render COMMAND, a object, into a CWL tree."
`((cwlVersion . ,%cwl-version)
@@ -142,17 +153,7 @@ CWL YAML specification."
`((position . ,index)
(valueFrom . ,arg))))
(command-args command))))
- (inputs . ,(map (lambda (input)
- `(,(input-id input)
- ,@(filter-alist
- `((type . ,(input-type input))
- (label . ,(input-label input))
- (default . ,(and (not (unspecified-default? (input-default input)))
- (input-default input)))
- (inputBinding . ,(filter-alist
- `((position . ,(input-position input))
- (prefix . ,(input-prefix input)))))))
- ,@(input-other input)))
+ (inputs . ,(map input->cwl-scm
(command-inputs command)))
(outputs . ,(map output->cwl-scm (command-outputs command)))
,@(if (command-stdin command)
--
cgit v1.2.3