Registry / aws / cwsandbox

cwsandbox

JSON →
library1.7.0pypypi✓ verified 24d ago

A Python client library for CoreWeave Sandboxes (CWSandboxes), offering a programmatic interface to manage sandboxed environments for secure execution of workloads on the CoreWeave platform. It is currently at version 0.16.0 and maintains an active release cadence with frequent updates.

pip install cwsandbox
INSTALL
IMPORT
SIG · CWSANDBOX
C
cwsandbox
awspythonv1.7.0
Install
2.7s avg
Import
797ms
Disk
40MB
Pass rate
6/ 10
Env Coverage6 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.7.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✕ build_error
py 3.11
✓ —
✓ 2.9s
py 3.12
✓ —
✓ 2.5s
py 3.13
✓ —
✓ 2.7s
py 3.9
✕ build_error
✕ build_error
40MB installed
● package 40MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Sandbox
from cwsandbox import Sandbox

This quickstart demonstrates how to create and run a simple command within a CoreWeave Sandbox using the `cwsandbox` client library. It highlights the use of `Sandbox.run` to initiate a sandbox and `sb.stop().result()` to wait for its completion and retrieve the output. Authentication typically relies on environment variables or a configured CoreWeave client.

import os from cwsandbox import Sandbox # Ensure COREWEAVE_API_KEY and COREWEAVE_PROJECT_ID (or similar) are set in your environment # For demonstration, using dummy values. In production, use actual credentials. # os.environ['COREWEAVE_API_KEY'] = os.environ.get('CWSANDBOX_API_KEY', 'your_api_key_here') # os.environ['COREWEAVE_PROJECT_ID'] = os.environ.get('CWSANDBOX_PROJECT_ID', 'your_project_id_here') try: # Create and run a simple command in a sandbox print("Starting sandbox...") sb = Sandbox.run("echo", "Hello, World! from cwsandbox") print(f"Sandbox ID: {sb.id}") # Wait for the sandbox to complete and get results (synchronous wait) result = sb.stop().result() print("Sandbox output:") print(result.output) print(f"Sandbox exited with code: {result.exit_code}") except Exception as e: print(f"An error occurred: {e}") print("Ensure your CoreWeave environment is configured and authenticated.")
Debug
Known issues
gotchaAuthentication to the CoreWeave platform is required. The `cwsandbox` client relies on proper configuration, often via environment variables (e.g., `COREWEAVE_API_KEY`, `COREWEAVE_PROJECT_ID`) or a configured CoreWeave CLI/SDK context. The provided quickstart assumes this setup.
fix
Ensure `COREWEAVE_API_KEY` and `COREWEAVE_PROJECT_ID` (or equivalent CoreWeave client configuration) are correctly set in your environment before using the library. Refer to CoreWeave's official authentication documentation for details.
affects: All versions
gotchaThe term 'cwsandbox' in this context refers to a client for CoreWeave's remote sandboxing service, not a local Python-level sandbox for executing untrusted Python code. Misunderstanding this distinction can lead to incorrect security assumptions if you intend to sandbox local Python execution.
fix
Understand that `cwsandbox` is an API client for managing remote execution environments provided by CoreWeave. If you need to sandbox Python code locally, consider dedicated Python sandboxing tools or OS-level isolation (e.g., containers).
affects: All versions
gotchaFailing to explicitly stop sandboxes (`sb.stop()`) can lead to resource leakage and unexpected billing, as sandbox instances on the CoreWeave platform may continue to run if not properly terminated.
fix
Always ensure that `sb.stop()` is called for any `Sandbox` instance you create, ideally within a `try...finally` block or by using a context manager if available, to guarantee resource cleanup.
affects: All versions
deprecatedThe `Sandbox.run` factory method provides a hybrid synchronous/asynchronous API (`.result()` blocks). While convenient, mixing sync and async code can be a footgun. Older versions or alternative methods might have different blocking behaviors.
fix
For robust asynchronous applications, consult the official documentation (if available) for native async methods (e.g., `await Sandbox.arun()`, `await sb.astop()`) to avoid blocking the event loop. For synchronous applications, ensure you understand where blocking operations occur.
affects: <0.16.0 (potential, check specific migration guides for earlier breaking changes related to async/sync patterns)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'cwsandbox'
The 'cwsandbox' Python library is not installed in your current environment.
fix
Install the library using pip: `pip install cwsandbox`
Authentication to the CoreWeave platform is required.
The `cwsandbox` client cannot authenticate with the CoreWeave platform because required environment variables (like `COREWEAVE_API_KEY` or `COREWEAVE_PROJECT_ID`) are missing or incorrect.
fix
Set the `COREWEAVE_API_KEY` and `COREWEAVE_PROJECT_ID` environment variables with your valid CoreWeave credentials before running your application.
Sandbox not stopped, leading to resource leakage and unexpected billing.
A CoreWeave Sandbox instance created via `cwsandbox` was not explicitly terminated using `sb.stop()`, causing it to continue running on the platform and incur costs.
fix
Always ensure `sb.stop()` is called on your `Sandbox` instance. Consider using a `try...finally` block or an `async with` context manager for automatic cleanup: `with Sandbox.run(...) as sb: ...` or `async with Sandbox.run(...) as sb: ...`.
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionRefusedError(111, 'Connection refused'))
The `cwsandbox` client failed to establish a network connection to the CoreWeave API endpoint, possibly due to network issues, an incorrect endpoint configuration, or the service being unavailable.
fix
Verify your internet connectivity, check the CoreWeave platform's status, and ensure your `cwsandbox` configuration points to the correct API endpoint.
Upgrade
Version history
1.7.0latest on PyPI · released Aug 24, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
24 hits · last 30 days
node
22
Resources
cwsandbox — pip install cwsandbox · libregistry