From e430937727b881be2b2428ad0f09a32ea0aaf198 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Fri, 22 Mar 2024 01:29:40 +0000 Subject: ccwl: Implement js-expression. js-expression corresponds to ExpressionTool in the CWL specification. * ccwl/ccwl.scm (): New type. (js-expression): New macro. (function-inputs, function-outputs, function-object): Support objects. (function-input-keys): Mention objects in docstring. * ccwl/cwl.scm (function->cwl, workflow->cwl-scm): Support objects. (command->cwl-scm): Move staging requirements handling to ... (staging-requirements): ... this new function. (js-expression->cwl, js-expression->cwl-scm): New functions. * ccwl/graphviz.scm (function->dot): Support objects. (command->graph): Abstract to ... (single-node-workflow->graph): ... this new function. (js-expression->dot, js-expression->graph): New functions. * scripts/ccwl (main): Support objects. * doc/ccwl.skb (Cookbook){Javascript expressions via ExpressionTool}: New section. * doc/js-expression-iota.scm: New file. --- doc/ccwl.skb | 12 ++++++++++-- doc/js-expression-iota.scm | 7 +++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 doc/js-expression-iota.scm (limited to 'doc') diff --git a/doc/ccwl.skb b/doc/ccwl.skb index cb78fd5..23bd798 100644 --- a/doc/ccwl.skb +++ b/doc/ccwl.skb @@ -1,5 +1,5 @@ ;;; ccwl --- Concise Common Workflow Language -;;; Copyright © 2021, 2023 Arun Isaac +;;; Copyright © 2021, 2023–2024 Arun Isaac ;;; ;;; This file is part of ccwl. ;;; @@ -389,7 +389,15 @@ the external CWL workflow.] keys forward to the output. This is what the ,(code [identity]) construct is for. An example follows.] (scheme-source "doc/identity-construct.scm") - (image :file "doc/identity-construct.png")))) + (image :file "doc/identity-construct.png"))) + (section :title [Javascript expressions via ExpressionTool] + :ident "javascript-expressions-via-expressiontool" + (p [ccwl supports CWL's ,(samp "ExpressionTool") using its +,(code "js-expression") construct. The ,(code "js-expression") +construct may be invoked from within workflows just like ,(code +"command") constructs can be. Here's a workflow that uses ,(code +"js-expression") to construct an array of numbers from 0 to n-1.] + (scheme-source "doc/js-expression-iota.scm")))) (chapter :title [Contributing] :ident "chapter-contributing" diff --git a/doc/js-expression-iota.scm b/doc/js-expression-iota.scm new file mode 100644 index 0000000..066e4ae --- /dev/null +++ b/doc/js-expression-iota.scm @@ -0,0 +1,7 @@ +(define iota + (js-expression #:inputs (n #:type int) + #:expression "$({\"sequence\": Array.from(Array(inputs.n).keys())})" + #:outputs (sequence #:type (array int)))) + +(workflow ((n #:type int)) + (iota #:n n)) -- cgit v1.2.3