Skip to main content

ix-sdk

Generated Python bindings for ix. The Rust ix-sdk owns every platform verb; Unibind generates the asyncio classes, typed records, exception classes and .pyi stubs from that contract, so the Python surface never drifts from the platform.

Python 3.13 or newer. The package ships py.typed and generated stubs, so pyright and mypy see the same methods and records the native module exports.

boot a machine

The credential resolves from IX_TOKEN, then the ix config file written by ix login, so there is no client to configure. The machine answers by the time create returns.

import asyncio

import ix_sdk


async def main() -> None:
    client = ix_sdk.Client()
    machine = await client.machines().create(ix_sdk.CreateMachineOptions(name="sdk-example"))
    try:
        result = await machine.exec_checked(["uname", "-a"])
        print(result.stdout.strip())
    finally:
        await machine.delete()


asyncio.run(main())

async with deletes a machine the handle booted at the end of the block, exception or not. Bind it with a plain = when the machine is meant to outlive the program; a machine outlives the process that made it, and client.machines().connect(machine_id) reattaches later.

boot from your repository's flake

Pass a sha-pinned flake reference as the template and the platform builds it in-guest on first use, publishes the result to the region's template cache, and boots every later create warm from that cache. Builds are single-flight region-wide, and create_stream carries the live build log:

options = ix_sdk.CreateMachineOptions(
    template="github:owner/repo/0123456789abcdef0123456789abcdef01234567#ci-runner",
)
stream = await client.machines().create_stream(options)
async for frame in stream:
    if frame.stderr:
        print(frame.stderr, end="")
    if frame.finished:
        machine = client.machines().connect(frame.machine_id)

everything else

Every verb is a method on the generated surface: machine.exec, machine.read_file, machine.write_file, machine.snapshot, machine.tail_logs, client.keys().create, and so on. Streams are async for iterables, and dropping the iterator cancels the work behind it.

Records are typed objects with documented read-only properties and a readable repr, and every record is dict-like: dict(machine), {**machine} and machine["status"] all work, so a list of records drops straight into a DataFrame.

The one piece of language-owned sugar is Repl, a stateful interpreter inside a machine:

repl = await ix_sdk.Repl.open(machine, "python")
await repl.exec("x = 21")
out = await repl.exec("print(x * 2)")

docs

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

ix_sdk-0.7.1-cp313-abi3-manylinux_2_34_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.13+manylinux: glibc 2.34+ x86-64

File details

Details for the file ix_sdk-0.7.1-cp313-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for ix_sdk-0.7.1-cp313-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 49434f2d6394620bb210b18736a61f15d2bd06808fadcc0c8fde2362efdc0ac5
MD5 b76ffa62ef99ea2af7418f5b10ae0a6b
BLAKE2b-256 c0d2f09a9eb63dc858470aa2bceb3714d767e9750276fb80e5d33b853c79bd5d

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 Sentry Error logging StatusPage Status page