GraalVM Eval

GraalVM Eval

Certified

Execute inline Python with GraalVM

Runs inline Python inside the task JVM via GraalVM. Access runContext, logger, and rendered variables from the bindings; declare names in outputs to return them. File access through Python (open, os, pathlib, tempfile) is limited to the task working directory (the bundled standard library is read-only for scripts), except for native modules (see below); host class access is restricted to java.* and io.kestra.core.models.*, minus classes that reach files, processes, reflection, or the network. To upload a file, read its bytes and pass them to runContext.storage().putFile(java.io.ByteArrayInputStream(data), 'name'). Optional modules preload Python files from content or kestra:// URIs onto the module path. Supports C-extension-backed stdlib modules such as ssl, sqlite3, and lzma, which requires enabling native access at the GraalVM engine level. Standard OS process APIs (os.system, subprocess) stay blocked, but this grant cannot be scoped down further: a script that reaches native code directly (e.g. ctypes) can still execute arbitrary OS commands, read or write any file the worker can access, or manipulate process memory. Native modules also open files themselves, outside the working directory restriction: sqlite3.connect() can read or create a database file anywhere the worker can. Unlike Kestra's Script/Shell tasks, which typically run in an isolated container or process via a TaskRunner, this code runs inline in the worker JVM process itself, so it has direct access to the worker process's own memory, file descriptors, and any secrets or other task state resident in that JVM. Only run scripts from users already trusted with the flow's credentials and infrastructure, as with any script task.

yaml
type: io.kestra.plugin.graalvm.python.Eval

Parse a downloaded JSON and update one of its fields.

yaml
id: parse_json_data
namespace: company.team

tasks:
  - id: download
    type: io.kestra.plugin.core.http.Download
    uri: http://xkcd.com/info.0.json

  - id: graal
    type: io.kestra.plugin.graalvm.python.Eval
    outputs:
      - data
    script: |
      data = {{ read(outputs.download.uri )}}
      data["next_month"] = int(data["month"]) + 1

Execute a Python script using the GraalVM scripting engine.

yaml
id: evalPython
namespace: company.team

tasks:
  - id: evalPython
    type: io.kestra.plugin.graalvm.python.Eval
    outputs:
      - out
      - map
    script: |
        import java
        import java.io.ByteArrayInputStream as ByteArrayInputStream
        # types other than one coming from the Java SDK must be defined this way
        Counter = java.type("io.kestra.core.models.executions.metrics.Counter")
        logger.info('Task started')
        runContext.metric(Counter.of('total', 666, 'name', 'bla'))
        map = {'test': 'here'}
        content = ByteArrayInputStream('Hello World'.encode('utf-8'))
        out = runContext.storage().putFile(content, 'out.txt')
        {"map": map, "out": out}

Define a Python module, then execute a script that imports this module using the GraalVM scripting engine.

yaml
id: evalPython
namespace: company.team

tasks:
  - id: evalPython
    type: io.kestra.plugin.graalvm.python.Eval
    modules:
      hello.py: |
        def hello(name):
          return("Hello " + name)
    script: |
      import hello
      logger.info(hello.hello("Kestra"))
Properties

Script body to execute

Template-rendered source code run by GraalVM in the selected language; flow variables are resolved before execution

Assets this task consumes as inputs or produces as outputs, for lineage tracking and the asset graph (Enterprise Edition). A flow declaring this property on a task is rejected in the open-source edition.

Definitions
assetFailureBehaviorstring
Possible Values
IGNOREFAILWARN

Asset failure behavior

Behavior applied to the task state when a declared asset fails to render, emit, or be persisted (e.g. a lock conflict): FAIL escalates it to FAILED, WARN (default) warns it if it would otherwise succeed, IGNORE leaves the state untouched.

enableAutobooleanstring

Whether to auto-register assets referenced dynamically at runtime that are not statically declared in inputs or outputs.

inputsarray

The assets consumed as inputs.

id*string
Min length1
typestring
outputs

The assets produced as outputs.

id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*string
Min length1

Custom asset type

descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150

Inline Python modules to preload

Map of filename to module content or a kestra:// URI; files are written to a temporary module path before execution

Advanced GraalVM context options

Maps directly to GraalVM's Context.Builder#options: one entry per option key/value, for example python.WarnOptions or js.ecmascript-version. Keys that would weaken the sandbox already enforced by this task are rejected at execution time: python.PosixModuleBackend, any key related to host access or class loading, and any key prefixed with engine. or sandbox..

SubTypestring

Names of script outputs

Rendered list of member names to pull from the evaluated value or bindings and expose as task outputs

The captured outputs as declared on the outputs task property

Result of the evaluated expression

Unitcount

Tracks a user defined numeric value emitted from the Python script, such as the number of processed records or computed results.