Dynamic node

Node annotations

Data types of nodes' inputs are variant such as numbers, texts, lists, etc. Some inputs can carry a set of possible values or values with a predetermined range as a condition to make the node works correctly. For that, Baseet.ai offers a feature for the node's inputs to be dynamic using predetermined annotations. As an example, if we have a numeric input, takes the value between 50 and 100 to work correctly, then instead of making the input as an open number that the user may input a number outside this range, we offer a slider option with min, max, and step value.

Another example, an input takes a text value but with a set of possible options, for example, the optimizer used in machine learning models, the developer can set the possible options to make the user choose from them, instead of making the input open with the possibility of misspelling.

Using @renderInput annotation the developer can determine the render type of the input and rules of it as will be illustrated later in the samples.

Users can execute Baseet.ai applications from the app editor, the app form, and using an API. In some cases, the app developer wants the user to fill some inputs values as mandatory, while other inputs are from outputs of previous nodes so no user input is required. So, Baseet.ai offers three options which are:

  • @Required: indicates it's a mandatory input and will be shown to the user.

  • @Hide: indicates it's a hidden input and will not be shown to the user in the application form.

  • @ignoreAPI: indicates it's a hidden input and will not be shown to the user in the API.

Given that the user can show all inputs from the app editor, and by default any input connected with an output from a previous node, it will be hidden from the API and form.

So here are samples of different data types inputs:

Sample 1: Numeric input:

num1 is a number taking values between [10,100] each step is 10 (i.e. accepted values, 10,20,30,...,100), assume we want this input to be shown to the user, then the annotation of this input will be as follows:

num1:int= 30 #@Required @renderInput {"type": "slider","rules":{"min": 10,"max": 100,"step":10, "default":30}}

Sample 2: Date Input:

birthdate:str="" #@Required @renderInput{"type":"date","rules":{"format":"yyyy-mm-dd","default":"2020-01-07"}}

Sample 3: Drop-down list with one selection:

modelname:str="Logistic Regression" #@Required @renderInput {"type":"dropdown","rules": {"items":["AutoML","Logistic Regression", "Support Vector Machines", "K-Nearest Neighbors", "Naive Bayes", "Decision Trees", "Neural Network", "Random Forest", "Voting Classifier", "AdaBoost" ,"AutoML"],"default":"Logistic Regression"}}

Sample 4: Drop-down list with multiple selection:

fruit:list= ["orange"] #@Required @renderInput {"type":"dropdown", "rules": { "multi":true, "items": ["banana","apple","orange","broccoli","carrot","], "default": ["orange"] } }

Sometimes the input variable name is Abbreviated as it must follow coding rules, but this name sometimes is not clear enough for the users, so Baseet.ai offers @alias annotation to use to show that alias instead of the actual input name, here is a sample:

num2:int= 30 #@Required @alias "Please input the required size" @renderInput {"type": "slider","rules":{"min": 10,"max": 100,"step":10, "default":30}}

If you want to add a description of a specific input variable, you can use @docString annotation, as we hover over the input name, the text will be shown as follows:

@docString {"text": "description of your input"}

Note that rendering annotations are optional and based on your needs. So if you don't need to render input, it will be rendered by default as a string and will be converted based on the data type you determine when you declare the input.

If you want to render an input of image or video, then use built-in nodes by Baseet.ai which are: Image input node & Video render node, as follows:

Baseet.ai offers also render for output, for example to render an image output use Image / Figure preview node or simple use this annotation:

node_previewImg:str = "" #@renderOutput {"type": "image"}

For render video as output, use the same built-in Video render node.