Importing Data from Python Scripts

You can import data directly from a Python script, either by entering the script directly in the task, or by referencing an external script file.

This type of operation may be useful if you want to apply an external script to data before using it in a Rulex workflow, in order to perform a specific operation that requires a low-level programming language, such as deciphering badly formatted text files.

Prerequisites

  • a Rulex process has been created

  • Python 3 software has been installed where Rulex is running.

  • IPython3 has been installed on the machine where Rulex is running (via pip install ipython)

Additional tabs

The following additional tabs are provided:


Procedure

  1. Drag and drop the Python Import Bridge task onto the stage.

  2. Double click the Python Import Bridge task.

  3. Configure the script options as described in the table below.

  4. Save and compute the task.

Python options

Python options

Name

PO

Description

General options

Get Python script from file

scriptfromfile

Select this option to import the Python script directly from a file, and not by manually entering the Python code below.

Select Python script

filename

Click here and browse to the external file, which contains the Python script you want to apply.

This option will be enabled only if you have selected the Get Python script from file option.

Store output in

outref

Select the type of table that will be populated by the dictionary selected as output in the Python script.

Possible options are:

  • Dataset (i.e. the main data table)

  • Clusters

  • Advanced association structure (association rules, bundle hypotheses or replacement rules table).

Name of the output data frame in Python script

routputname

Enter the name you want to use in the Python script to reference the data Rulex will receive from Python. This data will populate the table according to the option selected in Store output in

Select file to store Python console output

debugfilename

Browse to the text file where the Python script console output will be saved after execution of the Python Bridge task.

Python Code

rcode

Enter the Python script code you want to execute.

This text box is enabled only if you have not selected the Get Python script from file option.

Connection options

Select path to Python command

rcommand

Browse to the location of the IPython interpreter command, which can be found in the Python installation folder. If you have administrator rights on the machine, it will be sufficient to enter ipython3.exe

If the path is not correctly specified, the Python Bridge task will not work correctly and a warning message will be displayed.

The Python task cannot compute if another process is pending. You can monitor this on Windows via the Task Manager (Processes).

Python host

rhostname

Enter the address of the host where Python is installed. If Rulex is running on the same desktop where it is installed you can enter localhost.

Python port

rport

Specify the port used for data transfer between Rulex and Python (i.e. input table transfer from Rulex to Python, output dictionary transfer from Python to Rulex).

 

System firewall exception

Make sure you define an exception in the system firewall on this port, allowing the data exchange between the two applications. Otherwise, the task will not be executed and a warning message will be displayed signaling a communication problem between Rulex and Python.

 

Python port for signals

rportaux

Specify the port used for signal transfer between Rulex and Python (i.e. progress bar updates).

 

System firewall exception

Make sure you define an exception in the system firewall on this port, allowing the data exchange between the two applications. Otherwise, the task will not be executed and a warning message will be displayed signaling a communication problem between Rulex and Python.

 

 



Need to get in touch? https://www.rulex.ai/contact/ - Need a license renewal? https://rulex.atlassian.net/servicedesk/customer/user/login?destination=portals
© 2024 Rulex, Inc. All rights reserved.