Skip to main content

sandbox-widget

A Jupyter cell magic that runs a cell in a fresh, isolated namespace and shows everything it produced -- stdout, stderr, rich display output, any exception -- in a shaded box below the cell, built on anywidget.

import sandbox_widget  # registers the %%exercise cell magic
%%exercise
import matplotlib.pyplot as plt
plt.plot([1, 2, 3])

Nothing the cell defines or imports persists past that one run, and nothing the notebook has already defined is visible to it -- except through the cell's own import/from ... import statements. Because Python caches loaded modules in sys.modules, such an import is essentially free and hands back the exact same live object the notebook already has (the same plt, with the same open figures; the same model, with the same weights) -- nothing is reloaded or reinitialized, and no kernel restart happens.

Installation

# pixi
pixi workspace channel add munch-group
pixi add sandbox-widget

# conda
conda install -c munch-group sandbox-widget

# pip
pip install sandbox-widget

Writing a %%exercise cell

  • Anything the cell needs -- a library, a model, a helper function -- must be imported by the cell itself. Plain notebook variables with no import path (e.g. a dataframe built inline two cells up) aren't visible.
  • A trailing bare expression is displayed, exactly like a normal cell (a + b, or a variable's name on its own); an assignment as the last line still runs, but produces no comparable output.

Documentation

Full docs live at munch-group.org/script-widget.

Development

This repo is managed with pixi:

pixi run install-dev   # editable install into the pixi environment
pixi run test          # run the pytest suite
pixi run docs          # execute the documentation notebooks
pixi run api           # build the quartodoc API reference

License

MIT

Metadata

Release files for sandbox-widget 1.0.22

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

Source distribution (sdist)

Source distribution for sandbox-widget 1.0.22
File Size Uploaded Provenance Actions
sandbox_widget-1.0.22.tar.gz 512.3 kB Without provenance Details for sandbox_widget-1.0.22.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sandbox-widget 1.0.22
File Interpreter ABI Platform Actions
sandbox_widget-1.0.22-py3-none-any.whl Python 3 none any Details for sandbox_widget-1.0.22-py3-none-any.whl

Total release size: 542.4 kB

Release files / sandbox_widget-1.0.22.tar.gz

Download URL sandbox_widget-1.0.22.tar.gz
Size 512.3 kB
Tags Source
SHA-256 checksum
How to use checksums
645f59084b0935e73aae1a57c5836ad730930dfb3fd3d9a3809b1d2868d31687
BLAKE2b-256 checksum
How to use checksums
b2714f3a1f70bbd714bccfd6e49678a351b542e951365ec0bd82a6b08448d1c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / sandbox_widget-1.0.22-py3-none-any.whl

Download URL sandbox_widget-1.0.22-py3-none-any.whl
Size 30.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b033c1db13f7136b56d3eb7902eafc806151ba3e52d1a0490d7a847179a6c9c5
BLAKE2b-256 checksum
How to use checksums
c0f7ef78c65593e8ac405a581e92c2f5723b07aaec719ea42b55dbdcdf08c277
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for sandbox-widget 1.0.22

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.

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