overture-spark
Portable, framework-agnostic runtime helpers for Overture's Spark jobs. Moved from tf-data-platform's overture_spark module (see ops-team#535, ops-team#536); other overture_spark modules follow in later PRs (see ops-team#532).
It contains:
SparkSedonaJob(injob.py) — cluster-side base class for jobs: platform detection, parameter parsing, logging, and the SedonaSparkSessionlifecycle. Subclass it and implementexecute_job().test_area— helpers for a job's optionaltest_areaparam (a bbox or WKT polygon that scopes a dev/test run to a small region instead of the full planet).s3— S3 credentials for Python clients (boto3, PyArrow) that need the same access as Spark's S3A, e.g. on Wherobots, where only S3A gets the storage-integration role.hadoop_fs— small driver-side file operations (read, write, list, delete) through Spark's Hadoop FileSystem, so they use S3A's credentials.plan—plan_size/assert_plan_sizeguards against runaway Spark query plans (see Guarding plan size).
Writing a job
from overture_spark.job import SparkSedonaJob
class CollectionJob(SparkSedonaJob):
def execute_job(self) -> None:
path = self.get_param("input_path")
self.log(f"Processing {path}")
df = self.apply_test_area_filter(self.spark.read.parquet(path))
# ... your logic
get_param treats None and text that is empty, none or null (any case, after stripping) as unset: an optional param returns its default, and a required one raises MissingParameterError. Jobs that read self.result.params directly use the same rule through is_unset(value). get_bool_param(name, default) returns true for true and false for false, in any case, and raises ValueError on anything else.
getSparkSedonaSession (in overture_spark/__init__.py) is the one call in this package that actually needs a real Spark/Sedona session — it, and everything downstream of it, imports pyspark/apache-sedona lazily and only there. Platform detection, version/JAR helpers, and SparkSedonaJob's parameter/logging logic are plain Python and importable without either installed.
Reaching S3 from Python
Spark's S3A can have per-bucket credentials (fs.s3a.bucket.<bucket>.*) that boto3 and PyArrow don't see. Resolve them on the driver, ship the picklable S3Access to Python workers, and build clients there:
from overture_spark.s3 import pyarrow_s3_filesystem, resolve_s3_access, s3_client
access = resolve_s3_access(spark, "s3a://bucket/prefix") # driver only
def write_partition(batches):
filesystem = pyarrow_s3_filesystem(access) # paths are "bucket/key"
s3 = s3_client(access)
...
resolve_s3_access returns S3A's assumed role (assumed.role.arn), else its static keys (access.key/secret.key, with session.token if set), plus endpoint.region, each preferring the per-bucket setting; a bucket's own keys also win over a global role. Clients assume the role with the Wherobots external ID (WBC_STINT_ASSUME_ROLE_EXTERNAL_ID, if set) and refresh it; with nothing configured (e.g. Glue) they use the default credential chain. boto3_session and pyarrow_s3_filesystem are cached per process; s3_client(access, **client_kwargs) builds an S3 client from the cached session and is safe to call from several threads. boto3/pyarrow are imported lazily: install them yourself or with overture-spark[s3].
Small file operations on the driver
For a params file, a bundle's file list, or a scratch prefix, go through Spark's Hadoop FileSystem instead of boto3. It already has S3A's credentials on every platform:
from overture_spark.hadoop_fs import delete_prefix, list_files, read_json, write_text
params = read_json(spark, "s3://bucket/params.json")
write_text(spark, "s3://bucket/run-1/_DONE", "")
files = list_files(spark, "s3://bucket/bundle/")
delete_prefix(spark, "s3://bucket/tmp/run-1/")
read_text decodes UTF-8; read_json is json.loads over it. write_text writes UTF-8, replacing any file at the URI. list_files returns sorted, Hadoop-qualified URIs of every file under the URI, recursively (s3://b/p lists s3a://b/p/..., /tmp/x lists file:/tmp/x/...), or [] if it doesn't exist. delete_prefix deletes a path recursively, not a string prefix (s3://b/tmp/run leaves tmp/run-2/), and is a no-op if the URI doesn't exist. These helpers read s3:// as s3a://. Every byte goes through the driver over py4j, so keep files small. On S3A, deleting the last object under a parent creates an empty directory marker for the parent (parent/).
Guarding plan size
A plan that grows with the number of unions, joins or withColumn calls can kill the driver: Spark renders the whole plan as one string for the UI and event log, and past the JVM's ~2 GB array limit the driver OOMs, however small the data. Guard it in unit tests:
from overture_spark.plan import assert_plan_size, plan_size
# Raises PlanTooLargeError (an AssertionError) past the limit
assert_plan_size(build_checks(df), max_chars=200_000)
plan_size(df) is the length of the analyzed plan string in UTF-16 code units (the JVM's String.length, so a non-BMP character counts as 2); the error message reports the measured size and the limit. When spark.sql.maxPlanStringLength truncates the string, plan_size recovers the true size from Spark's ... N more characters suffix (or its Truncated plan of N characters message at caps of 30 or lower), so the guards work under any cap. Jobs can opt in to the same check before an expensive action such as the final write:
self.check_plan_size(df, name="final output") # logs a warning past 10M chars
self.check_plan_size(df, max_chars=1_000_000, fail=True) # raises PlanTooLargeError
Measuring renders the plan string on the driver, so it is never run automatically: call it once, not on every action.
getSparkSedonaSession also defaults spark.sql.maxPlanStringLength to 100000000 (100M chars) when nothing has set it, to bound the plan string Spark renders for the UI and event log and reduce the risk of driver OOM. A cluster or --conf value is kept, and extra_spark_conf={"spark.sql.maxPlanStringLength": "..."} overrides it. Only the string is truncated, not the plan or the event log, so it doesn't fix plan growth. Its effect on a plan string over 2 GB is not validated.
Testing locally
cd packages/overture_spark
uv sync --extra dev
uv run pytest -v -m "not spark"
Tests marked @pytest.mark.spark need a real Spark/Sedona session (a JVM, plus Sedona's native JAR resolution), so they're excluded from the routine pytest run above and from overture-spark[dev]. Install the sql-spark extra to run them:
uv sync --extra dev --extra sql-spark
uv run pytest -v --cov --cov-fail-under=95
CI mirrors this split: the routine Test Python workflow runs pytest -m "not spark" for this package (no coverage gate, since the Spark-only code paths aren't exercised), and the SQL Engines workflow's spark (overture_spark) job installs the sql-spark extra and Java, then runs the full suite with the 95% coverage floor.
Publishing
See PACKAGE_VERSIONING.md for how a version bump here turns into a PyPI release.
Metadata
Release files for overture-spark 1.0.0
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 |
|---|---|---|---|---|
| overture_spark-1.0.0.tar.gz | 192.2 kB | With provenance | Details for overture_spark-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| overture_spark-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for overture_spark-1.0.0-py3-none-any.whl |
Total release size: 215.3 kB
Release files / overture_spark-1.0.0.tar.gz
| Download URL | overture_spark-1.0.0.tar.gz |
|---|---|
| Size | 192.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b044bc7957baac568cd92cadc2846ef5d6f31e813e53b85086d82da8a2ef467f
|
|
BLAKE2b-256 checksum How to use checksums |
cbd4824c52e2a26106816214d24f74b90be3d4254b93624275b64c1156486783
|
| 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 11, 2026.
Transparency logRelease files / overture_spark-1.0.0-py3-none-any.whl
| Download URL | overture_spark-1.0.0-py3-none-any.whl |
|---|---|
| Size | 23.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c28880e7a6ce3b4d7d1ba7ee50d92ca20745fd4230a958345ac5978b442f98ac
|
|
BLAKE2b-256 checksum How to use checksums |
1cafc816f461b5c5cb2d574b7e3e8dcac344bbcc678fb32836eec95245d0a4bf
|
| 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 11, 2026.
Transparency logSecurity for overture-spark 1.0.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.
Attestation for overture_spark-1.0.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 11, 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.