Skip to main content

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:

  1. Checks whether a server already responds on 127.0.0.1:8765 (/health).
  2. If yes: just pushes the new table to it over HTTP — no new process is created.
  3. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sparkstagelapse-0.1.0.tar.gz (48.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sparkstagelapse-0.1.0-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

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

Hashes for sparkstagelapse-0.1.0.tar.gz
Algorithm Hash digest
SHA256 31993dafdce34331a2fc89171e7faf9f95a1fe23a276ee6e5512318b96e1c5dc
MD5 d00e195e078eff0f21a5813525f5777d
BLAKE2b-256 e604718a09ce7bee75343d7c2f9b993552c6e426fef01ff275c2ae58c19da757

See more details on using hashes here.

Provenance

The following attestation bundles were made for sparkstagelapse-0.1.0.tar.gz:

Publisher: release.yml on Jay-boo/sparkstagelapse

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for sparkstagelapse-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 92321f3c5e2c8ae36c7aafe37db9558b435460988c694ca5d3c9af7ccf40dfcc
MD5 d80cd77402571d60b07e5449739a1db5
BLAKE2b-256 d4664753c75dd0037833e54690f270e85e3635d168484125ac7c3c0566255499

See more details on using hashes here.

Provenance

The following attestation bundles were made for sparkstagelapse-0.1.0-py3-none-any.whl:

Publisher: release.yml on Jay-boo/sparkstagelapse

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page