Python library and Jupyter kernels that run Spark code on remote clusters through Livy, with SQL magics and notebook visualizations.
Overview
Sparkmagic connects Jupyter notebooks to remote Apache Spark clusters through a REST interface, chiefly Livy. Analysts and engineers can run Python, Scala, R, and SQL against shared clusters without installing Spark components on the notebook host.
You can use IPython cell magics such as %%spark and %%sql from a standard notebook, or install dedicated PySpark, Scala Spark, and SparkR kernels that auto-connect, manage sessions, and surface cluster configuration in the UI. The library creates SparkContext and HiveContext automatically, visualizes SQL results, exposes application logs via %%info, and can pull query output into Pandas for local plotting or model handoff.
Authentication to Livy supports none, HTTP basic access, Kerberos, or custom authenticator classes registered in configuration. A Jupyter server extension can switch cluster endpoints programmatically. Optional Docker Compose stacks bundle Jupyter, Livy, and a local Spark instance for development, though production setups normally target separate cluster endpoints.
Because execution happens on the remote Spark driver, structured results travel as JSON back to the client. Client-side %%local manipulation therefore expects Python when working with returned dataframes.
Key features
- Livy-backed remote Spark sessions
- %%spark and %%sql IPython magics
- PySpark, Scala, and SparkR kernels
- SQL result visualization widgets
- Pandas export of query output
- Basic, Kerberos, or custom auth
- Jupyter server extension for clusters
- Send local files to remote Spark
Use cases
- Notebook access to shared Spark clusters
- Remote PySpark and Scala development
- SQL exploration with inline charts
- Kerberos-secured enterprise notebooks
- Local-to-cluster model or data upload