diff options
author | Arun Isaac | 2024-09-06 00:33:06 +0100 |
---|---|---|
committer | Arun Isaac | 2024-09-06 11:05:37 +0100 |
commit | c4164374719566236d33699b92ec09ee2d9617a8 (patch) | |
tree | c4db6ef7a88ab6b6e59baacff93d8705a1bb35aa | |
parent | 2dbaca2815e550e6155e4db189dba24701cd1ea1 (diff) | |
download | ravanan-c4164374719566236d33699b92ec09ee2d9617a8.tar.gz ravanan-c4164374719566236d33699b92ec09ee2d9617a8.tar.lz ravanan-c4164374719566236d33699b92ec09ee2d9617a8.zip |
propnet: Support optional inputs.
* ravanan/propnet.scm (<propagator>)[optional-inputs]: New field.
* ravanan/propnet.scm (activate-propagator): Activate propagator even
when optional inputs are absent.
* ravanan/workflow.scm: Import (ravanan work utils).
(command-line-tool->propagator, workflow-class->propagators): Specify
optional inputs of propagators.
(workflow->command-line-tool-steps): Inherit defaults down to the steps from the
containing workflow.
[inherit-defaults]: New function.
-rw-r--r-- | ravanan/propnet.scm | 7 | ||||
-rw-r--r-- | ravanan/workflow.scm | 33 |
2 files changed, 36 insertions, 4 deletions
diff --git a/ravanan/propnet.scm b/ravanan/propnet.scm index 396f6d5..4eef452 100644 --- a/ravanan/propnet.scm +++ b/ravanan/propnet.scm @@ -34,6 +34,7 @@ propagator-name propagator-proc propagator-inputs + propagator-optional-inputs propagator-outputs scheduler scheduler-schedule @@ -51,11 +52,12 @@ (scheduler propnet-scheduler)) (define-immutable-record-type <propagator> - (propagator name proc inputs outputs) + (propagator name proc inputs optional-inputs outputs) propagator? (name propagator-name) (proc propagator-proc) (inputs propagator-inputs) + (optional-inputs propagator-optional-inputs) (outputs propagator-outputs)) (define-immutable-record-type <scheduler> @@ -76,7 +78,8 @@ required inputs are absent, do nothing. Schedule the propagator using (propagator-inputs propagator)) (map (match-lambda ((input-name . _) input-name)) - inputs-alist)) + inputs-alist) + (propagator-optional-inputs propagator)) (() (just (schedule (propagator-proc propagator) inputs-alist))) (_ %nothing))) diff --git a/ravanan/workflow.scm b/ravanan/workflow.scm index 6764269..b30c386 100644 --- a/ravanan/workflow.scm +++ b/ravanan/workflow.scm @@ -28,6 +28,7 @@ #:use-module (ravanan utils) #:use-module (ravanan vectors) #:use-module (ravanan work command-line-tool) + #:use-module (ravanan work utils) #:export (run-workflow)) (define %supported-requirements @@ -130,6 +131,15 @@ propagator." (cons (assoc-ref input "id") (assoc-ref input "id"))) (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"))) + (assoc-ref cwl "inputs")) (vector-map->list (lambda (output) (cons (assoc-ref output "id") (assoc-ref output "id"))) @@ -138,11 +148,29 @@ propagator." (define (workflow->command-line-tool-steps cwl) "Recursively traverse @var{cwl} tree and return a list of @code{CommandLineTool} class steps." + (define (inherit-defaults step-run step-in) + "Augment the @var{step-run} CWL tree with defaults from the containing +workflow. @var{step-in} is the inputs mapping association list of the step." + (assoc-set step-run + (cons "inputs" + (vector-map (lambda (input) + (let* ((input-id (assoc-ref input "id")) + (input-source (assoc-ref step-in input-id))) + (maybe-assoc-set input + (cons "default" + (maybe-assoc-ref (just cwl) + "inputs" + input-source + "default"))))) + (assoc-ref* step-run "inputs"))))) + (vector-append-map->list (lambda (step) - (let ((run (assoc-ref step "run"))) + (let ((run (inherit-defaults (assoc-ref step "run") + (assoc-ref step "in")))) (if (string=? (assoc-ref run "class") "CommandLineTool") - (list step) + (list (assoc-set step + (cons "run" run))) (workflow->command-line-tool-steps (inherit-requirements-and-hints run @@ -173,6 +201,7 @@ their own namespaces." (propagator-name step-propagator)) (propagator-proc step-propagator) (assoc-ref step "in") + (propagator-optional-inputs step-propagator) (vector-map->list (lambda (output-name) (cons output-name (prefix-name step-id output-name))) |