Skip to main content

flyteplugins-rs

[!WARNING] Experimental. The APIs and wire contracts may change without notice.

Launch Rust Flyte tasks from Python.

A Rust task container runs a compiled binary and no Python. This package is the launch-time half: it reads a worker binary's self-described interface, declares the matching Flyte task, and builds the worker image from Rust sources.

pip install flyteplugins-rs
from pathlib import Path

import flyteplugins_rs as rs

my_task, rust_env = rs.rust_task(
    crate_dir=Path(__file__).parent,
    binary="hello-trace",
    retries=2,  # any TaskTemplate option passes through
)
flyte run task.py my_task --x 21 --label demo

The task's name, inputs, and outputs are never written here — they come from the Rust fn signature, so renaming a parameter cannot silently diverge from what gets launched.

rust_env is the environment holding the task. A Python parent calling it needs depends_on=[rust_env], which carries the worker image into the deployment plan:

env = flyte.TaskEnvironment(name="my_pipeline", depends_on=[rust_env])

@env.task
async def pipeline(x: int) -> str:
    return await my_task(x=x, label="demo")

What it does

  • Interface — runs <binary> describe-interface when a local build exists, and refreshes the generated _generated_interface.py from it. Inside a container (no cargo build) the generated module is used instead.
  • Image — declares the worker image as flyte.Image layers, so the remote image builder can compile it (no Dockerfile, no local docker). No layer asks for Python, so the image gets no venv.
  • Task — a container task typed rust-task, whose args match the worker's contract, and whose args[0] is the binary (image layers cannot set an ENTRYPOINT).

Bringing your own Dockerfile

By default the worker image is declared as flyte.Image layers, which is what lets the remote builder compile it with no docker on your machine. When that is not enough — a private base image, extra system libraries, a multi-stage build that keeps the Rust toolchain out of the final image — pass a Dockerfile instead:

my_task, rust_env = rs.rust_task(
    crate_dir=Path(__file__).parent,
    binary="hello-trace",
    dockerfile=Path(__file__).parent / "Dockerfile",
)

Three things such a Dockerfile has to get right:

  1. Install the binary at /usr/local/bin/<binary>. The task passes that exact path as args[0]; it is the one hard-coded contract between the image and the task.
  2. Ship libpython. flyte_core enables pyo3/auto-initialize, so the worker links against it. A slim runtime stage needs the libpython3.N package, not just the python3 interpreter — Debian's python3 links it statically and does not provide the shared object.
  3. An ENTRYPOINT is optional. With none set, Kubernetes execs the args directly. Setting one is fine too: the worker skips a leading token it does not recognise, so one arg list works either way.

The build context is the directory holding the Dockerfile, so COPY paths are relative to it. workspace= and dockerfile= are mutually exclusive — a Dockerfile brings its own context, so put the copying in the Dockerfile.

[!IMPORTANT] Custom Dockerfiles build only with the local docker builder. The remote builder takes declarative layers, not a Dockerfile it would have to parse, and rejects one outright. With image: {builder: remote} in your config, this path needs flyte --image-builder local run and a working local docker.

A worked example is the custom-image example: multi-stage so the toolchain does not ship, and installing a system package the task actually depends on.

Two extra requirements. flyte.Image.from_dockerfile has no registry to inherit, so set RUST_IMAGE_REGISTRY or pass registry=. And the image is named <binary>-worker unless image_name= says otherwise — the first push to a name creates a new repository, which registries like GHCR make private by default, so the build and push succeed and the task then cannot start. Make the package public once, or point image_name= at one that already exists.

Compatibility

The launcher and the worker agree on a versioned descriptor contract, currently flyte_interface_version = 1. A worker built against a newer SDK is refused at launch with a message naming both sides, rather than failing inside the container. Package versions are deliberately not kept in step with the flyte Rust crate's — see docs/releasing.md.

Developing

To run against a checkout instead of the released package:

git clone https://github.com/flyteorg/flyte-sdk-rs && cd flyte-sdk-rs
./scripts/dev-setup.sh

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flyteplugins_rs-0.0.3.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flyteplugins_rs-0.0.3-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file flyteplugins_rs-0.0.3.tar.gz.

File metadata

  • Download URL: flyteplugins_rs-0.0.3.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for flyteplugins_rs-0.0.3.tar.gz
Algorithm Hash digest
SHA256 8795682ca78f18a9e1ca085b16d0adeb6ea7062525e0a6e79230f702d7af27c5
MD5 83acace67ecfd02a328177b4ee8bae51
BLAKE2b-256 0f36eddd1768c2ab00934aa8d02d85f4dc9ffe466c9607eeba218908f1dbd2d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for flyteplugins_rs-0.0.3.tar.gz:

Publisher: release-python.yml on flyteorg/flyte-sdk-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flyteplugins_rs-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: flyteplugins_rs-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for flyteplugins_rs-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3f96c38ff5066beca6ef8f7d0e65fd96e4a67fdd6f891871dd8021e14658e5fb
MD5 026d46eb078e8cb74bf36c85140d35b4
BLAKE2b-256 d1b9136cbea471e8c4e17210f0efcfea581496df61559bb10c8ae28d0087bc19

See more details on using hashes here.

Provenance

The following attestation bundles were made for flyteplugins_rs-0.0.3-py3-none-any.whl:

Publisher: release-python.yml on flyteorg/flyte-sdk-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page