Skip to main content

Python SDK for Watasu

Project description

Watasu Python SDK

Python SDK for Watasu.

Install

pip install watasu

Set WATASU_API_KEY before using the SDK.

Usage

from watasu import Sandbox

sbx = Sandbox()
sbx.files.write("/home/user/a.py", "print(2 + 2)")
result = sbx.commands.run("python /home/user/a.py")
print(result.stdout)
sbx.kill()

Sandbox(), Sandbox.create, and Sandbox.connect return only after the Watasu API supplies a usable data-plane session. The SDK does not poll sandbox readiness.

from watasu import Sandbox

with Sandbox.create() as sbx:
    result = sbx.commands.run("echo hello")
    print(result.stdout)

Leaving the context manager calls kill().

Metrics And Snapshots

from watasu import Sandbox

with Sandbox.create() as sbx:
    metrics = sbx.get_metrics()
    snapshot = sbx.create_snapshot(name="ready")
    snapshots = sbx.list_snapshots().list_items()
    restored = sbx.restore(snapshot_id=snapshot.snapshot_id)

Watasu snapshots are backed by sandbox checkpoints. Use the returned snapshot_id when restoring from a checkpoint.

Async API

from watasu import AsyncSandbox


async def main() -> None:
    async with await AsyncSandbox.create() as sbx:
        result = await sbx.commands.run("echo hello")
        print(result.stdout)

        metrics = await sbx.get_metrics()
        snapshot = await sbx.create_snapshot(name="ready")
        snapshots = await sbx.list_snapshots().list_items()

Unsupported surfaces raise explicit not-implemented errors instead of silently falling back to client-side polling.

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

watasu-0.1.5.tar.gz (67.5 kB view details)

Uploaded Source

Built Distribution

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

watasu-0.1.5-py3-none-any.whl (34.9 kB view details)

Uploaded Python 3

File details

Details for the file watasu-0.1.5.tar.gz.

File metadata

  • Download URL: watasu-0.1.5.tar.gz
  • Upload date:
  • Size: 67.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for watasu-0.1.5.tar.gz
Algorithm Hash digest
SHA256 dbd80716328f9489c38f280cc20b7ced5c6396cd3b14e5a885c6917cf010aa90
MD5 11a5e880c7c062025bc21c8293b5d198
BLAKE2b-256 f6659d3435f74ff78fd567cd1d26d61ce933c17be738900d8dfbdc9c55daa5f3

See more details on using hashes here.

File details

Details for the file watasu-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: watasu-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 34.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for watasu-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 6c61afc50da58aa0140ef56dfc774d5b0d63422aeb845136121c6780bb63170c
MD5 40a40904eba59c4b2280ed6069de949f
BLAKE2b-256 9a7bc3278969c7fc4834774a4decd4c73009158dfe0e304a314006a06fccfcea

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