Cloud bursting for AI workloads over a NATS bus — Python client + IPython %%burst magic
Project description
nats-bursting (Python client)
Atlas-side Python client + IPython cell magic for the nats-bursting controller.
The Go controller (in the parent directory) listens on a NATS bus and
dispatches Kubernetes Jobs to a remote cluster (e.g. NRP Nautilus).
This package is the submitter: it lets a Python script — or a
Jupyter notebook cell via the %%burst magic — publish job
descriptions to the controller and wait for an acknowledgement.
Install
pip install -e nats-bursting/python # local checkout
pip install 'git+https://github.com/ahb-sjsu/nats-bursting.git#subdirectory=python' # from GitHub
Optional extras: [ipython] for the cell magic, [dev] for tests + lint.
Two ways to use it
1. Library API
from nats_bursting import Client, JobDescriptor, Resources
client = Client(nats_url="tls://atlas-xxxx.ts.net:443")
result = client.submit_and_wait(
JobDescriptor(
name="hello",
image="python:3.12-slim",
command=["python", "-c", "print('hi from nautilus')"],
resources=Resources(cpu="1", memory="1Gi"),
),
timeout=60,
)
print(result.k8s_job_name)
2. Jupyter %%burst cell magic
%load_ext nats_bursting.magic
%%burst --gpu 1 --memory 16Gi
import torch
print(torch.cuda.is_available())
By default %%burst checks the local GPU first (via nvidia-smi)
and only ships the cell to Nautilus if every local GPU is past the
busy threshold. Useful flags:
| Flag | Behavior |
|---|---|
--when-busy (default) |
Burst only if local GPU is busy |
--always |
Burst unconditionally |
--never |
Run locally unconditionally |
--gpu N |
Request N GPUs in the burst pod |
--cpu X |
CPU request ("2", "500m") |
--memory X |
Memory request ("16Gi") |
--image IMG |
Container image; default python:3.12-slim |
--timeout S |
Submit-ack timeout in seconds |
--dry-run |
Print the JobDescriptor JSON, don't submit |
Cell source is shipped to the pod via the NATS_BURSTING_CELL
environment variable and run with python -c "$NATS_BURSTING_CELL".
Anything that fits in a 1 MiB env var fits in a cell, which is
every realistic notebook cell.
Configuration
The magic reads two env vars so notebooks stay portable:
export NATS_BURSTING_NATS_URL="tls://atlas-xxxx.ts.net:443"
export NATS_BURSTING_NATS_CREDS="/path/to/nats.creds" # optional
What's missing (yet)
| Feature | Status |
|---|---|
| Submit + ack | ✅ |
| Local GPU probe | ✅ |
| Cell magic | ✅ |
| Live log streaming back to the notebook | ⏳ needs controller-side kubectl logs -f → NATS bridge |
| Auto-build of a Python image with the user's installed packages | ⏳ |
| File / dataset upload to the burst pod | ⏳ — current pattern: pre-stage on a Nautilus PVC and reference by path |
Running tests
cd python
pip install -e '.[ipython,dev]'
pytest -q
29 tests exercise descriptor serialization, the GPU probe, the
client (against a FakeTransport — no broker required), and the
IPython magic.
Architecture
See ../docs/design.md for the full picture and
../docs/nats-leafnode-duckdns.md for how Atlas's NATS fabric
extends into NRP via a leaf-node bridge.
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 nats_bursting-0.1.0.tar.gz.
File metadata
- Download URL: nats_bursting-0.1.0.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
600c62a5c962f346f2e26cc5fdfde668d2bd46447691556afa9dee043e020a33
|
|
| MD5 |
c2ca11d9653433ff0e9f2dfd8e358ea4
|
|
| BLAKE2b-256 |
74eb55e17356225887000e06099fc5d8d5efb5d79fa23ecc91ed1388ec9532a3
|
File details
Details for the file nats_bursting-0.1.0-py3-none-any.whl.
File metadata
- Download URL: nats_bursting-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7942b7506bff54c672183fe4975c05dcd114ba967ed6a020a1e2040279c5c214
|
|
| MD5 |
3cd44332b81250797637a7849d2c45df
|
|
| BLAKE2b-256 |
df7a1172eb3a0212db6f003a9426142a3f6597558331749cddc5d5e0c5aeba4d
|