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
Metadata
Release files for shipyard-python-sdk 0.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| shipyard_python_sdk-0.2.4.tar.gz | 7.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| shipyard_python_sdk-0.2.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.4 kB
Release files / shipyard_python_sdk-0.2.4.tar.gz
| Download URL | shipyard_python_sdk-0.2.4.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4c129a21d55ffc31698fc84b1082c91df122ab330481e17d7dda551076a800c2
|
|
BLAKE2b-256 checksum How to use checksums |
0c729aebc032e5a385020b11c73bc5ab9945c30ab0c4e6a90a22fb8f84c5b40a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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}
|
Release files / shipyard_python_sdk-0.2.4-py3-none-any.whl
| Download URL | shipyard_python_sdk-0.2.4-py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a6324846ba5125ff0e778111adc18ac500294bb5bfa0c770a0f7c60c44cba839
|
|
BLAKE2b-256 checksum How to use checksums |
0c07a0a81d4861107739b0bc188395aab449fcd20d24711348cbeac4234e6274
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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}
|