aboutsummaryrefslogtreecommitdiff
path: root/ccwl
diff options
context:
space:
mode:
authorArun Isaac2023-11-16 13:35:40 +0000
committerArun Isaac2023-11-16 13:59:33 +0000
commit900c76a29726778a34ba0cbeb832cddd618783f4 (patch)
tree817d51c15cd8d4c2ee88b6f9f018f16c20f47529 /ccwl
parent7d1cc9b535afeb6021bec83b3220928998361528 (diff)
downloadccwl-900c76a29726778a34ba0cbeb832cddd618783f4.tar.gz
ccwl-900c76a29726778a34ba0cbeb832cddd618783f4.tar.lz
ccwl-900c76a29726778a34ba0cbeb832cddd618783f4.zip
ccwl: Support nested arrays.
* ccwl/ccwl.scm (construct-type-syntax): Construct types recursively to support nested arrays. (key->output): Recursively convert stdout types to File types. * ccwl/cwl.scm (type->cwl): New function. (input->cwl-scm, output->cwl-scm): Use type->cwl. * tests/ccwl.scm (make-array-type): New function. (construct-type-syntax-wrapper): New syntax. ("construct-type-syntax on primitive types", "construct-type-syntax on array types", "construct-type-syntax on nested array types"): New tests. * tests/cwl.scm, doc/array-types.scm, doc/nested-array-types.scm: New files. * doc/ccwl.skb (Cookbook)[Array types]: New section.
Diffstat (limited to 'ccwl')
-rw-r--r--ccwl/ccwl.scm24
-rw-r--r--ccwl/cwl.scm17
2 files changed, 19 insertions, 22 deletions
diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm
index 66a8ab7..5ae0761 100644
--- a/ccwl/ccwl.scm
+++ b/ccwl/ccwl.scm
@@ -132,11 +132,9 @@ compared using @code{equal?}."
(define (construct-type-syntax type-spec)
"Return syntax to build a type from @var{type-spec}."
- ;; TODO: Does CWL support arrays of arrays? If so, support such
- ;; recursive type definitions.
(syntax-case type-spec (array)
((array member-type)
- #'(make-array-type 'member-type))
+ #`(make-array-type #,(construct-type-syntax #'member-type)))
(primitive-type
#''primitive-type)))
@@ -714,6 +712,14 @@ a <key> object, in STEPS, a list of <step> objects. If no such
<output> object is found, return #f. Note that the returned syntax is
only applicable to construct <output> objects for workflows, not in
commands."
+ (define (stdout->file-type type)
+ "Recursively convert stdout types in @var{type} to File types."
+ (cond
+ ((array-type? type)
+ (make-array-type (stdout->file-type (array-type-member-type type))))
+ ((eq? type 'stdout) 'File)
+ (else type)))
+
(and-let* ((step-with-output (find (lambda (step)
(eq? (step-id step)
(key-step key)))
@@ -734,17 +740,7 @@ commands."
(cwl-key-address key))
(key-name key))
;; Convert stdout type outputs to File type outputs.
- (let ((type
- (cond
- ((eq? (output-type output-for-key)
- 'stdout)
- 'File)
- ((and (array-type? (output-type output-for-key))
- (eq? (array-type-member-type (output-type output-for-key))
- 'stdout))
- (make-array-type 'File))
- (else
- (output-type output-for-key)))))
+ (let ((type (stdout->file-type (output-type output-for-key))))
;; If step scatters, convert to an array type.
(if (null? (step-scattered-inputs step-with-output))
type
diff --git a/ccwl/cwl.scm b/ccwl/cwl.scm
index cdb4503..cdd65ca 100644
--- a/ccwl/cwl.scm
+++ b/ccwl/cwl.scm
@@ -97,15 +97,19 @@ association list."
(scatterMethod . ,(step-scatter-method step)))))))
(workflow-steps workflow)))))
+(define (type->cwl type)
+ "Render @var{type} into a CWL tree."
+ (if (array-type? type)
+ `((type . array)
+ (items . ,(type->cwl (array-type-member-type type))))
+ type))
+
(define* (output->cwl-scm output #:key workflow?)
"Render @var{output}, a @code{<output>} object, into a CWL tree. If
@var{workflow?} is @code{#t}, this is a workflow output."
`(,(output-id output)
,@(or (filter-alist
- `(,@(if (array-type? (output-type output))
- `((type . ((type . array)
- (items . ,(array-type-member-type (output-type output))))))
- `((type . ,(output-type output))))
+ `((type . ,(type->cwl (output-type output)))
;; outputBinding is relevant only to commands, and
;; outputSource is relevant only to workflows.
,@(if workflow?
@@ -125,10 +129,7 @@ CWL YAML specification."
(define (input->cwl-scm input)
"Render @var{input}, a @code{<input>} object, into a CWL tree."
`(,(input-id input)
- ,@(if (array-type? (input-type input))
- `((type . ((type . array)
- (items . ,(array-type-member-type (input-type input))))))
- `((type . ,(input-type input))))
+ (type . ,(type->cwl (input-type input)))
,@(or (filter-alist
`((label . ,(input-label input))
(default . ,(and (not (unspecified-default? (input-default input)))