diff options
author | Arun Isaac | 2023-11-07 23:08:01 +0000 |
---|---|---|
committer | Arun Isaac | 2023-11-07 23:29:09 +0000 |
commit | e78eee575051bf9506b2362997a2dc7c73f148dd (patch) | |
tree | 02bc9b468c29ad7857f780f8a59868734e4a3229 | |
parent | 808e44bd4e717f0ad7f89c5f97ee8d401935d856 (diff) | |
download | ccwl-e78eee575051bf9506b2362997a2dc7c73f148dd.tar.gz ccwl-e78eee575051bf9506b2362997a2dc7c73f148dd.tar.lz ccwl-e78eee575051bf9506b2362997a2dc7c73f148dd.zip |
cwl: Unify rendering of command and workflow outputs.
* ccwl/cwl.scm (output->cwl-scm): Handle both command and workflow
outputs. Accept #:workflow? argument to indicate workflow outputs.
(workflow->cwl-scm): Use output->cwl-scm.
-rw-r--r-- | ccwl/cwl.scm | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/ccwl/cwl.scm b/ccwl/cwl.scm index d751def..f032211 100644 --- a/ccwl/cwl.scm +++ b/ccwl/cwl.scm @@ -25,6 +25,7 @@ (define-module (ccwl cwl) #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) #:use-module (ice-9 match) #:use-module (ccwl ccwl) #:use-module (ccwl utils) @@ -67,14 +68,7 @@ association list." ,@(workflow-other workflow) (inputs . ,(map input->cwl-scm (workflow-inputs workflow))) - (outputs . ,(map (lambda (output) - `(,(output-id output) - (type . ,(match (output-type output) - ('stdout 'File) - (some-other-type some-other-type))) - (outputSource . ,(match (output-source output) - ((? string? source) source) - ((? input? input) (input-id input)))))) + (outputs . ,(map (cut output->cwl-scm <> #:workflow? #t) (workflow-outputs workflow))) (steps . ,(map (lambda (step) `(,(step-id step) @@ -94,14 +88,27 @@ association list." (tree tree))))) (workflow-steps workflow))))) -(define (output->cwl-scm output) - "Render OUTPUT, a <output> object, into a CWL tree." +(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) - ,@(filter identity - (list (and (output-type output) - (cons 'type (output-type output))) - (and (output-binding output) - (cons 'outputBinding (output-binding output))))) + ,@(or (filter-alist + `(,@(cond + ;; In workflows, convert stdout outputs to File + ;; outputs. + ((and workflow? + (eq? (output-type output) 'stdout)) + `((type . File))) + (else + `((type . ,(output-type output))))) + ;; outputBinding is relevant only to commands, and + ;; outputSource is relevant only to workflows. + ,@(if workflow? + `((outputSource . ,(match (output-source output) + ((? string? source) source) + ((? input? input) (input-id input))))) + `((outputBinding . ,(output-binding output)))))) + '()) ,@(output-other output))) (define (command->cwl command port) |