Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WhizzML executes WhizzML
;; Creating and executing dependent scripts.
;; script2 uses the output of an execution of script1 to multiply it by a number
;; As one script uses the execution of the previous script, they will be executed
;; in a sequence
;; creating the first script to add 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 uses the results of an existing execution to multiply them
;; by another number
(define script2
(create-script
{"source_code" (str "(define execution-info (fetch execution-id))"
"(let (sum (execution-info [\"execution\" \"result\"]))"
" (* sum c))")
"name" "Multiplication script"
"inputs" [{"type" "execution-id" "name" "execution-id"}
{"type" "number" "name" "c"}]}))
;; creating the execution of the first script
(define execution1 (create-execution {"script" script1
"inputs" [["a" 1] ["b" 2]]}))
;; creating the execution of the second script
(define final-execution
(create-and-wait-execution {"script" script2
"inputs" [["execution-id" execution1]
["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