anycloud Python SDK
Submit jobs and run workloads on any cloud with anycloud.
Install
pip install anycloud-sdk
Quick start
import anycloud
ac = anycloud.Client()
job = ac.submit("my-training:latest", gpu="h100:8", env={"LR": "0.01"})
job.wait()
print(job.logs())
Chaining jobs
prep = ac.submit("prep:latest")
prep.wait()
train = ac.submit("train:latest", gpu="h100:8", env={"LR": "0.01"})
train.wait()
eval_job = ac.submit("eval:latest")
eval_job.wait()
Fan-out / fan-in
from anycloud import Submission
split = ac.submit("split:latest")
split.wait()
shards = ac.submit_many([
Submission(image="worker:latest", env={"LR": lr})
for lr in ["0.1", "0.01", "0.001"]
])
shards.wait()
merge = ac.submit("merge:latest")
merge.wait()
Workload images
Publish an image containing your code and dependencies, then select its
entrypoint with command. Use an immutable tag or digest when reproducibility
matters:
job = ac.submit(
"ghcr.io/acme/trainer:git-a1b2c3d",
gpu="h100:8",
command=["python", "-m", "training", "--lr", "0.01"],
)
job.wait()
service = ac.serve(
"ghcr.io/acme/inference:git-a1b2c3d",
gpu="L40S:1",
command=["python", "-m", "myapp"],
deployment_id="model-a-001",
)
service.wait_running(timeout=600)
print(service.url)
AnyCloud sets PORT=8088 for Services by default; override it with
env={"PORT": "<port>"}. When a workload fails,
DeploymentFailedError.logs includes its container logs:
from anycloud import DeploymentFailedError
try:
job.wait()
except DeploymentFailedError as e:
print(e.state, e.logs)
Jobs in a persistent Kubernetes Deployment
Create a long-running application Deployment, then submit identity-only Jobs to it:
deployment = ac.create_deployment(
"model-workers",
"ghcr.io/acme/model-worker:latest",
cluster="training",
command=["python", "worker.py"],
gpu="h100:1",
max_concurrent_jobs_per_replica=4,
)
job = ac.submit(deployment=deployment, deployment_id="request-123")
Persistent Deployments do not yet accept named application Secrets. Do not put
sensitive values in env as a workaround; use an application-owned secret
source until Deployment Secret references are available.
Inside that Deployment's Pod, use the same SDK distribution. Your application owns its loop, concurrency, invocation lookup, retry policy, and liveness:
import time
import anycloud
with anycloud.current_deployment() as deployment:
while True:
job = deployment.next_job()
if job is None:
time.sleep(1)
continue
try:
invocation = invocations.get(job.id)
run(invocation)
job.complete()
except TemporaryError as error:
job.retry(str(error))
except Exception as error:
job.error(str(error))
next_job() starts the Job before returning it; there is no separate start
acknowledgement. A CurrentJob can also report invalid(...), observe
cancellation_requested(), and acknowledge cancellation with cleanup().
The projected token is reread for every operation so Kubernetes can rotate it
without restarting the application. Call next_job() only when the process
has capacity, and exit the process if the critical selection loop dies so
Kubernetes can replace it.
Buckets
Discover storage, inspect objects, and chain data between jobs using bucket
handles. Select a credential saved with anycloud credentials new:
ac = anycloud.Client(credentials="aws-prod")
for bucket in ac.list_buckets():
print(bucket.name, bucket.region, bucket.created_at)
data = ac.bucket("training-data")
model = ac.bucket("model-output")
data.upload("~/datasets/imagenet.tar", remote_path="datasets/imagenet.tar")
data.upload_directory("~/datasets/shards", prefix="datasets/shards/")
for entry in data.list_objects(prefix="datasets/"):
print(entry.kind, entry.key, entry.size_bytes)
all_objects = data.list_objects(recursive=True, limit=None)
prep = ac.submit("prep:latest", input=data, output=model)
prep.wait()
train = ac.submit("train:latest", input=model, output=model, gpu="h100:8")
train.wait()
model.download_directory("~/checkpoints", prefix="checkpoints/")
Listings default to 1,000 sorted results; limit=None exhausts every API page.
Prefixes are literal, so include a trailing / to browse a folder. Bucket I/O
and listing stream through the local anycloud api server—no provider SDK
extras are needed. Input buckets must already exist; output buckets used by a
Job can be created by the server.
Downloads validate the received byte count and atomically replace the target
only after a complete response. Incomplete responses are retried twice, then
raise DownloadIntegrityError while preserving any existing target.
Directory upload, download, and prefix deletion use four workers by default;
pass concurrency=1 through 32 to tune the bound. They return a
BucketOperationResult. Partial item failures raise BucketOperationError
with the result summary and ordered (object_key, exception) failures.
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 anycloud_sdk-0.1.62.tar.gz.
File metadata
- Download URL: anycloud_sdk-0.1.62.tar.gz
- Upload date:
- Size: 50.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61936c7fafbf86784cc4ad1203c3305fe8086107a9c09631ec6e7d4b7bfbe4ff
|
|
| MD5 |
dae1acfe694f3918cbba7105a482b2a7
|
|
| BLAKE2b-256 |
0a262e550b686fe21328fe1f3f11b35d34ff93101b1aafa820838cb03a2d0850
|
Provenance
The following attestation bundles were made for anycloud_sdk-0.1.62.tar.gz:
Publisher:
release.yml on anycloud-sh/anycloud
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anycloud_sdk-0.1.62.tar.gz -
Subject digest:
61936c7fafbf86784cc4ad1203c3305fe8086107a9c09631ec6e7d4b7bfbe4ff - Sigstore transparency entry: 2688560025
- Sigstore integration time:
-
Permalink:
anycloud-sh/anycloud@7482038445d67b8e686369131a6934ed01125681 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/anycloud-sh
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
self-hosted -
Publication workflow:
release.yml@7482038445d67b8e686369131a6934ed01125681 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file anycloud_sdk-0.1.62-py3-none-any.whl.
File metadata
- Download URL: anycloud_sdk-0.1.62-py3-none-any.whl
- Upload date:
- Size: 33.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c0f42a2ce5a17138f41aafb89811dd4bf0fee10d5037b064ab47889146c72ee
|
|
| MD5 |
e246572885c0e3156e21b2523a01ecfd
|
|
| BLAKE2b-256 |
42d92b070069a0e61621a8c0be26731693f806856423dd63afbd788ead3f2aaf
|
Provenance
The following attestation bundles were made for anycloud_sdk-0.1.62-py3-none-any.whl:
Publisher:
release.yml on anycloud-sh/anycloud
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anycloud_sdk-0.1.62-py3-none-any.whl -
Subject digest:
2c0f42a2ce5a17138f41aafb89811dd4bf0fee10d5037b064ab47889146c72ee - Sigstore transparency entry: 2688560094
- Sigstore integration time:
-
Permalink:
anycloud-sh/anycloud@7482038445d67b8e686369131a6934ed01125681 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/anycloud-sh
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
self-hosted -
Publication workflow:
release.yml@7482038445d67b8e686369131a6934ed01125681 -
Trigger Event:
workflow_dispatch
-
Statement type: