tupa-pyffi 0.11.0

Python FFI bindings for Tupã — call Python functions from pipelines
Documentation

tupa-pyffi

Python FFI bindings for Tupã — call Python functions from Rust pipelines.

Overview

Enables interoperability with Python libraries (NumPy, PyTorch, TensorFlow) by allowing Tupã pipelines to invoke Python functions as steps.

Status: Alpha (0.10.x). API may change before 1.0.

Installation

[dependencies]
tupa-pyffi = "0.10"

Note: Requires Python development headers installed on the system.

Quick Example

use tupa_pyffi::call_python_function;
use serde_json::json;

// Call math.sqrt from Python. Returns a `serde_json::Value`.
let result = call_python_function("math", "sqrt", json!(16.0))?;
assert_eq!(result, json!(4.0));

Usage in Pipeline

use tupa_core::pipeline;
use serde_json::json;

fn python_step(input: &MyInput) -> Result<serde_json::Value, String> {
    call_python_function("my_module", "process", json!(input))
        .map_err(|e| e.to_string())
}

pipeline! {
    name: MyPipeline,
    input: MyInput,
    steps: [
        step("python") { python_step(&input)? }
    ],
    constraints: []
}

Multi-Argument Calls

use tupa_pyffi::call_python_function_with_args;

let args = vec![
    json!(10.0),
    json!(20.0),
];
let result = call_python_function_with_args("my_module", "add", args)?;

Reset Global State

use tupa_pyffi::reset_python_bridge;

// Reset Python interpreter state (useful for testing)
reset_python_bridge();

Supported Types

  • i32, u64, u32, f32 — numeric primitives
  • Vec<u8> — byte arrays
  • Vec<Value> — JSON arrays
  • serde_json::Value — arbitrary JSON

License

Apache-2.0

Links