Skip to content

How to create a WhizzML Script – Part 3

by on August 25, 2017

In this third post about WhizzML basics, you’ll learn more about tools to create WhizzML scripts. We already covered how to manipulate WhizzML scripts from the Gallery. We also learned how to do the same via Scriptify and the Script Editor. For a quick reminder, go to the previous posts, How to create a WhizzML script – Part1 and Part 2. In this tutorial, you’ll discover two new powerful scripting scenarios that will help you build complicated workflows: GitHub and BigMLer. Let’s dive in!

GitHub & WhizzML

Once you are in the scripts section, you can create a new script by using the editor, create a new script from an existing one, or (you guessed it) import one from GitHub.

git-whizz

It’s easy as pie! You just have to go to the WhizzML Script section and click on the ‘IMPORT SCRIPT FROM GITHUB’ button in the top right menu. Then you enter a WhizzML Github URL. You’ll see the script uploaded in your dashboard window ready be created upon clicking the ‘Create’ button. You may be wondering where you can find a WhizzML Github URL. No problem! There is a WhizzML example repository in Github with a lot of handy example scripts.

BigMLer

bigmler-whizzml

Using BigMLer (BigML’s command line tool), you can execute WhizzML scripts too. You just have to remember to use the sub command execute. Let’s see some examples.

  1. In this first example, you will execute the code written directly in the command line by using the --code option. The code has to be written between the quotation marks. Below, we execute a real basic piece of code: adding two numbers. In this example, the output will be stored in the simple_exe directory, because we used the flag --output-dir. This directory will contain whizzml_result.txt, where you can easily read the output of your code.
    bigmler execute --code “(+ 1 2)” --output-dir simple_exe
  2. You can execute a script that you already have in your dashboard by using the script ID. For this, you have to use the flag --script:
    bigmler execute --script script/50a2bb64035d0706db000643
  3. If your script has inputs, you can pass it as a JSON file (my_inputs.json) by using the flag --inputs:
    bigmler execute --script script/50a2bb64035d0706db000643 \
                      --inputs my_inputs.json

    where the my_inputs.json file can contain something like below. The inputs would be a with value 1 and b with value 2 :jsonfile3

  4. In the following example of a BigMLer command, you will create your script but you won’t execute it through the flag  --no-execute. In this script, you are declaring inputs and outputs and specifying them in the corresponding JSON files, with the flags --declare-inouts and --declare outputs
        bigmler execute --code “(define addition (+ a b)” \
                        --declare-inputs my_inputs_dec.json \
                        --declare-outputs my_outputs_dec.json \
                        --no-execute

    bigmler execute –code “(define addition (+ a b)” \ –declare-inputs my_inputs_dec.json \ –declare-outputs my_outputs_dec.json \

  5. In this example, the my_inputs_dec.json file could contain:jsonfile1.pngand the my_outputs_dec.json file could be like the example below. The value of the addition variable would then be returned as output in the execution results:jsonfile2.png

So it isn’t rocket science. Now it’s your turn to try it! Of course, remember to install and authenticate yourself before typing your BigMLer command lines.

Now you know how to create a WhizzML script in more ways. But we’re not quite finished yet! The next step will be discovering how to use the bindings to create scripts and libraries.  Stay tuned.

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: