Skillable Studio allows execution of scripts against a cloud subscription, as well as executing scripts that do not have a target. Scripts are used in Automated Activities and Life Cycle Actions.
Using Python Import Keyword
The import
keyword is used to import modules.
#Import the datetime module and display the current date and time
import datetime
x = datetime.datetime.now()
print(x)
Interacting with Skillable Studio
Your scripts can communicate success or failure to Skillable Studio in one of two ways.
Return a Boolean value
//do stuff... all good
return True;
//do stuff... uh oh
return False;
Use setActivityResult
//do stuff... all good
setActivityResult(True);
//do stuff... uh oh
setActivityResult(False);
You can also report the result as a score %...
//do stuff... we want to report success and set the score value as 50%
setActivityResult(0.5);
Send a Notification to the User
Notifications appear as real-time toast notification in the lab client.
sendLabNotification("A notification from Python!");
Lab Variables
Lab variables are always string name/value pairs. Variable values are scoped to the lab instances and become available within the lab instructions as well as subsequent script executions.
setLabVariable("myVariable1", "This was set by Python in the cloud!");
You can "receive" a variable in your script...
#a variable set elsewhere in the lab, but we can use it in our script
const myVariable1 = "@lab.Variable(myVariable1)";
Use setActivityResult
If you choose to use setActivityResult, the last time it is called within your script will determine the outcome.
setTimeout(function() {
console.log("This message was left inside the async code.");
setActivityResult(True);
}, 1000);
return False; //<- this will have no effect, as it will be evaluated before the async code is run.