Skip to content

Run a pipeline locally with FFI

Call execute_pipeline_with_input() to execute a manifest through the native runtime. This is useful when your application owns the input and needs the result of one request.

Before you start

Install the client and compatible native runtime. The example uses the built-in PassThrough node and needs no model download or GPU.

Execute a request

From the documentation repository root:

python examples/python/ffi_echo.py

The complete example loads echo.json. Run it with the local environment's Python, or activate that environment first. Its source is included directly here:

"""Execute one request through the native FFI. Requires client + native runtime."""

import asyncio
import json
from pathlib import Path

from remotemedia import execute_pipeline_with_input


async def main():
    manifest = json.loads(Path(__file__).with_name("echo.json").read_text(encoding="utf-8"))
    result = await asyncio.wait_for(
        execute_pipeline_with_input(manifest, ["hello"]), timeout=10
    )
    assert result == "hello", result
    print(result)


if __name__ == "__main__":
    asyncio.run(main())

Expected output is the string hello. The script asserts that result and applies a ten-second application timeout. This return shape was verified with the local FFI profile; other graphs and metrics-enabled calls can return different envelopes.

Choose the execution contract

Entry point Behavior to account for
execute_pipeline_with_input(manifest, [item]) Explicit native path; missing FFI raises an import error
execute_pipeline(...) Native execution without caller-supplied input, for an appropriate source-driven graph
Pipeline.run(input_data, use_rust=True) Attempts native execution and can fall back to Python, including after execution errors
Pipeline.run(..., use_rust=False) Chooses the Python executor

The reviewed wrapper documents manifest execution as validating the input list but executing only its first item. Use one input here. Use a streaming session for repeated requests. Direct Node instance lists follow a different path; their behavior should not be inferred from manifest execution.

Errors and lifecycle

The one-shot call owns its execution; it does not return a long-lived session to close. A timeout limits the application's wait, not proof that all native or worker work has already terminated. Invalid manifests, unknown node types, and missing plugin dependencies must be resolved before execution succeeds.

For long-running work, use a session with an explicit close() in finally. Continue with streaming.