On this Page
In this Section
Overview
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.
Input and Output
Expected input:
- First input view: The document upon which the Python script is to be executed.
- Second input view: The Python script to be executed.
Expected output:
- First output view: The output from the Python script's execution.
- Second output view: The STDOUT redirected from the RPE.
Expected upstream Snaps:
- First input view: Any Snap that has a document output view. For example, CSV Generator, or a combination of File Reader and CSV Parser.
- Second input view: You can use Snaps that read script files from the SLDB or external locations such as GitHub. For example, a combination of File Reader and Binary to Document.
Expected downstream Snaps:
- First output view: Any Snap that accepts a document input. For example, Mapper, or a combination of JSON Formatter and File Writer.
- Second output view: Any Snap that accepts a document input. For example, Mapper, or a combination of Document to Binary and File Writer.
Prerequisites
The RPE should be installed and running before using this Snap. See Remote Python Executor Installation for steps to install the RPE.
Configuring Accounts
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.
Configuring Views
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. |
Troubleshooting
None.
Limitations and Known Issues
None.
Modes
- Ultra Pipelines: Works in Ultra Pipelines.
Snap Settings
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: Functions in the default script There are three main functions:
The first function (snaplogic_init) is executed before consuming input data. The second function (snaplogic_process) is called on each of the incoming documents. The last function (snaplogic_final) is processed after all incoming documents have been consumed by snaplogic_process. |
Page lookup error: page "Anaplan Read" not found. If you're experiencing issues please see our Troubleshooting Guide. | Page lookup error: page "Anaplan Read" not found. If you're experiencing issues please see our Troubleshooting Guide. |
Examples
Case Conversion
This example demonstrates using a Python script to convert all lower-case characters in an incoming document to upper-case characters.
Download this pipeline.
Additional Examples
The following use cases demonstrate a few real-world scenarios for using this Snap:
Downloads
Important steps to successfully reuse Pipelines
- Download and import the Pipeline into SnapLogic.
- Configure Snap accounts as applicable.
- Provide Pipeline parameters as applicable.