Skip to main content

Raine

Raine is an MLOps toolkit for the full model lifecycle: data preparation and feature engineering, training pipeline orchestration (Kubeflow), and model serving. The goal is reusable building blocks you can compose across local development and cloud deployment.

Status: only raine.serve.artifacts is implemented and documented today — packaging a handler, traced local code, model assets, and runtime dependencies into a self-contained bundle. Other areas of the repo are work in progress.

Install

pip install raine

Model packaging does not require LitServe. To run a LitServe-based handler, install the optional serve extra for convenience:

pip install "raine[serve]"

For PyTorch handlers, also install the torch extra. Other extras (gcp, train, data) cover optional tooling elsewhere in the repo and are not required for model packaging.

Exporting bundles (save_model)

save_model writes a PEP 751 pylock.toml by shelling out to the uv CLI when it is available. Put the uv executable on your PATH when you export (for example via uv's standalone installer). It does not need to be installed in the same Python environment as raine — only the command must be reachable.

If uv is missing, export still succeeds: raine writes pyproject.toml and emits a warning that pylock.toml was skipped. Install uv and re-run export, or run uv export --format pylock.toml --directory <bundle_dir> manually against the bundle directory.

Local dependencies are materialized into the artifact:

  • Source directories (PEP 508 @ file:./pkg, Poetry { path = \"...\" }, uv [tool.uv.sources] directory paths) are copied into vendors/ and rewritten as file:./vendors/<name> requirements.
  • Wheel files (PEP 508 @ file:...whl or source-table paths ending in .whl) are copied into vendors/ and rewritten as file:./vendors/<name>.whl requirements.

You do not need uv at all if you use another installer. The artifact pyproject.toml is standard PEP 621 — Poetry, pip, pdm, etc. can install from it. A Poetry consumer can run poetry lock / poetry install in the bundle directory and ignore pylock.toml entirely.

Model bundles

save_model writes a directory like:

my_model/
├── code/              # traced local Python (handler + imports)
├── artifacts/         # weights, configs, and other assets
├── artifacts.json     # logical name → bundle path index
├── pyproject.toml     # merged runtime dependencies
├── vendors/           # local source and .whl deps (copied when referenced)
└── pylock.toml        # locked deps (when uv is on PATH; optional)

At serving time, load the handler with from_bundle. In setup(), access bundle assets via self.context.artifacts, similar to MLflow's PythonModelContext.

Quick start

RaineModel is a mixin — it does not depend on any serving framework. The example below uses LitServe (pip install "raine[serve]"); mix it with your own base class instead if you prefer.

import litserve as ls
from raine.serve.artifacts import RaineModel

class MyInferenceAPI(RaineModel, ls.LitAPI):
    def __init__(self):
        super().__init__(max_batch_size=1)

    def setup(self, device):
        weights = self.context.artifacts["weights"]
        config = self.context.artifacts["config"]
        ...

api = MyInferenceAPI.from_bundle("/path/to/my_model", max_batch_size=1)
ls.LitServer(api).run(port=8080)

Export from a dedicated script:

handler = MyInferenceAPI()
handler.save_model(
    output_dir="./my_model",
    artifacts={
        "config": "/path/to/config.json",
        "weights": "/path/to/weights",
    },
)

Common options

Parameter Purpose
source_dir Root for code tracing (defaults to the handler module directory)
code_seeds Extra modules/classes to include in code/
code_renames Rename files in the bundle, e.g. {"inference_en.py": "inference.py"}
dependency_extras PEP 621 optional deps from your pyproject.toml
dependency_groups uv/poetry dependency groups to merge
extra_dependencies Extra PEP 508 reqs merged last; local @ file:... dirs and wheels are copied into vendors/
include_base When false, skip source [project].dependencies; merge only extras/groups/overrides
pyproject_toml_path Explicit deps manifest (overrides upward search)

Local testing without a full export

Use staged_handler to symlink a bundle layout and yield a loaded handler:

from raine.serve.artifacts import staged_handler

with staged_handler(
    MyInferenceAPI,
    artifacts={"weights": weights_path, "config": config_path},
    source_dir=handler_dir,
    code_renames={"inference_en.py": "inference.py"},
    max_batch_size=1,
) as api:
    ls.LitServer(api).run(port=8080)

Example

See examples/artifact_packaging/ for a minimal export script, handler, and sample assets.

Metadata

Release files for raine 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for raine 0.1.4
File Size Uploaded Provenance Actions
raine-0.1.4.tar.gz 305.6 kB Without provenance Details for raine-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for raine 0.1.4
File Interpreter ABI Platform Actions
raine-0.1.4-py3-none-any.whl Python 3 none any Details for raine-0.1.4-py3-none-any.whl

Total release size: 374.8 kB

Release files / raine-0.1.4.tar.gz

Download URL raine-0.1.4.tar.gz
Size 305.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7d001ae44791ecbff3496b7eb64af21fdccdf61615a3e63670eacf07f73d8d79
BLAKE2b-256 checksum
How to use checksums
8a458659112c993d0521eec4a322d6901b467727db35670b304d0ed9616a2621
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / raine-0.1.4-py3-none-any.whl

Download URL raine-0.1.4-py3-none-any.whl
Size 69.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3c0863f0d3124648e2219d1319360a1ecce2c5c1aa487ca0635d069da9fd0238
BLAKE2b-256 checksum
How to use checksums
0f1ed96196312176f5c9ffe8524069d92ae947c806b5ffc25405c7b1afbee6ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for raine 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page