Python gRPC client for the local toolkami daemon
Project description
toolkami
Python gRPC client for the local toolkami daemon.
Install
pip install toolkami
The packaged distribution downloads the matching Linux x64 daemon and guest-agent from the GitHub release for the package version on first client start. Repository checkouts use the local Cargo debug binary.
Usage
from toolkami import Client
client = Client.open(tcp_address="127.0.0.1:50061")
print(client.get_version().version)
print(client.ping("python").message)
client.close()
Daemon Launch and NBD Permissions
The daemon now requires read/write access to NBD block devices (/dev/nbd*).
- Default behavior:
Client.open(...)reuses an existing daemon attcp_address; if not found, it auto-launches one. - If your user lacks NBD permissions, auto-launch fails with an actionable error.
- To disable auto-launch and only connect to an already-running daemon:
client = Client.open(tcp_address="127.0.0.1:50061", auto_launch=False)
- To explicitly opt into privileged launch:
client = Client.open(tcp_address="127.0.0.1:50061", use_sudo=True)
Spawn/Restore with Folder Mounts
from toolkami import Client
from toolkami.v1.image_pb2 import BuildRequest
from toolkami.v1.instance_pb2 import FolderMount, RestoreRequest, SpawnRequest
from toolkami.v1.snapshot_pb2 import SnapshotRequest
client = Client.open(tcp_address="127.0.0.1:50061")
image = client.build(
BuildRequest(
dockerfile_text="FROM ubuntu:24.04\nWORKDIR /workspace",
dockerfile_bytes_max=64_000,
)
)
spawned = client.spawn(
SpawnRequest(
image_id=image.image_id,
mounts=[
FolderMount(
source_host_path="/abs/path/to/repo",
target_path="/workspace/repo",
# access_mode defaults to read-only when omitted
)
],
)
)
snap = client.snapshot(SnapshotRequest(instance_id=spawned.instance_id))
restored = client.restore(
RestoreRequest(
snapshot_id=snap.snapshot_id,
mounts=[
FolderMount(
source_host_path="/abs/path/to/repo",
target_path="/workspace/repo",
)
],
)
)
print(restored.instance_id)
client.close()
Development
make proto-generate
make test
make release-build
make integration-smoke-local
Project details
Release history Release notifications | RSS feed
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 toolkami-0.1.4.tar.gz.
File metadata
- Download URL: toolkami-0.1.4.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6264121955c0678fb40c10654a632083f15534c92f125d41aa3c44edb204913
|
|
| MD5 |
d565bf8337c291ed61e17d054e16e895
|
|
| BLAKE2b-256 |
758a40982f241ffeb89218a2a7864ecbd4023714f94361f28afbb8753dc6262e
|
File details
Details for the file toolkami-0.1.4-py3-none-any.whl.
File metadata
- Download URL: toolkami-0.1.4-py3-none-any.whl
- Upload date:
- Size: 25.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d076860da8146e70466e5b9f7cecdabfc63f167b859b4cfc15df7040cfaa1949
|
|
| MD5 |
59e1874b8043728e7e3088418d7becaf
|
|
| BLAKE2b-256 |
393f0bf5c5885407f550b12a9ad0dbb3bb6683ba9877a44e308a9927a5911a7c
|