From 299a60b666e64df20f1c7065b58aa43e163caae9 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sat, 18 Nov 2023 21:08:17 +0000 Subject: ccwl: Allow nested workflows in workflow body. * ccwl/ccwl.scm (function-inputs, function-outputs, function-object): Support objects as functions. (): Move above function-outputs. * ccwl/cwl.scm (workflow->cwl-scm): Allow nested workflows. --- ccwl/ccwl.scm | 35 +++++++++++++++++++---------------- ccwl/cwl.scm | 2 ++ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm index dd4a76c..0b8f701 100644 --- a/ccwl/ccwl.scm +++ b/ccwl/ccwl.scm @@ -274,12 +274,21 @@ compared using @code{equal?}." (inputs cwl-workflow-inputs) (outputs cwl-workflow-outputs)) +(define-immutable-record-type + (make-workflow steps inputs outputs other) + workflow? + (steps workflow-steps) + (inputs workflow-inputs) + (outputs workflow-outputs) + (other workflow-other)) + (define (function-outputs function) - "Return the outputs of FUNCTION, a or -object." + "Return the outputs of FUNCTION---a , or + object." ((cond ((command? function) command-outputs) ((cwl-workflow? function) cwl-workflow-outputs) + ((workflow? function) workflow-outputs) (else (error "Unrecognized ccwl function" function))) function)) @@ -297,14 +306,6 @@ object." (define step-out (compose function-outputs step-run)) -(define-immutable-record-type - (make-workflow steps inputs outputs other) - workflow? - (steps workflow-steps) - (inputs workflow-inputs) - (outputs workflow-outputs) - (other workflow-other)) - (define (input-spec-id input-spec) "Return the identifier symbol of INPUT-SPEC." (syntax->datum @@ -496,11 +497,12 @@ identifiers defined in the commands." (parameters->id+type (assoc-ref yaml "outputs")))))) (define (function-inputs function) - "Return the list of inputs accepted by @var{function}, a -@code{} or @code{} object." + "Return the list of inputs accepted by @var{function}---a +@code{}, @code{} or @code{ object." ((cond ((command? function) command-inputs) ((cwl-workflow? function) cwl-workflow-inputs) + ((workflow? function) workflow-inputs) (else (error "Unrecognized ccwl function" function))) function)) @@ -547,15 +549,16 @@ an association list mapping keyword arguments to their values." (command-inputs command)))) (define (function-object x) - "Return the ccwl function object (a or a -object) described by syntax X. If such a ccwl function is not defined, -return #f." + "Return the ccwl function object (a , +or object) described by syntax X. If such a ccwl function +is not defined, return #f." ;; TODO: What if function object is defined in lexical scope? (let ((result (false-if-exception (eval (syntax->datum x) (interaction-environment))))) (and (or (command? result) - (cwl-workflow? result)) + (cwl-workflow? result) + (workflow? result)) result))) (define (collect-scatter-step x input-keys scatter-method) diff --git a/ccwl/cwl.scm b/ccwl/cwl.scm index cdd65ca..53e6548 100644 --- a/ccwl/cwl.scm +++ b/ccwl/cwl.scm @@ -89,6 +89,8 @@ association list." (command->cwl-scm command)) ((? cwl-workflow? cwl-workflow) (cwl-workflow-file cwl-workflow)) + ((? workflow? workflow) + (workflow->cwl-scm workflow)) (tree tree))) ,@(match (step-scattered-inputs step) (() '()) -- cgit v1.2.3