diff options
author | Arun Isaac | 2021-03-06 02:21:29 +0530 |
---|---|---|
committer | Arun Isaac | 2021-03-06 02:21:29 +0530 |
commit | cf3d41273f89ae713a828b5d1bc5f194b39b482f (patch) | |
tree | 650486d09ea7e009197ba592d29d167a7f49aefc | |
parent | 5b51e967a83df2879a241b7b21217056f15280ee (diff) | |
download | ccwl-cf3d41273f89ae713a828b5d1bc5f194b39b482f.tar.gz ccwl-cf3d41273f89ae713a828b5d1bc5f194b39b482f.tar.lz ccwl-cf3d41273f89ae713a828b5d1bc5f194b39b482f.zip |
Implement pipeline support.
* ccwl/ccwl.scm (%stdin, %stdout): New variables.
(pipeline): New function.
-rw-r--r-- | ccwl/ccwl.scm | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm index b1425f8..e49225a 100644 --- a/ccwl/ccwl.scm +++ b/ccwl/ccwl.scm @@ -12,7 +12,8 @@ workflow input output - step)) + step + pipeline)) (define-immutable-record-type <input> (make-input id type label default binding source other) @@ -48,6 +49,11 @@ "Build and return an <output> object." (make-output id type binding source other)) +(define %stdin + (input "stdin" #:type 'File)) + +(define %stdout + (output "stdout" #:type 'stdout)) (define (input->tree input) "Convert INPUT, an <input> object, to a tree." @@ -159,6 +165,38 @@ interface-inputs outputs))) +(define (pipeline id steps outputs) + ;; Error out if any step does not encapsulate a command. + (cond + ((find (lambda (step) + (not (command? (step-run step)))) + steps) + => (lambda (step) + (error "Step does not encapsulate command" step)))) + (workflow id + (reverse + (fold (lambda (step result) + (match result + ((previous-step tail ...) + (cons* + ;; Add an stdin input that is connected to the stdout + ;; of the previous step. + (let ((stdin (set-input-source %stdin + (string-append (step-id previous-step) "/" (output-id %stdout))))) + (append-step-in (modify-step-run step + (cut set-command-stdin <> stdin)) + stdin)) + previous-step + tail)) + (() (list step)))) + (list) + ;; Add an stdout output to all steps. + (map (lambda (step) + (append-step-out (modify-step-run step (cut append-command-outputs <> %stdout)) + %stdout)) + steps))) + outputs)) + (define (output->cwl output) `(,(output-id output) ,@(filter identity |