numen-sandbox-py
Python client for the Numen sandbox API. 0.x beta. The API can change between minor versions.
Install
pip install numen-sandbox-py
Credentials
The SDK reads ~/.config/numen/credentials.json.
Create and run
image is required. numen/base is the general platform image. The with
block destroys the sandbox when the block ends. sb.destroy() does the same.
from numen_sandbox_py import Sandbox
with Sandbox.create(image="numen/base") as sb:
print(sb.run(["python", "-c", "print(2+2)"]).stdout)
Pass id= to keep a stable name. The same id on a later create returns
that sandbox. net="egress" allows outbound network.
timeout is seconds on every call. Omit it to keep that call's default.
0 means no limit: run does not kill the command, and a file call does
not stop on its own.
Your own image
build_image sends a Dockerfile and the directory next to it. The name you
give is what you later pass to create.
from numen_sandbox_py import Client, Sandbox
with Client() as c:
c.build_image("my-agent", dockerfile="Dockerfile", context=".")
with Sandbox.create(c, image="my-agent") as sb:
print(sb.run(["python", "-c", "print(2+2)"]).stdout)
FROM python:3.12-slim
FROM is always a public image. An image you have already built or
registered, including numen/base, cannot be the base of a new one.
Files
Paths are under /work. upload writes one file, or a local directory as
one tree. A directory upload replaces that guest directory. Pass
overwrite=False to update only the paths you send.
sb.upload("/work/hello.py", "print('hi')\n", mode=0o755)
sb.upload("/work/app", local="./app")
print(sb.run(["python", "/work/hello.py"]).stdout)
write is a batch of file bodies, mkdir, and rm, in the order you give.
read returns the bytes of one file.
A process that stays up
start leaves the process running. write_stdin sends to that process.
follow yields stdout and stderr until it exits. wait blocks until it exits.
proc = sb.start(["python", "-u", "-c", "print(input())"])
proc.write_stdin("hello\n", eof=True)
for entry in proc.follow():
print(entry.stream, entry.line)
proc.wait()
Async
AsyncSandbox and AsyncClient have the same methods. await them, and
use async with.
Metadata
Release files for numen-sandbox-py 0.22.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| numen_sandbox_py-0.22.0.tar.gz | 84.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| numen_sandbox_py-0.22.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 176.1 kB
Release files / numen_sandbox_py-0.22.0.tar.gz
| Download URL | numen_sandbox_py-0.22.0.tar.gz |
|---|---|
| Size | 84.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b95a478354de2462d90c091634453cd04e8b2d76cf6400383df45ce9a634c55d
|
|
BLAKE2b-256 checksum How to use checksums |
2d9dd6023ca5aa73355f02c21c6b3c7ac2f83b93f983907e6af26e9aea609c62
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / numen_sandbox_py-0.22.0-py3-none-any.whl
| Download URL | numen_sandbox_py-0.22.0-py3-none-any.whl |
|---|---|
| Size | 91.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9f986f97a4db42b38524ac90ae07bafd2a81bb67d4156c5ba7bb71668cc7e80d
|
|
BLAKE2b-256 checksum How to use checksums |
10de69ad223365165f3ebbd8bb6c8a3d0ed75917bdba0fe18885f22b48d590a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for numen-sandbox-py 0.22.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.