Python¶
This plugin allows execution of Python code on streamed data using the GraalVM Python engine.
Features¶
- Execute Python code on input data
- Load Python code from a file or provide it inline
- Set a timeout for Python execution
- Access input data from Python
- Emit output data from Python
The Python processor can also be configured to limit script execution time.
Python API¶
The JavaScript code can access the input
data passed to the processor.
The Python code should define a process
function that takes the input data and returns the output data:
def process(input):
# Process the input data
return output
Security Considerations¶
The Python processor runs with limited permissions by default. It cannot access the file system, network, or other system resources unless explicitly allowed.
.processWith(PythonConfigBuilder.builder()
.withScript(value)
.withScriptUrl(value)
.withTimeout(value)
)
processor:
python:
script: value
scriptUrl: value
timeout: value
Java dependency management¶
Add this declaration to your dependency management system to access the configuration DSL for this plugin in Java.
<dependency>
<groupId>org.voltdb</groupId>
<artifactId>volt-stream-plugin-python-api</artifactId>
<version>1.0-20250910-124207-release-1.5.3</version>
</dependency>
implementation group: 'org.voltdb', name: 'volt-stream-plugin-python-api', version: '1.0-20250910-124207-release-1.5.3'
Properties¶
script
¶
Python code to execute
Type: string
scriptUrl
¶
URL to a Python file to execute
Type: string
timeout
¶
Maximum execution time in milliseconds
Type: object
Default value: 1s
Usage Examples¶
Capitalise all strings.
version: 1
name: PythonProcessorExample
source:
file:
path: "input.txt"
pipeline:
processors:
- python:
name: "python-processor"
script: |
def process(input):
if isinstance(input, str):
return input.upper()
return input
sink:
stdout: {}