Class ExternalPythonExecutionStrategy
java.lang.Object
ai.nervemind.app.executor.script.ExternalPythonExecutionStrategy
- All Implemented Interfaces:
ScriptExecutionStrategy
@Component
public class ExternalPythonExecutionStrategy
extends Object
implements ScriptExecutionStrategy
External Python execution strategy using subprocess.
Executes Python code using the user's installed Python interpreter via subprocess. This provides full access to the Python ecosystem including pip-installed packages.
Features
- Full Python standard library access
- pip packages available
- Any Python version supported (3.8+)
- Virtual environment support
Limitations
- Requires Python to be installed
- Slower startup than embedded mode
- Less sandboxed (can access filesystem)
Available Globals
input/$input- Data from previous nodes (dict)node/$node- Current node parameters (dict)
Example
import json
# Access input data
items = input.get('items', [])
# Use any Python feature
result = {
'count': len(items),
'processed': [x.upper() for x in items]
}
return result
-
Constructor Summary
ConstructorsConstructorDescriptionExternalPythonExecutionStrategy(com.fasterxml.jackson.databind.ObjectMapper objectMapper, SettingsService settingsService) Creates a new external Python execution strategy. -
Method Summary
Modifier and TypeMethodDescriptionexecute(String code, Map<String, Object> input, ai.nervemind.common.domain.Node node, ExecutionService.ExecutionContext context) Execute a script with the given input data.Get information about why this strategy might not be available.Get a human-readable name for display.Get the language identifier this strategy handles.booleanCheck if this strategy is available (dependencies installed, etc.).
-
Constructor Details
-
ExternalPythonExecutionStrategy
public ExternalPythonExecutionStrategy(com.fasterxml.jackson.databind.ObjectMapper objectMapper, SettingsService settingsService) Creates a new external Python execution strategy.- Parameters:
objectMapper- the ObjectMapper for JSON serialization/deserializationsettingsService- the settings service for configuration access
-
-
Method Details
-
execute
public Map<String,Object> execute(String code, Map<String, Object> input, ai.nervemind.common.domain.Node node, ExecutionService.ExecutionContext context) throws ScriptExecutionExceptionDescription copied from interface:ScriptExecutionStrategyExecute a script with the given input data.- Specified by:
executein interfaceScriptExecutionStrategy- Parameters:
code- the script code to executeinput- input data from previous nodesnode- the node being executed (for accessing parameters)context- the execution context- Returns:
- output data including script results merged with input
- Throws:
ScriptExecutionException- if execution fails
-
getLanguageId
Description copied from interface:ScriptExecutionStrategyGet the language identifier this strategy handles.- Specified by:
getLanguageIdin interfaceScriptExecutionStrategy- Returns:
- the language ID (e.g., "javascript", "python")
-
getDisplayName
Description copied from interface:ScriptExecutionStrategyGet a human-readable name for display.- Specified by:
getDisplayNamein interfaceScriptExecutionStrategy- Returns:
- display name (e.g., "JavaScript (GraalJS)", "Python (GraalPy)")
-
isAvailable
public boolean isAvailable()Description copied from interface:ScriptExecutionStrategyCheck if this strategy is available (dependencies installed, etc.).- Specified by:
isAvailablein interfaceScriptExecutionStrategy- Returns:
- true if the strategy can be used
-
getAvailabilityInfo
Description copied from interface:ScriptExecutionStrategyGet information about why this strategy might not be available.- Specified by:
getAvailabilityInfoin interfaceScriptExecutionStrategy- Returns:
- diagnostic message, or empty string if available
-