The python3 component supports running Python 3 code.
Actions
Action | Description | Use case |
| Runs a Python 3 script | Runs a Python 3 script |
Configuration example
This section provides parameter configuration examples for each action of the python3 component. You can import them as a test playbook. The visual flow editor helps you view and test configuration parameters intuitively and understand the component logic and usage. For the import procedure, see Playbook import.
Save the example data as a JSON file first.
runPythonScript
Python 3 code runs in a built-in Python 3.9 container that belongs to your Alibaba Cloud account. The container provides 0.25 vCPU and 256 MB of memory. The maximum execution time for scripts is 600 seconds.
Configuration
The component parameter configuration has two parts:
Parameter area: Configure parameter names and parameter values.
Parameter name: Custom names are supported. In your Python code, use
execute["parameter_name"]to retrieve parameter values.Parameter value: Supports constants, strings, JSON, arrays, and output values from preceding nodes.
Test data: The data values used when testing your Python code.
Code area: Write Python code online. The execute function parameter name is customizable and receives the parameters configured in the parameter area.
Execution result area:
Execution result: Click Run to view the Python code output or error messages in this area.
Execution log: View log output to debug Python script errors, such as checking execution position and computation output.
NoteOnly
warn,info, anderrorlog levels are supported.Log output has a delay. Click Refresh to get the latest entries.
Example
Example:
The input parameter name is
ip, and the parameter value is the ip field output from the preceding node (named "DataFormat").Uses "params" as the execute function parameter to receive the ip parameter.
Uses
logging.infoto output logs to the execution log.
The parameter value expression is ${DataFormat.datalist.*.ip}, and the test data is 127.0.0.1. The function return structure is {"success": True, "message": "OK", "data": [{"ip": ip}]}. The execution log outputs enter execute,ip is 127.0.0.1, indicating that the script ran successfully.