Adding first Python Script

Clicking on Python Scripts will give a Pop up window showing all the Scripts related the particular Stage. Clicking on a Script Tab a user can Click on I/O , Edit , Delete, Info and Test to check Input/Output, Edit, Delete, get information and test the script.

A User can add a new script by clicking on Icon on this Pop up window. User can provide Script Title and Description and Submit the form to create a new script. User is shown the new script in Edit Tab and here a user can select and add input properties, output properties and Global variables.

For Linear regression on GDP data exercise a User can add Year as input property and newYear as output property.

After adding these Properties a user can use I/O Tab to edit the script. For this example we have normalized Year variable by subtracting 1960 from the value of Year.

# access property of abc using input["abc"]
# print(input["abc"])
# save computed property xyz to the database using output["xyz"] = 1234
​
# stuff to run always here such as class/def
def main():
output["newYear"] = input["Year"]-1960
​
if __name__ == "__main__":
# stuff only to run when not called via 'import' here
main()
​

A default Python script is generated when a User adds a new script. We have just added line no. 7 in the script to normalize the Year variable.

A User can run the unittest on the script on the Test Tab and get the test response as Passed or Failed.

Test Script

import unittest
# You can accesss your script using 'mainscript'
import script_5df1a84dba09a742d900601d as mainscript

​