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 operationsship.shell- Shell command executionship.python- Python code execution
Spec
Resource specification for ships:
spec = Spec(cpus=2.0, memory="1g")
Environment Variables
SHIPYARD_ENDPOINT- Bay API endpoint URLSHIPYARD_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
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 shipyard_python_sdk-0.2.2.tar.gz.
File metadata
- Download URL: shipyard_python_sdk-0.2.2.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a924a2c2d1e6faeb4a052249d69bad56c0c8efd832653d104142bfc65b7f7dac
|
|
| MD5 |
297b7dd044e3ef68014033d882295bf3
|
|
| BLAKE2b-256 |
6e451cb8042c66ff28e77ee73c89ec8c4a2df02dba00d5f8a54120d95599830e
|
File details
Details for the file shipyard_python_sdk-0.2.2-py3-none-any.whl.
File metadata
- Download URL: shipyard_python_sdk-0.2.2-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54d7e931bf885be7fb0c7375bb172396837bddc1aa513862df7589af9a4aa6a8
|
|
| MD5 |
13a9572aec6440703db5315610f5f15b
|
|
| BLAKE2b-256 |
7687263492b8c2748c9ca41fed87e0fb2503be21154a8895270690a0160fd118
|