Skip to main content

Shipyard Python SDK is an agent sandbox sdk

Project description

Shipyard Python SDK

A Python SDK for interacting with Shipyard containerized execution environments.

Installation

pip install aiohttp

Quick Start

import asyncio
from shipyard_python_sdk import ShipyardClient, Spec, create_session_ship

async def main():
    # Option 1: Using client directly
    client = ShipyardClient(
        endpoint_url="http://localhost:8000",
        access_token="your-token"
    )
    
    ship = await client.create_ship(
        ttl=3600,  # 1 hour
        spec=Spec(cpus=1.0, memory="512m"),
        max_session_num=5
    )
    
    # Use the ship
    await ship.fs.create_file("hello.txt", "Hello, World!")
    result = await ship.fs.read_file("hello.txt")
    print(result["content"])
    
    # Option 2: Using convenience function
    ship = await create_session_ship(
        ttl=1800,
        spec=Spec(cpus=0.5, memory="256m")
    )
    
    await client.close()

if __name__ == "__main__":
    asyncio.run(main())

File Structure

shipyard_python_sdk/
├── __init__.py          # Main package exports
├── types.py             # Type definitions and data models
├── client.py            # Main ShipyardClient implementation
├── session.py           # SessionShip implementation
├── filesystem.py        # File system operations component
├── shell.py             # Shell operations component
├── python.py            # Python/IPython operations component
├── utils.py             # Convenience functions
└── examples.py          # Usage examples

Components

ShipyardClient

Main client class for interacting with the Bay API.

SessionShip

Represents a ship session with three main components:

  • ship.fs - File system operations
  • ship.shell - Shell command execution
  • ship.python - Python code execution

Spec

Resource specification for ships:

spec = Spec(cpus=2.0, memory="1g")

Environment Variables

  • SHIPYARD_ENDPOINT - Bay API endpoint URL
  • SHIPYARD_TOKEN - Access token for authentication

Error Handling

All operations can raise exceptions. Wrap calls in try-catch blocks:

try:
    result = await ship.fs.read_file("nonexistent.txt")
except Exception as e:
    print(f"Error: {e}")

Examples

See examples.py for comprehensive usage examples including:

  • Basic file operations
  • Shell command execution
  • Python code execution with persistent variables
  • Background processes
  • Error handling patterns

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

shipyard_python_sdk-0.2.3.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

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

shipyard_python_sdk-0.2.3-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file shipyard_python_sdk-0.2.3.tar.gz.

File metadata

  • Download URL: shipyard_python_sdk-0.2.3.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.3

File hashes

Hashes for shipyard_python_sdk-0.2.3.tar.gz
Algorithm Hash digest
SHA256 bed6b8ea4af61e555b1024470248f9f778e4991ad3fc83c93e6fb4447a1c6ffa
MD5 c37f1706e37a2d16d7aed82a4be8b87d
BLAKE2b-256 00c5df608d5a17c8f76d10553c9de0358a2ebc50fe56c25f4a173e018a150b77

See more details on using hashes here.

File details

Details for the file shipyard_python_sdk-0.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for shipyard_python_sdk-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f4800e64724d42cc85e27328ab0d5e6b2c9663ed40cab7e0bccdddf68d5b5624
MD5 78a03a2c73b1521153387a6eebb875d0
BLAKE2b-256 7d826740a5ccefb6dd308ae72d2e0d7882ad9ab362ea4d8e153ae43e221428d8

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