Bridge tasks#

Bridge tasks allow users to add external scripts to their data in Rulex Factory: sometimes it might happen that user already have statistical algorithms to integrate to their flow, or it might be needed to perform certain operations requiring a low level programming language.

The following external scripts are supported in Rulex Factory:

  • R

  • Python

In the Bridge task family, the following tasks are provided:

  • R Bridge: applies R scripts to data elaborated in Rulex.

  • R Import Bridge: imports data from R scripts into Rulex.

  • Python Bridge: applies Python scripts to data elaborated in Rulex.

  • Python Import Bridge: imports data from Python scripts into Rulex.

Python Bridge and R Bridge tasks

To use these tasks, it is necessary to install Python3, IPython 3 and Miniconda.

See also

The format data in Python is a dictionary that associates to each column name (key) the list of values of the column itself (values), for example: "age" : [39, 45,...] "workclass" : ["Private", "State-gov",...]

Warning

It is strongly recommended to use Python 3.10. After having installed Miniconda, it is recommended to check on the machine where Rulex Platform is running if Python 3.10 has been installed. If not, the user must install it manually.


Bridge tasks layout#

Once opened on the interface, all the tasks listed above have the same layout.

Users can distinguish two areas:

Configuration area

The configuration area is divided into two tabs, the Advanced Configuration and the Configuration.

Despite their location on the interface, it is strongly recommended filling the Advanced Configuration tab first.

Advanced Configuration

In this tab, the executable details must be defined. To do so, the following options are provided:

  • Select Executable type: select the executable type which will be used in the task. Possible values are:
    • Conda (default)

    • Python/ R

  • Executable file area: drag the conda/Python/rterm executable file, according to the chosen Executable type option.

Configuration Tab

In this tab, users can set the environment where the script will be run.

Caution

The configuration options are available only if Conda has been selected in the Select Executable type option in the Advanced Configuration tab.

The options available are:

  • Use User Environment: if selected, the user environment will be used. In the cloud/server version, it is the only option available. This checkbox is available only if Conda has been chosen as the executable file type.

  • Select Conda Environment: select from this drop down list the Conda environment which will be used in the task. It is available in the standalone version only.

Code area

This area is divided into two tabs: the Console and the Script tabs.

Console

In this tab, a console is provided, where users can write their Python/R code and test it, as it works like a normal Python/R console. The code isn’t saved within the task. The following options are provided:

  • Connect Python/R Bridge: click on this button to open the Interactive Console.

  • Save History: click on this button to save the changes made to the code. Once this button has been clicked, the code will be printed in the Script tab.

  • Clear History: click on this button to delete all the changes made to the code.

  • Interactive Console: write the code which will be executed within the task.

Hint

The input dataset is converted to a Pandas DataFrame and automatically stored as r_dataset into the task. So, when writing code referring to the source dataset in Python Bridge and R Bridge tasks, the file must be referenced as r_dataset.

The flow variables are received automatically by the task, and must be referenced as r_vars into the task, when writing code referring to the flow variables in Python Bridge and R Bridge tasks.

Script

In the Script tab users can execute the Python/R code written in the Interactive Console and visualize its results. This tab is made of the following elements:

  • Python/R Editor: in this text area, users can edit the code written in the Interactive Console.

  • Execute Code: click this button to execute the code and visualize the results in the Last Execution Output area.

  • Save Code: click this button to save the code written in the Script tab.

  • Last Execution Output: in this area, the output of the last code execution is visualized.