summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2023-11-18 21:08:17 +0000
committerArun Isaac2023-11-18 21:08:17 +0000
commit299a60b666e64df20f1c7065b58aa43e163caae9 (patch)
tree07a0ade0f74de14fe525d03d23eff5eeb7c2024f
parent52f486fc3855c20f2ef092cdd17437bfc16302f6 (diff)
downloadccwl-299a60b666e64df20f1c7065b58aa43e163caae9.tar.gz
ccwl-299a60b666e64df20f1c7065b58aa43e163caae9.tar.lz
ccwl-299a60b666e64df20f1c7065b58aa43e163caae9.zip
ccwl: Allow nested workflows in workflow body.
* ccwl/ccwl.scm (function-inputs, function-outputs, function-object): Support <workflow> objects as functions. (<workflow>): Move above function-outputs. * ccwl/cwl.scm (workflow->cwl-scm): Allow nested workflows.
-rw-r--r--ccwl/ccwl.scm35
-rw-r--r--ccwl/cwl.scm2
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 <workflow>
+ (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 <command> or <cwl-workflow>
-object."
+ "Return the outputs of FUNCTION---a <command>, <cwl-workflow> or
+<workflow> 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 <workflow>
- (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{<command>} or @code{<cwl-workflow>} object."
+ "Return the list of inputs accepted by @var{function}---a
+@code{<command>}, @code{<cwl-workflow>} or @code{<workflow> 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 <command> or a <cwl-workflow>
-object) described by syntax X. If such a ccwl function is not defined,
-return #f."
+ "Return the ccwl function object (a <command>, <cwl-workflow>
+or <workflow> 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)
(() '())