Skip to main content

Datalayer

Become a Sponsor

{ } Code Sandboxes

PyPI - Version

Code Sandboxes (code_sandboxes) is a Python package for running code in isolated sandbox variants through a unified API.

Canonical variant names:

  • jupyter
  • docker
  • eval
  • monty
  • kaggle
  • colab
  • modal
  • datalayer

Documentation

The full documentation is the single source of truth:

Published site:

Install

pip install code-sandboxes

For backend-specific extras and credentials, see https://code-sandboxes.datalayer.tech/installation and https://code-sandboxes.datalayer.tech/sandboxes.

Quick Examples

Python: launch a jupyter sandbox

from code_sandboxes import Sandbox

# Option 1: manage a local Jupyter server automatically
with Sandbox.create(variant="jupyter") as sandbox:
  print(sandbox.run_code("1 + 1").text)  # 2

# Option 2: connect to an existing Jupyter server
with Sandbox.create(
  variant="jupyter",
  server_url="http://localhost:8888",
  token="MY_TOKEN",
) as sandbox:
  sandbox.run_code("x = 40")
  print(sandbox.run_code("x + 2").text)  # 42

CLI REPL: kaggle variant

Kaggle REPL supports both interactive runtime mode and credential-based batch mode.

Required credentials for batch mode:

  • ~/.kaggle/kaggle.json, or
  • KAGGLE_API_KEY
# Install Kaggle support
pip install code-sandboxes[kaggle]

# Optional: env-based credentials (if not using ~/.kaggle/kaggle.json)
export KAGGLE_API_KEY="<your-kaggle-api-key>"

# Launch the REPL
sandbox repl --variant kaggle

For full setup and parameters for all variants, see:

License

BSD 3-Clause License

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

code_sandboxes-0.16.0-py3-none-any.whl (66.1 kB view details)

Uploaded Python 3

File details

Details for the file code_sandboxes-0.16.0-py3-none-any.whl.

File metadata

File hashes

Hashes for code_sandboxes-0.16.0-py3-none-any.whl
Algorithm Hash digest
SHA256 591a69a95fffb538ed7c4cf40d6e197c1e15095b8448644e05c72d8b0c25124c
MD5 7986d056a79924bd9f138d461853b6ea
BLAKE2b-256 a45c12cbc4e214e8b6da899db73b32a703598a19df83a6fc8a1dfdaf67696959

See more details on using hashes here.

Release history Release notifications | RSS feed

1.1.2

1 file

1.1.1

1 file

1.1.0

1 file

1.0.10

1 file

1.0.9

1 file

1.0.8

1 file

1.0.7

1 file

1.0.6

1 file

1.0.5

1 file

1.0.4

1 file

1.0.3

1 file

1.0.2

1 file

1.0.1

1 file

1.0.0

1 file

0.17.0

1 file

This release

0.16.0 This release

1 file

0.0.21

1 file

0.0.20

1 file

0.0.19

1 file

0.0.18

1 file

0.0.17

1 file

0.0.16

1 file

0.0.15

1 file

0.0.14

1 file

0.0.13

1 file

0.0.12

1 file

0.0.11

1 file

0.0.10

1 file

0.0.9

1 file

0.0.8

1 file

0.0.7

1 file

0.0.6

1 file

0.0.5

1 file

0.0.4

1 file

0.0.3

1 file

0.0.2

1 file

0.0.1

1 file

Supported by

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