Skip to main content

Run Astra-compressed models on-device with local ONNX serving and built-in closed-loop telemetry that feeds the Astra dashboard

Project description

astra-ai-sdk

Serve Astra-compressed models on your own hardware — Astra never runs your model server-side — and keep the Astra dashboard monitoring them while they run.

pip install 'astra-ai-sdk[serve]'         # on-device ONNX serving (onnxruntime, numpy)
pip install 'astra-ai-sdk[serve,system]'  # + precise CPU/RSS metrics (psutil)

Exports: AstraRunner, AstraRunnerError, pull_artifact, AstraTelemetryReporter, AstraApiError.

On-device serving (the whole product)

AstraRunner.from_deployment pulls the deployed, compressed artifact once (sha256-cached under ~/.cache/astra) and serves it with onnxruntime inside your own process — no server to stand up, no hosted inference:

from astra_sdk import AstraRunner

# base_url defaults to the hosted Astra origin (override with ASTRA_BASE_URL).
runner = AstraRunner.from_deployment("dep_ab12cd34ef", "astra_sk_live_...")
out = runner.run({"input": my_numpy_array})   # bare ndarray per input name
print(out["latencyMs"], out["outputs"], out["preMs"], out["postMs"])
runner.close()                                 # final telemetry flush

run() returns {latencyMs, outputs, preMs, postMs, raw}.

Run a file you already have

Downloaded the artifact (SDK Hub → Download Artifact) or have an .onnx on disk? Skip the deployment — serve the file directly:

from astra_sdk import AstraRunner

runner = AstraRunner.from_file("compressed.onnx")
out = runner.run({"input": my_numpy_array})
runner.close()

Telemetry is off for a bare file; pass deployment_id= + api_key= to still report local runs to that deployment.

Closed-loop telemetry (offline-durable)

Every on-device inference is measured and shipped back to Astra through a durable closed loop that can never block or break your serving path:

  • buffers events in memory and spools them to disk when offline;
  • flushes the buffered batches automatically on reconnect;
  • deletes each batch only after the server acks it, with per-batch idempotency so a retry is never double-counted.
Stream Cadence Fields
Request events per inference timestamp, latency breakdown (preprocess / inference / postprocess ms), success / error code, batch size, region tag, input shape signature
System snapshots ~30 s CPU %, RSS MB, throughput req/min, dropped-event count, SDK / Python / onnxruntime versions, OS, arch, execution provider, hostname
Window stats ~60 s or 200 requests per-input tensor mean/std/min/max/NaN%, output class distribution (top-10), 16-bin confidence histogram, mean entropy, mean top-1 confidence

Window stats power the dashboard's prediction drift (PSI vs the deployment's reference distribution) and input distribution shift alerts.

Opt out any time: AstraRunner.from_deployment(..., report_telemetry=False) or ASTRA_SDK_TELEMETRY=0. Disable the on-disk spool with ASTRA_SDK_SPOOL=0 (telemetry then buffers in memory only).

CLI

astra pull                  # pull the compressed artifact
astra serve --port 8765     # on-device HTTP endpoint: POST /infer
astra bench -n 200          # on-device p50/p95, reported as telemetry

Options can come from ASTRA_BASE_URL, ASTRA_DEPLOYMENT_ID, ASTRA_API_KEY (or --deployment / --api-key / --base-url flags).

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

astra_ai_sdk-0.4.2.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

astra_ai_sdk-0.4.2-py3-none-any.whl (22.4 kB view details)

Uploaded Python 3

File details

Details for the file astra_ai_sdk-0.4.2.tar.gz.

File metadata

  • Download URL: astra_ai_sdk-0.4.2.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for astra_ai_sdk-0.4.2.tar.gz
Algorithm Hash digest
SHA256 bdd1bc972ce854fd2651b9ae6198d9dcc2cf72802cfdbefc394d770d28c3d919
MD5 9cbb6160d1bf887964516c0f3b0a34dd
BLAKE2b-256 1e3faf2b274f2e09b4c6b0334ef2da7a37ec3ee1547e4091c51e064272e8ecfc

See more details on using hashes here.

File details

Details for the file astra_ai_sdk-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: astra_ai_sdk-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 22.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for astra_ai_sdk-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dd30ed919e7919493a2442c303254dc93fc0c1c03f885800b0e2c3a3ea5754b2
MD5 a81cc97d80eacd95a397ed77a4ffb7ca
BLAKE2b-256 6b54532a3e6e84c6da1e542206c96870666a20e4140357f91586391646075b8c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page