Skip to main content

Python SDK for Runta runtime management

Project description

Runta Python SDK

This package provides matching async and sync SDKs. Both call the public runta-api HTTP/JSON service; they do not speak control-plane gRPC directly.

Install

pip install runta-sdk

For user-facing installation, configuration, and workflow examples, see doc.md.

For a full API reference with every public method, parameter, return value, and model field, see manual.md.

import asyncio

from runta import AsyncRunta


async def main():
    async with AsyncRunta() as runta:
        runtime = await runta.runtimes.create("example")
        result = await runtime.exec("echo hello")
        print(result.stdout_text)


asyncio.run(main())
from runta import Runta

runta = Runta()
runtime = runta.runtimes.create("example")
result = runtime.exec("echo hello")
print(result.stdout_text)
runta.close()

Authentication uses Runta(token="rt_...") or RUNTA_TOKEN. The endpoint defaults to https://api.runta.me; override it with Runta(endpoint="..."), RUNTA_ENDPOINT, or endpoint from the optional Runta config file.

Public REST endpoint lifecycle test

You can test the SDK against the hosted REST API by pointing the client at https://api.runta.me and providing a Runta token:

export RUNTA_TOKEN="rt_..."
uv run python scripts/runta-lifecycle.py

The lifecycle script creates a runtime, starts it, runs a command, writes and reads a remote file, uploads a local file, downloads it back, pauses/resumes the runtime, then stops and deletes it. To pass credentials explicitly:

uv run python scripts/runta-lifecycle.py \
  --endpoint https://api.runta.me \
  --token "$RUNTA_TOKEN"

Use --keep to leave the runtime behind for inspection.

The SDK is aligned with the current crates/runta-api REST routes. The OpenAPI contract exposes single-file raw byte routes at /v1/runtimes/{runtime_id}/files for runtime.files.read, runtime.files.write, runtime.files.upload, and runtime.files.download. SDK sessions are SDK-owned handles because persistent server-side session routes are not exposed.

REST contract

contracts/runta-api.openapi.yaml is copied from runta/crates/runta-openapi/specs/openapi.yaml and is used by the SDK contract tests. CI refreshes this file from the latest successful runta OpenAPI contract artifact before running tests. If the artifact is unavailable, it falls back to the dev branch raw YAML and then to the checked-in contract.

To refresh it locally after changing runta-api:

cd ~/runta
cargo make openapi
cp crates/runta-openapi/specs/openapi.yaml ~/RuntaPythonSDK/contracts/runta-api.openapi.yaml
cd ~/RuntaPythonSDK
uv run python -m pytest tests/test_openapi_contract.py

To fetch the latest published contract directly:

scripts/fetch-runta-openapi.py

Live tests

The live test module runs mocked SDK workflow tests by default:

python -m unittest tests/test_live.py -v

Pass --live to run the real runtime tests. They create real runtimes and use external egress, so run them only with scripts/dev-api.sh already running:

uv run python -m pytest --live

Local pytest loads .env automatically. The default local file uses:

RUNTA_ENDPOINT=http://127.0.0.1:8080
RUNTA_TOKEN_FILE=../runta/.dev/cli_token_dev-a

Copy or edit .env.example if your checkout paths differ.

Release

This repository publishes runta-sdk to PyPI from GitHub Releases.

  1. Update version in pyproject.toml.
  2. Run uv run --extra dev python -m pytest.
  3. Run rm -rf dist && uv build and uvx twine check dist/*.
  4. Commit the release change and create a GitHub Release whose tag is exactly v{pyproject version}, for example v0.0.5.

The Publish SDK workflow validates that the release tag matches pyproject.toml and publishes the built distributions to PyPI with trusted publishing.

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

runta_sdk-0.0.5.tar.gz (35.2 kB view details)

Uploaded Source

Built Distribution

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

runta_sdk-0.0.5-py3-none-any.whl (23.5 kB view details)

Uploaded Python 3

File details

Details for the file runta_sdk-0.0.5.tar.gz.

File metadata

  • Download URL: runta_sdk-0.0.5.tar.gz
  • Upload date:
  • Size: 35.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for runta_sdk-0.0.5.tar.gz
Algorithm Hash digest
SHA256 323abde5befa252f5124d65958c3dd0cdabf4f0545b8230a367fa8d1eb9028e3
MD5 5aab119de38c84d68064f65a4f1f7795
BLAKE2b-256 445730cfbea0857f6fe83013a70b00fd2baa2f578c3e2aac4df429bc17d4dcfa

See more details on using hashes here.

Provenance

The following attestation bundles were made for runta_sdk-0.0.5.tar.gz:

Publisher: publish-sdk.yml on runta-dev/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file runta_sdk-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: runta_sdk-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 23.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for runta_sdk-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 69ccdebc697d17d54ef6bd7cf20bcf216541f00786526ed14761b9e0f4d3ca31
MD5 b77e54c1e06495cc45474256b0611bec
BLAKE2b-256 e54a8c1304a0aac62769b09ba9362c1c0eea747c046c5fe799e40b034bdbcebb

See more details on using hashes here.

Provenance

The following attestation bundles were made for runta_sdk-0.0.5-py3-none-any.whl:

Publisher: publish-sdk.yml on runta-dev/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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