Skip to content

Instantly share code, notes, and snippets.

@mmerce
Created April 24, 2019 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmerce/0a7044f28c71febb95c9e3e91c5b7741 to your computer and use it in GitHub Desktop.
Save mmerce/0a7044f28c71febb95c9e3e91c5b7741 to your computer and use it in GitHub Desktop.
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
(create-script
{"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