Skip to content

Work with the conditional logic operator

UbiOps pipelines come with some predefined operators that you can use. One of those operators is the Conditional Logic operator. The Conditional Logic evaluates expressions as boolean, and uses this boolean to determine if the next deployment in your pipeline should be activated. In this how-to, we show how you can use the conditional logic operator, to throw an error if your model provides unwanted results.

Configuring the conditional logic operator

Once you have added the function operator to your pipeline canvas, the UI will prompt you to provide an Expression and an Input field that can be used inside the Expression. If you want to add this operator using the Client Library you need to provide the following parameters:

Field Description
name if-condition
reference name if-condition
reference type operator
configuration (example) {
"expression": "probability>=1 or probability<0",
"input_fields": [{"name": "probability", "data_type": "double"}],
"output_fields": [{"name":"output", "data_type":"int"}]
}

The expression refers to the conditional expression to evaluate. Let us assume that we want to perform a unit test on our model. To this end, we want to check if the probability of a certain classification is within range, i.e. if it is larger than zero and smaller than one. We insert the following Expression:

probability>=1 or probability<0
The conditional logic operator has no output field, and only determines if the next step in your pipeline is executed. Your set-up should now look as follows:

Example pipeline with the conditional logic operator

In the Test expression tab, you can try out various cases by instering dummy data and evaluating the results. If the results are correct, you can create the conditional logic operator operator by clicking on 'save'. This creates the Function operator object.

Integrating the conditional logic operator into your pipeline

The conditional logic operator decides if the next step in the pipeline is executed. You could for example raise a custom error using the Raise error operator. To see how, check out the raise error how-to

Example pipeline with the conditional logic operator

That's all there is to this operator. If you run into any issues though, do not hesitate to contact support.