Executes a python script via system python or reticulate.
Super class
HydraR::AgentNode -> AgentPythonNode
Public fields
scriptCharacter string or Function. The python script to execute.
engineCharacter. Execution engine ("system2" or "reticulate").
Methods
Method new()
Usage
AgentPythonNode$new(
id,
label = NULL,
script,
engine = "system2",
params = list()
)Examples
if (FALSE) { # \dontrun{
# 1. Pure system-level Python execution (isolated process)
node_sys <- AgentPythonNode$new(
id = "py_cleaner",
script = "print('Cleaning data...'); result = 10",
engine = "system2"
)
# 2. Reticulate-based execution with shared memory
# This allows the 'result' variable in Python to be returned as an R object.
node_retic <- AgentPythonNode$new(
id = "py_stats",
script = "
import numpy as np
data = np.array([1, 2, 3, 4, 5])
result = data.mean()
",
engine = "reticulate"
)
# Execute and retrieve the 'result' object
res <- node_retic$run(state = AgentState$new())
message("Mean calculated in Python: ", res$result)
} # }