From 5ef416199d69090219261b367a74b9e374579ef8 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Wed, 11 Sep 2024 15:57:21 +0100 Subject: workflow: Move optional input predicate to separate function. * ravanan/workflow.scm (optional-input?): New function. (command-line-tool->propagator): Use optional-input?. --- ravanan/workflow.scm | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ravanan/workflow.scm b/ravanan/workflow.scm index 0e52a73..87458e0 100644 --- a/ravanan/workflow.scm +++ b/ravanan/workflow.scm @@ -123,6 +123,15 @@ requirements and hints of the step." (else (error "Unable to coerce value to type" val type)))) (else val))) +(define (optional-input? input) + "Return @code{#t} if @var{input} is optional. Else, return @code{#f}." + ;; Inputs that either have a default or accept null values are optional. + (and (or (assoc-ref input "default") + (match-type 'null + (formal-parameter-type + (assoc-ref* input "type")))) + (assoc-ref input "id"))) + (define* (command-line-tool->propagator name cwl) "Convert @code{CommandLineTool} workflow @var{cwl} of @var{name} to a propagator." @@ -134,12 +143,7 @@ propagator." (assoc-ref cwl "inputs")) ;; Inputs that either have a default or accept null values are ;; optional. - (vector-filter-map->list (lambda (input) - (and (or (assoc-ref input "default") - (match-type 'null - (formal-parameter-type - (assoc-ref* input "type")))) - (assoc-ref input "id"))) + (vector-filter-map->list optional-input? (assoc-ref cwl "inputs")) (vector-map->list (lambda (output) (cons (assoc-ref output "id") -- cgit v1.2.3