Skip to main content

Rulebricks Spark

Rulebricks Spark

PyPI

Reference Documentation

Apply versioned Rulebricks rules and flows to PySpark DataFrames. The library sends records in bounded requests and keeps each decision, error, and execution ID alongside its source data.

pip install rulebricks-spark
import os

from rulebricks_spark import apply_flow

results = apply_flow(
    source,
    "order-routing-flow",
    version="1",
    api_key=os.environ["RULEBRICKS_API_KEY"],
    base_url="https://acme.rulebricks.com/api/v1",
    correlation_id_path="request_id",
    max_inflight_rows=128,
)
results.write.format("delta").mode("errorifexists").save(result_path)
saved = spark.read.format("delta").load(result_path)

Flow results remain JSON by default, ready for your own Spark expressions.

For independent rows, max_inflight_rows=128 lets the library automatically pack, overlap, and tune requests within a planned budget of 128 outstanding rows. To choose the batch size yourself, set max_batch_rows. This disables automatic batch tuning. With full batches, the planned number of concurrent requests is max_inflight_rows / max_batch_rows. In this example, max_batch_rows=4 gives 128 / 4 = 32 requests of four rows each. Both modes choose Spark partitioning automatically and refill requests individually. execution_partitions remains an advanced override; max_batch_bytes is a 64 MiB request ceiling and does not disable tuning. Omitting max_inflight_rows keeps the existing execution behavior. See execution and scale for details.

apply_rule() uses the same execution model and infers a typed result from the selected rule version. Context operations provide optional input staging and ordered stateful processing, while Structured Streaming uses Spark's ordinary foreachBatch interface.

Start with the documentation or the notebook walkthroughs. The guides explain how the concepts fit together; the reference covers parameters, result fields, failure handling, and recovery. Notebook settings are defined in the notebooks, with only credentials kept in a secret manager or environment.

The package targets classic PySpark 3.5 and requires Python 3.9+ and PyArrow 18+. Use a Python version supported by your Spark runtime. For a documentation preview, follow the Sphinx build instructions.

Releasing

Release versions come from Git tags. Push a tag such as v0.2.2 (or 0.2.2) on the commit you want to release, and GitHub Actions builds and publishes that version to PyPI. There is no version number to edit in the source code.

The release checks the package filenames and metadata against the tag before uploading. See release instructions for details.

Metadata

Release files for rulebricks-spark 0.3.0

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

Source distribution (sdist)

Source distribution for rulebricks-spark 0.3.0
File Size Uploaded Provenance Actions
rulebricks_spark-0.3.0.tar.gz 541.7 kB With provenance Details for rulebricks_spark-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rulebricks-spark 0.3.0
File Interpreter ABI Platform Actions
rulebricks_spark-0.3.0-py3-none-any.whl Python 3 none any Details for rulebricks_spark-0.3.0-py3-none-any.whl

Total release size: 600.4 kB

Release files / rulebricks_spark-0.3.0.tar.gz

Download URL rulebricks_spark-0.3.0.tar.gz
Size 541.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c445f2347fb8c18f7851df43603f8a3bfe8d90aedc58561be31e5f35d7b74a1d
BLAKE2b-256 checksum
How to use checksums
f7a732a101aa00e9e8dcde4045fde05686915a93257acdf7220295aef1c9b2f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Release files / rulebricks_spark-0.3.0-py3-none-any.whl

Download URL rulebricks_spark-0.3.0-py3-none-any.whl
Size 58.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa5dccc1cb2f969a3aab4bbe89b7029c6a78e548585bd2db402e2cea07405078
BLAKE2b-256 checksum
How to use checksums
5c073f0993513aa6d49260cc6616990ff6f304ff2dc57bd24a6b847ddad1f18c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Security for rulebricks-spark 0.3.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for rulebricks_spark-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

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