Skip to main content

jupyter-storage-usage

Jupyter server extension that monitors home-directory storage usage and reports it to JupyterHub. Inspired by jupyter-resource-usage.

What it does

This extension runs inside each user's Jupyter server pod and operates in two modes:

Normal mode (JSU_CLEANUP_MODE=0, default)

  • Checks disk usage of the home directory (/home/jovyan by default) via du with nice -n 19 (lowest priority)
  • Exposes usage via an API endpoint (/api/storage/v1/usage) for JupyterHub to poll
  • Pushes usage to the hub's /report endpoint periodically
  • Shows a status bar widget in JupyterLab (like jupyter-resource-usage)
  • Uses a persistent cache (.storage-usage.json on NFS) so the widget shows the last known value instantly on pod start

Cleanup mode (JSU_CLEANUP_MODE=1)

Set by the pre-spawn hook when a user is over their hard limit. In this mode:

  • Takes over all URLs — the cleanup portal replaces JupyterLab entirely
  • Serves a file manager at /cleanup/ — browse, delete, download
  • Blocks /lab/, /api/, /terminals/ etc. (catch-all redirect to /cleanup/)
  • Shows the student's actual usage vs. their limits with a progress bar
  • Supports folder download as zip or tar.gz
  • Shows recursive folder sizes so students see the real savings from deleting a folder
  • Reports fresh usage to the hub after each delete so re-spawn works immediately
  • No upload, no create, no edit — application-layer enforcement

Configuration

All settings are environment variables. Defaults match the hub-side package.

Env var Default Description
JSU_HOME_DIR /home/jovyan Directory to monitor
JSU_WARN_LIMIT_BYTES 10Gi Soft limit — show warning
JSU_HARD_LIMIT_BYTES 20Gi Hard limit — triggers cleanup mode
JSU_CHECK_INTERVAL_SEC 1800 (30 min) How often to run du locally
JSU_CLEANUP_MODE 0 Set to 1 by the pre-spawn hook for over-limit users
JSU_HUB_REPORT_URL http://hub:9099/report Where to report usage to the hub

Accepts K8s-style quantities: 10Gi, 500Mi, 1Ti, or plain bytes.

Note: The pre-spawn hook injects JSU_WARN_LIMIT_BYTES and JSU_HARD_LIMIT_BYTES into the pod environment with the user's resolved limits (from per-user/group overrides). The defaults here are only used when the pod is not spawned through JupyterHub.

How it works with JupyterHub

JupyterHub (hub pod)                    User pod
┌─────────────────────┐                ┌──────────────────────┐
│ ServerPoller        │──poll──────────▶│ /api/storage/v1/usage│
│ (every 600s)        │                │                      │
│                     │                │ jupyter-storage-     │
│ /report endpoint    │◀──report───────│ usage extension      │
│ (receives updates)  │  (every 1800s  │                      │
│                     │   + after each │ Status bar widget    │
│ Pre-spawn hook      │   delete in    │ (normal mode)        │
│ (swaps to cleanup   │   cleanup mode)│                      │
│  image if over)     │                │ Cleanup portal       │
└─────────────────────┘                │ (cleanup mode)       │
                                       └──────────────────────┘

Install

pip install jupyter-storage-usage

The extension auto-registers via jupyter_server_config.d/jupyter_storage_usage.json.

License

MIT

Metadata

Release files for jupyter-storage-usage 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jupyter-storage-usage 0.1.2
File Size Uploaded Provenance
jupyter_storage_usage-0.1.2.tar.gz 20.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for jupyter-storage-usage 0.1.2
File Interpreter ABI Platform
jupyter_storage_usage-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 47.5 kB

Release files / jupyter_storage_usage-0.1.2.tar.gz

Download URL jupyter_storage_usage-0.1.2.tar.gz
Size 20.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3e56485f529caf1d3e01748f48ed95763d46386a6d5d98ba601fbc5a741c5dac
BLAKE2b-256 checksum
How to use checksums
d3df79a0167cdc788f20d318096ac1367d3b2028576c13cfb7f1219d415a5b26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Release files / jupyter_storage_usage-0.1.2-py3-none-any.whl

Download URL jupyter_storage_usage-0.1.2-py3-none-any.whl
Size 27.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0cd104747907b2921119fdc332aeec7d22b7779b2a9b72642573e8b4577b2569
BLAKE2b-256 checksum
How to use checksums
5a428f1b34a90c27edbf79acf48611c9eab43bf6061c3052b45f92df004e252e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Security for jupyter-storage-usage 0.1.2

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.

Release history Release notifications | RSS feed

This release

0.1.2 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