Skip to main content

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_ai

To include PySpark for the distributed execution branch:

pip install "switchboard_ai[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.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 switchboard-engine 0.1.0
File Size Uploaded Provenance
switchboard_engine-0.1.0.tar.gz 6.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for switchboard-engine 0.1.0
File Interpreter ABI Platform
switchboard_engine-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.6 kB

Release files / switchboard_engine-0.1.0.tar.gz

Download URL switchboard_engine-0.1.0.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
18a3984b76aed4daa490e6d75c53a4f2769a41e34635336adbbd4e0114e9c684
BLAKE2b-256 checksum
How to use checksums
d2d78c7fcc9bd66f02c07297ad194f3bf123d9e76da8f1849e3ef365b1e9b25e
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.0-py3-none-any.whl

Download URL switchboard_engine-0.1.0-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6bde79d3377a2336971bad9568f022b973aa4079ee02217e44be834a88b46502
BLAKE2b-256 checksum
How to use checksums
a9dfcc70e7e6bf0123dd13ce6bc3ce082ea99350cf9b6855d49c094de84000f5
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.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.

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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