Skip to content

Work with the function operator

UbiOps pipelines come with some predefined operators that you can use. One of those operators is the function operator. This operator is used to manipulate one or multiple of your output data fields before passing it on to the next pipeline object.

Let's say that you want to divide the output from an example model by a hunderd, because you want to convert its units from centimeters to meters. To implement this, we use the Function operator.

Configure the function operator

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

Field Description
name function
reference name function
reference type operator
configuration (example) {
"expression": "input / 100",
"input_fields": [{"name": "input", "data_type": "int"}],
"output_fields": [{"name": "output", "data_type": "int"}]
}

In this example, we require one input field named input of data type Double precision. The Expression field is used to transform the input fields to an output via a one-line Python expression. For our example, we insert the following Expression:

input / 100

The output of our Function operator will be a data field that is called output, of data type Double precision. Your set-up should now look as follows:

Example pipeline with the function 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 Function operator by clicking on 'save'. This creates the Function operator object.

Connect the function operator

We now connect the Function operator to the other elements of our pipeline. We add one pipeline connector between the source object example-model and the Function operator and map the input and output fields accordingly. Similarly, we add one connector between the Function operator and the output of the pipeline.

Example pipeline with create subrequests operator

That's it. We have created a pipeline that implements the Function operator. If you get run into any issues though, do not hesitate to contact support.