Switchboard AI
A lightweight, production-grade Python library that acts as a dynamic payload router for ETL workloads. It analyzes the size of an S3 input path and intelligently routes the execution of a SQL transformation query to either:
- DuckDB: For fast, in-memory processing of small payloads (<100MB by default).
- PySpark: For distributed, memory-safe processing of large, multi-GB datasets.
Installation
Install via pip:
pip install switchboard-engine
To include PySpark for the distributed execution branch:
pip install "switchboard-engine[spark]"
Usage
Local Python Script
import logging
from switchboard.engine import SwitchboardEngine
logging.basicConfig(level=logging.INFO)
input_path = "s3://my-bucket/incoming/data/*.json"
output_path = "s3://my-bucket/processed/data_clean/"
sql_query = "SELECT id, name, UPPER(status) as status FROM read_json_auto('s3://my-bucket/incoming/data/*.json')"
# Using context manager for automatic cleanup
with SwitchboardEngine(threshold_mb=100.0, max_duckdb_memory="4GB") as engine:
# If the payload size is <= 100MB, it will execute in DuckDB.
# Otherwise, it will fallback to PySpark.
# Write directly to S3
engine.execute(input_path, sql_query, s3_output_path=output_path)
# Or return an in-memory DataFrame (Pandas from DuckDB or PySpark DataFrame from Spark)
# df = engine.execute(input_path, sql_query)
# print(df)
Databricks Integration
In Databricks, PySpark is pre-installed. SwitchboardEngine is designed to be zero-config by picking up the active SparkSession.
from switchboard.engine import SwitchboardEngine
input_path = "s3://my-data-lake/bronze/transactions/"
sql_query = "SELECT * FROM parquet.`s3://my-data-lake/bronze/transactions/` WHERE amount > 100"
with SwitchboardEngine(threshold_mb=200.0) as engine:
df = engine.execute(input_path, sql_query)
display(df)
Note for Databricks: DuckDB will automatically attempt to use the instance profile (via IMDS) if standard AWS keys are not explicitly set in the environment variables, ensuring secure and seamless access to S3.
Metadata
Release files for switchboard-engine 0.1.1
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 | |
|---|---|---|---|---|
| switchboard_engine-0.1.1.tar.gz | 6.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| switchboard_engine-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.5 kB
Release files / switchboard_engine-0.1.1.tar.gz
| Download URL | switchboard_engine-0.1.1.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c8dfca5d83f8edbf8390bdf97f04f1ea5984ca677199ab75d7f79259e42ae498
|
|
BLAKE2b-256 checksum How to use checksums |
be2138994022fe5ae0401297a35a9cdf297e91c62a8ee516197426445e6f1cd6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.9
|
Release files / switchboard_engine-0.1.1-py3-none-any.whl
| Download URL | switchboard_engine-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
03de6d8d73991635cfc9d33eec870fc538c714be0d051268985f6fc56f5d2521
|
|
BLAKE2b-256 checksum How to use checksums |
6d179380c278240e79f53ecb496556a61d0cef0512adcf0fa23411bf6201384b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.9
|
Security for switchboard-engine 0.1.1
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.