# Rodar Python
Python script engine adapter for [Rodar](https://github.com/rodar-project/rodar).
Enables Python scripts in BPMN ScriptTask elements by implementing the
`Rodar.Expression.ScriptEngine` behaviour.
## Status
**Not yet implemented.** The engine stub is in place but returns `{:error, :not_implemented}`.
## Planned Approach
Use [Erlport](https://github.com/erlport/erlport) to communicate with a Python interpreter
via Erlang ports. This provides process isolation and leverages the full Python ecosystem.
Alternative: [Pythonx](https://github.com/cocoa-xu/pythonx) — embeds Python via NIF for
lower-latency calls, at the cost of tighter coupling.
## Installation
Once published, add to your `mix.exs`:
{:rodar_python, "~> 0.1.0"}
## Usage
Register the engine on application start:
Rodar.Expression.ScriptRegistry.register("python", RodarPython.Engine)
Then use `scriptFormat="python"` in your BPMN diagrams:
<scriptTask id="task1" name="Python Task" scriptFormat="python">
<script>result = data["count"] + 1</script>
</scriptTask>
## Key Considerations
- **Process management**: Python interpreter lifecycle — pool of persistent workers
vs spawn-per-eval. Consider using a pool library like Poolboy.
- **Sandboxing**: Restrict imports and builtins for untrusted scripts. Python's
`RestrictedPython` package can help.
- **Data marshalling**: Use JSON for safe serialization between BEAM and Python.
Complex types (dates, decimals) need explicit conversion.
- **Timeouts**: Python scripts should have execution timeouts to prevent runaway processes.
- **Dependencies**: Consider whether to support `pip` dependencies per-process or
require a pre-configured Python environment.
## License
Apache-2.0 — see [LICENSE](LICENSE).