Python SDK for Replicated customer, metrics, and instance insights
Project description
Replicated Python SDK
A Python SDK for embedding Replicated customer, custom metrics, and instance insights data in your applications.
Installation
Install the SDK via pip:
pip install --upgrade replicated
Usage
Sync Example
from replicated import ReplicatedClient, InstanceStatus
client = ReplicatedClient(
publishable_key="replicated_pk_...",
app_slug="my-app"
)
# Create a customer (or fetch an existing one)
customer = client.customer.get_or_create(email_address="xxx@yyy.com")
# Get or create the associated instance
instance = customer.get_or_create_instance()
# Use the instance for metrics and status reporting
instance.send_metric("cpu_usage", 0.83)
instance.set_status(InstanceStatus.RUNNING)
instance.set_version("1.2.0")
Custom State Directory
By default, the SDK stores state in platform-specific directories. You can override this for testing, containerization, or custom deployments:
from replicated import ReplicatedClient
# Use a custom directory (supports ~ and relative paths)
client = ReplicatedClient(
publishable_key="replicated_pk_...",
app_slug="my-app",
state_directory="/var/lib/my-app/replicated-state"
)
# Or use a relative path (will be resolved to absolute)
client = ReplicatedClient(
publishable_key="replicated_pk_...",
app_slug="my-app",
state_directory="./local-state"
)
When to use custom state directories:
- Testing with temporary directories
- Docker containers with mounted volumes
- Multi-tenant applications requiring isolated state
- Development with project-local state
Async Example
from replicated import AsyncReplicatedClient, InstanceStatus
async def main():
async with AsyncReplicatedClient(
publishable_key="replicated_pk_...",
app_slug="my-app"
) as client:
customer = await client.customer.get_or_create(email_address="xxx@yyy.com")
instance = await customer.get_or_create_instance()
await instance.send_metric("cpu_usage", 0.83)
await instance.set_status(InstanceStatus.RUNNING)
await instance.set_version("1.2.0")
Documentation
For detailed documentation, visit docs.replicated.com/sdk/python.
License
MIT License
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 replicated-0.1.0a1.tar.gz.
File metadata
- Download URL: replicated-0.1.0a1.tar.gz
- Upload date:
- Size: 43.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31a20281b2decaa235261479e05a006af72666d1af9b1f439c4698c046078b2e
|
|
| MD5 |
7ed2a9ab6a0c13b20601f9d76a9d597c
|
|
| BLAKE2b-256 |
056747bd0e33bb2a14e9ab3715eaadda9db3751f581ad58c1956f41bc4adeae3
|
Provenance
The following attestation bundles were made for replicated-0.1.0a1.tar.gz:
Publisher:
publish.yml on replicatedhq/replicated-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
replicated-0.1.0a1.tar.gz -
Subject digest:
31a20281b2decaa235261479e05a006af72666d1af9b1f439c4698c046078b2e - Sigstore transparency entry: 606459435
- Sigstore integration time:
-
Permalink:
replicatedhq/replicated-python@2863a34d6fed68ebdf42914b6e356220ce2084f7 -
Branch / Tag:
refs/tags/0.1.0-alpha.1 - Owner: https://github.com/replicatedhq
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2863a34d6fed68ebdf42914b6e356220ce2084f7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file replicated-0.1.0a1-py3-none-any.whl.
File metadata
- Download URL: replicated-0.1.0a1-py3-none-any.whl
- Upload date:
- Size: 11.7 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 |
0aa34b61107dfe85766e58f7a8b8dc883385a7355c60530eab7bf2e52ef72d3e
|
|
| MD5 |
8f8b722b42c20e4fa05f03d11cc5fa9e
|
|
| BLAKE2b-256 |
d0a469198b88f6fe15a83853dcd37d3e57ee0425a179ffadf4a70fd6d47c87bb
|
Provenance
The following attestation bundles were made for replicated-0.1.0a1-py3-none-any.whl:
Publisher:
publish.yml on replicatedhq/replicated-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
replicated-0.1.0a1-py3-none-any.whl -
Subject digest:
0aa34b61107dfe85766e58f7a8b8dc883385a7355c60530eab7bf2e52ef72d3e - Sigstore transparency entry: 606459439
- Sigstore integration time:
-
Permalink:
replicatedhq/replicated-python@2863a34d6fed68ebdf42914b6e356220ce2084f7 -
Branch / Tag:
refs/tags/0.1.0-alpha.1 - Owner: https://github.com/replicatedhq
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2863a34d6fed68ebdf42914b6e356220ce2084f7 -
Trigger Event:
push
-
Statement type: