Python SDK for DSB (Distributed Sandboxes)
Project description
DSB Python SDK
Python SDK for interacting with Distributed Sandboxes (DSB), including sandbox management, SSH sessions, terminals, and web automation.
Installation
pip install dsb-sdk
Initialization
The SDK provides both synchronous and asynchronous clients. Always use context managers (with or async with) to ensure proper resource cleanup.
from dsb_sdk import DSBClient, AsyncDSBClient
# Synchronous client
with DSBClient(api_url="http://localhost:8080/api") as client:
pass # Use the client
# Asynchronous client
async with AsyncDSBClient(api_url="http://localhost:8080/api") as async_client:
pass # Use the async client
Quickstart: Sandbox Management
Create, check, and delete a sandbox easily.
from dsb_sdk import DSBClient
with DSBClient(api_url="http://localhost:8080/api") as client:
# Create a sandbox
sandbox = client.sandbox.create(image="python:3.12", name="my-sandbox")
print(f"Created sandbox: {sandbox.id}")
# Check status
status = client.sandbox.get(sandbox.id)
print(f"Sandbox status: {status.state}")
# Delete the sandbox
client.sandbox.delete(sandbox.id)
print("Sandbox deleted")
Executing Code
Run commands directly inside a running sandbox.
from dsb_sdk import DSBClient
from dsb_sdk.types.exec import ExecRequest
with DSBClient(api_url="http://localhost:8080/api") as client:
sandbox = client.sandbox.create(image="python:3.12")
# Execute a command
request = ExecRequest(cmd=["echo", "Hello from DSB!"])
response = client.sandbox.exec(sandbox.id, request)
print(response.stdout)
client.sandbox.delete(sandbox.id)
Other Features
SSH Access
Retrieve SSH connection details for a sandbox.
with DSBClient(api_url="http://localhost:8080/api") as client:
ssh_session = client.ssh.create_session(sandbox.id)
print(f"Connect via: ssh -p {ssh_session.port} {ssh_session.user}@{ssh_session.host}")
Web Automation
Scrape a webpage.
with DSBClient(api_url="http://localhost:8080/api") as client:
result = client.web.scrape("https://example.com")
print(result.markdown)
Async Support
All synchronous methods have an asynchronous equivalent when using AsyncDSBClient. Simply append _async to the method name.
async with AsyncDSBClient(api_url="http://localhost:8080/api") as client:
sandbox = await client.sandbox.create_async(image="python:3.12")
await client.sandbox.delete_async(sandbox.id)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dsb_sdk-0.10.8.tar.gz.
File metadata
- Download URL: dsb_sdk-0.10.8.tar.gz
- Upload date:
- Size: 121.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.14 {"installer":{"name":"uv","version":"0.9.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d72428522cbe4ec58cba06914ea8aabedecebb2ec5b6b4a93aa1a6b77aacee7
|
|
| MD5 |
bfd9a57524f88772d4d41375f5ed8a8e
|
|
| BLAKE2b-256 |
6d4114b47bb5a22c7166bba53c6c26462aa15a776726fbf2d0e4587a2f200399
|
File details
Details for the file dsb_sdk-0.10.8-py3-none-any.whl.
File metadata
- Download URL: dsb_sdk-0.10.8-py3-none-any.whl
- Upload date:
- Size: 89.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.14 {"installer":{"name":"uv","version":"0.9.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
072c56f64b0d6852c8b9bd7074d01739c6ce885a5e420bc010d49701af0cb0c8
|
|
| MD5 |
8eb1d9c0e122fd23e9accedeac17dde2
|
|
| BLAKE2b-256 |
f13df3f5d4c5cccd13b3f24c6b87e26863afad9354980e25c70233678b708a04
|