Skip to main content

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


Download files

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

Source Distribution

dsb_sdk-0.10.7.tar.gz (121.7 kB view details)

Uploaded Source

Built Distribution

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

dsb_sdk-0.10.7-py3-none-any.whl (89.2 kB view details)

Uploaded Python 3

File details

Details for the file dsb_sdk-0.10.7.tar.gz.

File metadata

  • Download URL: dsb_sdk-0.10.7.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

Hashes for dsb_sdk-0.10.7.tar.gz
Algorithm Hash digest
SHA256 94469dc2da52ec059fc61b5f151400d64577fd79162fc9d361377bf2af92fa43
MD5 ba53c89e859231a09ecf2dc187a4c350
BLAKE2b-256 294765129b06c17ad855b9792a48a6113d974e7de0dded2562f8363f0e3c4477

See more details on using hashes here.

File details

Details for the file dsb_sdk-0.10.7-py3-none-any.whl.

File metadata

  • Download URL: dsb_sdk-0.10.7-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

Hashes for dsb_sdk-0.10.7-py3-none-any.whl
Algorithm Hash digest
SHA256 ab33a5edf4100707e10fc48ca4378e6c9c088fc7e7a1953ae1c6e089a9a72cfc
MD5 3f9c225d7abaeffaeaa91cbff3785f58
BLAKE2b-256 5014eafee21c067d985ce8ce5de6fab00c14d3e0a85b9a1cdb59b376abb1adcd

See more details on using hashes here.

Supported by

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