Python Module
  • 21 Mar 2023
  • 3 Minutes to read
  • Dark
    Light

Python Module

  • Dark
    Light

Article Summary

Module Details

Core or Github ModuleCore
Restart Required No 
Steps ExposedYes
Step Location Integration > Python
Settings Location System > Settings Python Module Settings
Prerequisites
  • A version of Python installed on the Decisions environment
  • Access to the file path to the Python directory after installation

The Python Module allows custom scripts written in Python to be created and used as steps inside a Flow.

In order the utilize the module the file path must contain the Python executable to be ran. For example, C:\Program Files\Python\python.exe will be entered in Python Module Settings.


Settings

Navigate to System > Settings. Click on Python Module Settings and enter the full file path to the Python executable. Click SAVE once the file path has been configured. In order to update the file path, Decisions must be restarted.

Feature Details
Introduced in Version8.10
Modified in Version--
LocationSystem > Settings > Python Module Settings

Python Module in Container

In order to use the Python module in containers, Decisions has included Python in the container image. The container will have the most up-to-date version of Python installed. The default path for Python in containers is at /usr/bin/python3.

After installing the Python module, users need to point Python Module Settings path to /usr/bin/python3.

Creating Script Projects

Script Projects house Python Scripts that will be generated as steps They are mainly used for organization, as the name of the Script Project will appear as a sub-category under Integrations > Python in the step Toolbox.

  1. Navigate to System > Integrations. Right-click Python Script Projects and select Add Script Project. Name the project and click SAVE.

Adding Python Scripts

The following Python script will be used in the example.

import sys
def main():
    print("Welcome", sys.argv[0])
    if len(sys.argv) == 3:
        print(" ", sys.argv[1], " ", sys.argv[2])
if __name__ == "__main__":
    main()
  1. Right-click on the Script Project and select Add Script.
  2. Name the script and upload the Python file. Enter names for the Inputs (string1, string2) and click SAVE.

Below are the settings that can be configured when for a script.

SettingDescription
NameThe name that will be given to the step when accessed in a Flow.
DescriptionA textbox which can be used to describe the script when inside of a Flow.
Read Python Path FromSets the file path used to search for the Python executable. If this is set to Default, the step will use the file path that was configured in System > Settings > Python Module Settings. If this is set to Custom, a new textbox will appear, allowing the file path to be specified.
FileThe file containing the python script.
Working DirectoryThe working directory used to search for the executable and store generated files. If no values are entered, this location will point to: C:\Program Files\Decisions\Decisions Server
InputsCustom inputs that are used in the script

Python Scripts as Flow steps

  1. To add the Python script to a Flow, navigate to Integrations > All Integrations > Python. Then, select the Python project and select the script and click ADD.
  2. With the step selected, change the input value mappings to Constant and enter "Hello" for string1 and "World" for string2.
  3. Add a Show Popup step to the Success path. Enter "Message" as the Subject. Click Unknown next to the Message field and select Select From Flow. Select Script Output [String] and click DONE.
  4. Connect the Error path and Done path to the End step.
  5. Click Save to save changes to the Flow. In the Flow Designer select debug and view inputs/outputs to the step. If the step succeeded, the output will display the configured result in the script.

Execute Python Script Step

The Execute Python Script step allows Python scripts to be executed without the need to create a Script Project. However, only parameter values can be passed to the script, the values cannot be defined in the Flow.

InputDescription
Parameter(s)The parameter inputs to the Script
Script FileSimilar to the File input when configuring a Script as a Flow step, this will be the file containing the Python script. 
Working DirectoryThe input controls the first location used to search for the Python executable, along with being the location custom files will be outputted from the script.


For further information on Modules, visit the Decisions Forum.

Was this article helpful?