Skip to content

How to create a WhizzML script – Part 2

by on July 28, 2017

In this second post about WhizzML basics, we go deeper into script creation methods. In the previous post, How to create a WhizzML script – Part1, you learned the basic concepts of WhizzML and how to clone existing scripts. In this tutorial, we introduce how to create and edit WhizzML scripts via the Web REPL. Let’s dive in!

WhizzMLLoop

Write your own scripts

Start by selecting “Scripts” under the WhizzML menu.

7

Once you are in the scripts section, you have the options to create a new script by using the editor or import one from GitHub (explained in the next post).

Create a script from scratch with the editor

8

With this option, you can write the code directly in the embedded editor, which provides syntax highlighting and autocomplete capabilities.

On top of the defined directives of the language, you’ll be able to use any procedure defined in a previously created library provided that you import that library first.

Once you have written your new WhizzML script, you should validate it to make sure your code is written with the correct WhizzML syntax. When the script code is validated, our REPL editor will automatically extract the inputs and outputs involved and present them for you to define their types. Errors, if any, will also be highlighted.

The simple WhizzML code in the image gallery below takes a number x as input and returns x+2. So the output (“result”) is also a number. In general, inputs and outputs have many possible types ranging from the basic string, number, boolean, list or map types to any of the resources in BigML, like sources, datasets, models or even scripts and executions. Once the code of your script is validated, you can actually create the script. If you execute it by providing an input of 2, you’ll observe that the output equals 4 as expected. Keep in mind that you can execute a script as many times as you wish in a repeatable and traceable way.

Create a script from an existing one

Imagine you have already executed a script, but you want to slightly modify it. Or you just have an old one you’d like to improve on. In these cases, you can easily create a new script from an existing one. Just navigate to the script you’d like to use and click on the “Create a new script using this one” menu option. Pretty self-explanatory, ha? This should save you a lot of time.

scripteditor

 Web REPL

One way to test WhizzML code is to use the WhizzML REPL. This feature can be found in the BigML LABS section that contains cool new functionality for our users to test before they get queued up to be fully integrated into the Dashboard as part of later releases. The WhizzML REPL is a simple, interactive programming environment that takes single expressions, evaluates them, and returns the result. When you open it, you’ll see a window to write code and a console to run it too. So you can edit your code to your heart’s desire, dynamically run and test it before implementing it in a finished script.

Now you know how to create a WhizzML script in different ways, but there are still more to learn. The next step is discovering how to use GitHub and BigMLer to create scripts and libraries all of which will be covered in our next post.  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: