Rulebricks Spark
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.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rulebricks_spark-0.2.3.tar.gz | 539.6 kB | With provenance | Details for rulebricks_spark-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rulebricks_spark-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for rulebricks_spark-0.2.3-py3-none-any.whl |
Total release size: 596.9 kB
Release files / rulebricks_spark-0.2.3.tar.gz
| Download URL | rulebricks_spark-0.2.3.tar.gz |
|---|---|
| Size | 539.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7e1586c8739c81a54b2cfe55aa24bd2007f17afbde50ec9724f967e137c11587
|
|
BLAKE2b-256 checksum How to use checksums |
66860d028f5460e8d8d0bb2c9f42693f5c6fc9d39143b39217512b6c9f2c110a
|
| 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 4, 2026.
Transparency logRelease files / rulebricks_spark-0.2.3-py3-none-any.whl
| Download URL | rulebricks_spark-0.2.3-py3-none-any.whl |
|---|---|
| Size | 57.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
81be165b87f6cc2df665b7888d4ce9ab5a335e07df2df664d34432518a19af7f
|
|
BLAKE2b-256 checksum How to use checksums |
0d4604efe4b46a69fbf4b18c8c54ec4f03743115d77cc762e28ff2b2f147ed97
|
| 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 4, 2026.
Transparency logSecurity for rulebricks-spark 0.2.3
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.
Attestation for rulebricks_spark-0.2.3.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 4, 2026.
Transparency logA 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.