Asyncio grpclib SDK for afs_proxy/afslet
Project description
Python Async SDK (grpclib)
This SDK talks to afs_proxy / afslet using asyncio + grpclib.
Generated protobuf modules are inside afs_sdk/api/....
Version
When imported from a git checkout, afs_sdk.__version__ is resolved from:
git describe --tags --long --always --dirty --match 'v*'
Example output:
>>> import afs_sdk
>>> afs_sdk.__version__
'v0.2.0-1-gabc1234-dirty'
>>> afs_sdk.get_version_info()
VersionInfo(version='v0.2.0-1-gabc1234-dirty', tag='v0.2.0', commit_sha='abc1234', distance=1, dirty=True)
When installed from a built distribution without .git metadata, it falls back
to the package metadata version. PyPI release versions are derived from git tags
via setuptools_scm.
Setup (uv)
cd python
~/.local/bin/uv sync
API
- Low-level:
AfsClient.raw_execute(requests: AsyncIterator[ExecuteRequest]) - High-level:
AfsClient.execute(request: ExecuteInput)- request is a single typed object (
image, optionalcommand, optionalenv, resources, and extra file entries) envaccepts either adict[str, str]or a sequence ofKEY=VALUEstrings, and overrides image env on key conflict- set
force_local_fetch=Trueto force local layer fetch on selected layerstore - response is
AsyncIterator[ExecuteEvent]
- request is a single typed object (
- Proxy status stream:
AfsClient.status(include_layerstores=True, include_afslets=True)- returns
AsyncIterator[ProxyStatusEvent]
- returns
- Reconcile image replica:
AfsClient.reconcile_image(request: ReconcileImageInput)- request: image/tag/platform/replica
- response:
ReconcileImageResult(image_key, current_replica, requested_replica, ensured)
- Execute tar.gz output is parsed in streaming form into:
TarDirectoryTarSymlinkTarFilePart(chunked file data; no full-file buffering)
- CPU-heavy tar.gz decode/untar is offloaded via executor:
- pass
tar_executor=...toAfsClient - default is an internal
ThreadPoolExecutor(max_workers=1)
- pass
Extra file input types
ExtraFile.content supports:
bytesAsyncIterator[bytes]
Example
import asyncio
from afs_sdk import AfsClient, ExecuteInput, ExtraFile
async def run():
req = ExecuteInput(
image="alpine",
tag="latest",
command=["/bin/sh", "-c", "echo ok >/tmp/ok.txt"],
env={"FOO": "bar", "PATH": "/custom/bin"},
fuse_max_read_ahead_bytes=16 << 20,
cpu_cores=1,
memory_mb=256,
timeout_ms=2000,
extra_entries=[
ExtraFile(path="hello.txt", content=b"hello from sdk\n"),
],
)
async with AfsClient("127.0.0.1", 62051) as client:
async for event in client.execute(req):
print(type(event).__name__)
asyncio.run(run())
CLI-style demo:
PYTHONPATH=python ~/.local/bin/uv run python python/examples/execute_stream.py \
--addr 127.0.0.1:62051 \
--dir ./extra-dir \
--env FOO=bar \
--env PATH=/custom/bin \
--image alpine --tag latest \
-- /bin/sh -c 'echo ok >/tmp/ok.txt'
If command is omitted, AFS uses the image Entrypoint/Cmd defaults returned by discovery.
Reconcile image replica demo:
PYTHONPATH=python ~/.local/bin/uv run python python/examples/reconcile_image.py \
--addr 127.0.0.1:62051 \
--image alpine --tag latest --replica 0
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
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 afs_sdk-0.2.3.tar.gz.
File metadata
- Download URL: afs_sdk-0.2.3.tar.gz
- Upload date:
- Size: 30.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f032b294ade9518579bdf3cbc080bbb97508fc7914a82bbf23a37b366c36cd4
|
|
| MD5 |
3c5f1bd30e746cdb1bb90ce6a22c0372
|
|
| BLAKE2b-256 |
f1009ade7a7e97fd8453a16f8649d9de55eceb6840dd4293b50967205deb8a18
|
Provenance
The following attestation bundles were made for afs_sdk-0.2.3.tar.gz:
Publisher:
python-publish.yml on reyoung/afs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
afs_sdk-0.2.3.tar.gz -
Subject digest:
9f032b294ade9518579bdf3cbc080bbb97508fc7914a82bbf23a37b366c36cd4 - Sigstore transparency entry: 1115443775
- Sigstore integration time:
-
Permalink:
reyoung/afs@8e960fa4687ef982e93a08ed424b61e0992d9dcd -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/reyoung
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@8e960fa4687ef982e93a08ed424b61e0992d9dcd -
Trigger Event:
release
-
Statement type:
File details
Details for the file afs_sdk-0.2.3-py3-none-any.whl.
File metadata
- Download URL: afs_sdk-0.2.3-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d29948d161d63c587f71b46feb7156a6f4cb87a76362cecb31628bb7aa0ac2c
|
|
| MD5 |
015b7c6d5635967e8f5f3c8ef17d35a7
|
|
| BLAKE2b-256 |
6d73fb775bbfe1caca34640455386f099d5d828b2461ec492a97a7458c6e0ebe
|
Provenance
The following attestation bundles were made for afs_sdk-0.2.3-py3-none-any.whl:
Publisher:
python-publish.yml on reyoung/afs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
afs_sdk-0.2.3-py3-none-any.whl -
Subject digest:
1d29948d161d63c587f71b46feb7156a6f4cb87a76362cecb31628bb7aa0ac2c - Sigstore transparency entry: 1115443788
- Sigstore integration time:
-
Permalink:
reyoung/afs@8e960fa4687ef982e93a08ed424b61e0992d9dcd -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/reyoung
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@8e960fa4687ef982e93a08ed424b61e0992d9dcd -
Trigger Event:
release
-
Statement type: