Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
WhizzML executes WhizzML
;; Creating and executing dependent scripts in a pipeline
;; script2 uses the output of an execution of script1 directly as input
;; and multiplies it by another input.
;; As one script uses the execution of the previous script, they will be executed
;; in a sequence
;; creating a first script that adds two numbers
(define script1 (create-script {"source_code" "(define sum (+ a b))"
"name" "Sum script"
"inputs" [{"type" "number" "name" "a"}
{"type" "number" "name" "b"}]
"outputs" [{"type" "number" "name" "sum"}]}))
;; creating a second script that multiplies two numbers
(define script2
{"source_code" "(* sum c)"
"name" "Multiplication script"
"inputs" [{"type" "number" "name" "sum"}
{"type" "number" "name" "c"}]}))
;; executing a list of two scripts in a pipeline, so that the output of script1 becomes one of the
;; inputs for script2
(define final-execution
(create-and-wait-execution {"scripts" [script1 script2]
"input_maps" {script1 [["a" 1] ["b" 2]]
script2 [["c" 3]]}}))
;; reading the result from the final execution
(define output ((fetch final-execution) ["execution" "result"]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment