Code Runner
Last updated
Last updated
Code Runner allows the user to use Python code to perform operations.
The output should be stored in a variable called response at the end of Code Runner.
response = "Hello World"
The previous step responses from Data Hub can be used in Code Runner by enclosing the step number (optionally followed by a dot and variable name in case of nested structure) within double curly brackets.
Allowed packages: JSON, datetime, math, re and time
Allowed built-in methods: min, max, len, range, all, any, bool, dict, enumerate, filter, float, int, isinstance, list, map, reversed and sum
Other than the above-specified packages and built-in methods, no other packages can be imported as Import
is restricted.
Code Runner should have a variable called response
which holds the final result. If there is no variable called response, there will be a validation error.
Example 1:
Output:
{"ids": [1,3,5,6]}
Example 2:
Output:
True
Importing other packages/modules is not allowed in Code Runner. If imported, the code will throw an error and will not be executed.
Example:
Output:
Execution failed because import found in code
The usage of built-in methods other than the listed methods is not supported.
Example 1: Using an allowed built-in method
Output:
1
Example 2: Using a not allowed built-in method
Output:
name 'type' is not defined
If any restricted methods are needed for you, reach out to us with your use case by raising a ticket in the Support Portal.
3 minutes
If the code takes more than that for execution, a timeout occurs and an error is thrown.
Changing the result of the previous step is restricted in workflows. However, with the help of Code Runner, any previous step from the Data hub can be duplicated and modified. The response of Code Runner can be used where the modified data is needed.