On this Page
In this Section |
The Remote Python Script Snap is a Transform type Snap that enables you to execute a Python script on a Remote Python Executor (RPE). The RPE can be installed on the same node as the JCC or elsewhere. The location of the RPE is specified in the account. See Remote Python Executor Installation for steps on installing the RPE.
The Snap has an additional Input and Output view. You can use the second Input view to pass a script to the Snap, in which case the default script within the Snap is ignored. This is useful in case the script is stored in external locations such as GitHub or SFTP server. The second Output view shows the standard output (STDOUT) redirected from the RPE.
Expected input:
Expected output:
Expected upstream Snaps:
Expected downstream Snaps:
The RPE should be installed and running before using this Snap. See Remote Python Executor Installation for steps to install the RPE.
This Snap uses account references created on the Accounts page of SnapLogic Manager to handle access to this endpoint. See Remote Python Executor Account for information on setting up this type of account.
Input | This Snap has at most two document input views. |
---|---|
Output | This Snap has at least one and at most two document output views. |
Error | This Snap has at most one document error view. |
None.
None.
Label | Required. The name for the Snap. Modify this to be more specific, especially if there are more than one of the same Snap in the pipeline. | |||
---|---|---|---|---|
Edit Script | Required. The Python script to be executed. Click Edit Script to open the script editor. The editor contains a default Python script, edit it as required or supply another script through the second input view. The default script writes the input documents to the $original field in the output. Default value: Default Python script as shown below:
| |||
Prerequisites:
Remote Executor Account.
This example pipeline demonstrates how to use the pipeline parameters to execute the Python Script remotely to get the desired output.
Step 1: Configure the pipeline parameters as follows:
Step 2: In the Remote Python Script Snap, update the script as follows to use or access pipeline parameters. In the below code, we have captured the parameter keys num1
and num2
values to return the appended value of parameters.
Step 3: Validate the pipeline. The script is run using the pipeline parameters on the Remote Python Executor. You can view the output of the Python script in the output preview.
This example demonstrates using a Python script to convert all lower-case characters in an incoming document to upper-case characters.
Download this pipeline.
The input to the Remote Pyhon Script Snap is a CSV document generated by the CSV Generator Snap. Below is a preview of the CSV Generator Snap's output: The Remote Python Script Snap is configured with the following script:
When executed, the script converts all lower-case characters in $text to upper-case characters. This is shown in the output preview of the Remote Python Script Snap below: Download this pipeline. |
The following use cases demonstrate a few real-world scenarios for using this Snap: