ECI-backed sandbox manager with an Agent interface.
Project description
English | 简体中文
eci-as-sandbox
ECI-backed sandbox manager built on alibabacloud-eci20180808 with a lightweight API for managing container-group sandboxes.
Install
pdm add eci-as-sandbox
Environment
The client auto-loads a .env file (searching upward from the working directory). You can also pass env_file=... or explicit credentials.
Required Alibaba Cloud credentials:
set ALIBABA_CLOUD_ACCESS_KEY_ID=...
set ALIBABA_CLOUD_ACCESS_KEY_SECRET=...
set ALIBABA_CLOUD_REGION_ID=cn-shanghai
Optional overrides:
set ECI_SANDBOX_ACCESS_KEY_ID=...
set ECI_SANDBOX_ACCESS_KEY_SECRET=...
set ECI_SANDBOX_REGION_ID=cn-shanghai
set ECI_SANDBOX_ENDPOINT=eci.cn-shanghai.aliyuncs.com
set ECI_SANDBOX_TIMEOUT_MS=60000
If you use a private image, configure registry credentials in ECI.
Quick start (sync)
from eci_as_sandbox import EciSandbox
client = EciSandbox()
result = client.create(
image="registry.cn-hangzhou.aliyuncs.com/eci_open/nginx:latest",
name="sandbox-demo",
cpu=1.0,
memory=2.0,
v_switch_id="vsw-xxx",
security_group_id="sg-xxx",
ports=[{"port": 8080, "protocol": "TCP"}],
)
if result.success and result.sandbox:
sandbox = result.sandbox
info = sandbox.info()
print(info.data.status)
sandbox.delete()
Async quick start
import asyncio
from eci_as_sandbox import AsyncEciSandbox
async def main() -> None:
client = AsyncEciSandbox()
result = await client.create(
image="registry.cn-hangzhou.aliyuncs.com/eci_open/nginx:latest",
name="sandbox-demo",
cpu=1.0,
memory=2.0,
v_switch_id="vsw-xxx",
security_group_id="sg-xxx",
)
if result.success and result.sandbox:
info = await result.sandbox.info()
print(info.data.status)
asyncio.run(main())
Command helpers
exec_command runs a list-form command. With sync=True (default) it uses the ECI WebSocket stream to collect output. timeout is in seconds and caps the stream duration (default 600 seconds, max 600). Use sync=False if you want the WebSocket/HTTP URLs without waiting.
result = sandbox.exec_command(
["/bin/sh", "-c", "for i in 1 2 3; do echo tick-$i; sleep 2; done"],
timeout=3,
)
print(result.output)
bash runs a shell command via bash -lc and supports exec_dir.
result = sandbox.bash(
command="pwd; ls -la",
exec_dir="/tmp",
timeout=5,
)
print(result.output)
Listing
result = client.list(limit=10, status="Running")
print(result.sandbox_ids)
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 eci_as_sandbox-0.1.2.tar.gz.
File metadata
- Download URL: eci_as_sandbox-0.1.2.tar.gz
- Upload date:
- Size: 14.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b28701d72f80e0646493eaf4eea88ade963c6fae8f384f3bec880db03d600d4f
|
|
| MD5 |
6df5219029645d250ed251683ad49227
|
|
| BLAKE2b-256 |
42309dc7b5d588bc3f3c89de94acf0fe6e48b5f6ba838d1576904e52b0bde47d
|
Provenance
The following attestation bundles were made for eci_as_sandbox-0.1.2.tar.gz:
Publisher:
publish.yml on AndersonBY/eci-as-sandbox
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
eci_as_sandbox-0.1.2.tar.gz -
Subject digest:
b28701d72f80e0646493eaf4eea88ade963c6fae8f384f3bec880db03d600d4f - Sigstore transparency entry: 813203867
- Sigstore integration time:
-
Permalink:
AndersonBY/eci-as-sandbox@7459b5768edc0a8c66957fc40be157d01fb5135c -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/AndersonBY
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7459b5768edc0a8c66957fc40be157d01fb5135c -
Trigger Event:
push
-
Statement type:
File details
Details for the file eci_as_sandbox-0.1.2-py3-none-any.whl.
File metadata
- Download URL: eci_as_sandbox-0.1.2-py3-none-any.whl
- Upload date:
- Size: 18.0 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 |
74576a05bc9c3895cdacd7960ca21fd2d2a20047ca9821a358c525fc8ed7ebb2
|
|
| MD5 |
a1fcf4946e62455bd38bde260f65499b
|
|
| BLAKE2b-256 |
864bfe047cd73e3b7bc22392be2597e1e15fe18b165d44591bb13b1838b062d7
|
Provenance
The following attestation bundles were made for eci_as_sandbox-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on AndersonBY/eci-as-sandbox
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
eci_as_sandbox-0.1.2-py3-none-any.whl -
Subject digest:
74576a05bc9c3895cdacd7960ca21fd2d2a20047ca9821a358c525fc8ed7ebb2 - Sigstore transparency entry: 813203870
- Sigstore integration time:
-
Permalink:
AndersonBY/eci-as-sandbox@7459b5768edc0a8c66957fc40be157d01fb5135c -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/AndersonBY
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7459b5768edc0a8c66957fc40be157d01fb5135c -
Trigger Event:
push
-
Statement type: