Affichage interactif de DataFrames (Spark/pandas) en notebook ou en script, via un dashboard web local persistant.
Project description
sparkstagelapse
Interactive DataFrame display (Spark or pandas) — whether you're in a notebook, a script, or a Databricks run — backed by a local web dashboard that stays open and up to date even after the script that launched it has exited.
Installation
From the root of this folder:
pip install -e .
# or, if you also want the full-screen explorer (Textual):
pip install -e ".[tui]"
Quick usage
from sparkstagelapse import display_spark
# df = spark.sql("select * from ...")
display_spark(df, title="Employees") # "auto" mode: notebook -> rich object, script -> web dashboard
display_spark(df, title="Employees", mode="web") # force the web dashboard
display_spark(df, title="Employees", mode="tui") # full-screen explorer (blocking)
display_spark(df, title="Employees", mode="rich") # plain ASCII output in the terminal
Or directly on a pandas DataFrame:
from sparkstagelapse import SparkDisplay
SparkDisplay(pdf, title="Preview").show_web()
The persistent dashboard
On the first show_web() call (or mode="web"), the client:
- Checks whether a server already responds on
127.0.0.1:8765(/health). - If yes: just pushes the new table to it over HTTP — no new process is created.
- If no: spawns the server as a detached process (not a thread — a daemon thread dies with its parent process, a separate process doesn't). Your script keeps running normally, without blocking.
The server therefore stays alive after your script exits. The next run — even tomorrow, even from a different script — will find the same dashboard already open in your browser and update it live over WebSocket.
Managing the server manually
python -m sparkstagelapse.dashboard status
python -m sparkstagelapse.dashboard stop
python -m sparkstagelapse.dashboard start # manual foreground start (blocking)
Logs and pid files live in ~/.cache/sparkstagelapse/dashboard_<port>.log / .pid.
Changing the port / host
from sparkstagelapse import DashboardClient, SparkDisplay
client = DashboardClient(host="127.0.0.1", port=9000)
SparkDisplay(pdf, title="Preview", _dashboard=client).show_web()
Package structure
sparkstagelapse/
├── __init__.py # Public API: SparkDisplay, display_spark, DashboardClient
├── display.py # SparkDisplay / display_spark — renders depending on context
└── dashboard/
├── app.py # FastAPI app (HTTP + WebSocket routes), in-memory state
├── server.py # Server bootstrap (foreground), pid/log files
├── client.py # DashboardClient: health-check, detached spawn, HTTP push
├── templates.py # HTML/JS template + table -> HTML rendering
└── __main__.py # CLI: start / stop / status
Development
pip install -e ".[dev,tui]"
ruff check . # lint
pytest -v # unit + integration tests
python -m build # build sdist + wheel
twine check dist/* # validate package metadata before upload
CI/CD
See .github/workflows/ci.yml (lint + test matrix + build, on every push/PR)
and .github/workflows/release.yml (build + publish to PyPI/TestPyPI via
Trusted Publishing, on tagged GitHub Releases). Before the release workflow
can actually publish, you need to register this repo as a Trusted Publisher
on PyPI/TestPyPI — see the CI/CD explanation in this conversation for the
exact steps.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sparkstagelapse-0.1.0.tar.gz.
File metadata
- Download URL: sparkstagelapse-0.1.0.tar.gz
- Upload date:
- Size: 48.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31993dafdce34331a2fc89171e7faf9f95a1fe23a276ee6e5512318b96e1c5dc
|
|
| MD5 |
d00e195e078eff0f21a5813525f5777d
|
|
| BLAKE2b-256 |
e604718a09ce7bee75343d7c2f9b993552c6e426fef01ff275c2ae58c19da757
|
Provenance
The following attestation bundles were made for sparkstagelapse-0.1.0.tar.gz:
Publisher:
release.yml on Jay-boo/sparkstagelapse
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sparkstagelapse-0.1.0.tar.gz -
Subject digest:
31993dafdce34331a2fc89171e7faf9f95a1fe23a276ee6e5512318b96e1c5dc - Sigstore transparency entry: 2253644588
- Sigstore integration time:
-
Permalink:
Jay-boo/sparkstagelapse@b7bee51afed5f8a9b3c0b0a4c32d9061bf0ded93 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/Jay-boo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b7bee51afed5f8a9b3c0b0a4c32d9061bf0ded93 -
Trigger Event:
release
-
Statement type:
File details
Details for the file sparkstagelapse-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sparkstagelapse-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92321f3c5e2c8ae36c7aafe37db9558b435460988c694ca5d3c9af7ccf40dfcc
|
|
| MD5 |
d80cd77402571d60b07e5449739a1db5
|
|
| BLAKE2b-256 |
d4664753c75dd0037833e54690f270e85e3635d168484125ac7c3c0566255499
|
Provenance
The following attestation bundles were made for sparkstagelapse-0.1.0-py3-none-any.whl:
Publisher:
release.yml on Jay-boo/sparkstagelapse
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sparkstagelapse-0.1.0-py3-none-any.whl -
Subject digest:
92321f3c5e2c8ae36c7aafe37db9558b435460988c694ca5d3c9af7ccf40dfcc - Sigstore transparency entry: 2253644946
- Sigstore integration time:
-
Permalink:
Jay-boo/sparkstagelapse@b7bee51afed5f8a9b3c0b0a4c32d9061bf0ded93 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/Jay-boo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b7bee51afed5f8a9b3c0b0a4c32d9061bf0ded93 -
Trigger Event:
release
-
Statement type: