This client uses Platform API 4.41.0.
To install without cloning, run the following command:
pip install git+https://github.com/CentML/centml-python-client.git@mainAlternatively to build from source, clone this repo then inside the project's base directory, run the following command:
pip install . For interactive use, authenticate once with the CLI. SDK examples reuse the stored credentials and refresh them when needed.
centml login
python examples/sdk/validate_auth.pyFor service-to-service use, provide both service-account environment variables:
export CENTML_SERVICE_ACCOUNT_ID="<service-account-id>"
export CENTML_SERVICE_ACCOUNT_SECRET="<service-account-secret>"
python examples/sdk/validate_auth.pyCENTML_PLATFORM_API_URL can be set when targeting a non-production API.
The Dynamo example uses SDK authentication separately from the bearer token that protects the deployed inference endpoint:
export CENTML_CLUSTER_ID="<cluster-id>"
export CENTML_HARDWARE_INSTANCE_ID="<hardware-instance-id>"
export CENTML_ENDPOINT_BEARER_TOKEN="<new-endpoint-token>"
# Required only for gated Hugging Face models:
export HF_TOKEN="<hugging-face-token>"
python examples/sdk/create_dynamo.pyUse python examples/sdk/get_clusters.py and
python examples/sdk/manage_hardware_instances.py to discover the required IDs.
Creating the example reserves GPU capacity and may incur usage charges. It does not
delete the deployment automatically.
fetch_logs() is the one way to read deployment logs: it fetches one pod's stored
log lines within a time window (start_time/end_time, epoch ms, inclusive) and
yields them lazily, oldest first, as chunks of DeploymentLogEvent — each line at
most once, holding only a short dedup window in memory however long the stream.
chunk_size (1 to 5000) is the number of lines requested from the server per
round trip and each server page that carries window lines becomes one chunk, so
a bulk read of history wants a large chunk_size — the log read path is
rate-limited upstream, and a small chunk_size over a large window multiplies
requests. Discover pod names with get_deployment_pods()
(terminated pods still within log retention are included). start_time defaults
to the moment of the call; with end_time set the iterator terminates once the
window is delivered or the store has no more lines to give, whichever comes
first:
for chunk in cclient.fetch_logs(DEPLOYMENT_ID, REVISION, pod, start_time=t1_ms, end_time=t2_ms):
for event in chunk:
print(event.message)Without end_time the same generator tails: it never terminates, and once caught
up it yields an empty chunk each time nothing new is stored yet — the caller
decides when to sleep or break:
import time
for chunk in cclient.fetch_logs(DEPLOYMENT_ID, REVISION, pod):
if not chunk:
time.sleep(2)
continue
for event in chunk:
print(event.message)python examples/sdk/get_deployment_logs.py runs both. get_deployment_logs(),
get_deployment_logs_range() and deployment_log_session() still work but are
deprecated in favor of fetch_logs() and emit a DeprecationWarning on use.
To uninstall centml, simply do:
pip uninstall centmlOnce installed, use the centml CLI tool with the following command:
centml If you want tab completion, run
source scripts/completions/completion.<shell language>Shell language can be: bash, zsh, fish
(Hint: add source /path/to/completions/completion.<shell language> to your ~/.bashrc, ~/.zshrc or ~/.config/fish/completions/centml.fish)
Registering, updating and deleting clusters requires admin privileges (PERM_ADMIN_MANAGE_HARDWARE). Before registering, install the infra-plane operator in the cluster and create a ServiceAccount token with cluster-admin access:
helm install ccluster-ip oci://ghcr.io/nvidia/charts/ccluster-ip --version <version> \
-n ccluster-ip-system --create-namespaceRegister a cluster. --ca-cert is the base64-encoded PEM CA certificate of the
API server, as in a kubeconfig's certificate-authority-data. The bearer token is
prompted for, with hidden input, when --bearer-token is omitted:
ccluster register-cluster --name my-cluster --storage-class standard-rwo \
--server https://<api-server> --ca-cert <base64-ca-cert> \
--cloud-provider gcp --region us-east1List the clusters you have access to, with their IDs:
ccluster list-clustersUpdate the components installed on a registered cluster. The file is the
PUT /clusters/{id} request body, in YAML or JSON: components maps each component to
its Helm chart values ({} for the defaults). final_stack is required. Components left out
of the file are uninstalled, and an empty entry such as istio: is rejected:
cat > components.yaml <<EOF
components:
kube_prometheus_stack: {}
istio: {}
cert_manager: {}
ingress_nginx: {}
keda: {}
argo_rollouts: {}
gpu_operator: {}
kai_scheduler: {}
metrics_server: {}
final_stack: {}
EOF
ccluster update-cluster <cluster-id> components.yamlDelete a cluster. For a cluster managed by ccluster, this also uninstalls the
components installed through it. Pass --yes to skip the confirmation prompt:
ccluster delete-cluster <cluster-id>examples/sdk/register_cluster.py, update_cluster.py, get_clusters.py and
delete_cluster.py do the same with the SDK.
To run tests, first install required packages:
pip install -r requirements-dev.txt
cd testsWhen running on a local machine, it is recommended to run tests with the following command. This skips tests that require a GPU.
pytest --sanityTo run all the tests, use:
pytestThe Update Platform API client workflow opens an upgrade PR in this repository
after a generated API client is published. It updates requirements.txt and the
compatibility note above. Existing PR workflows run the SDK/CLI sanity tests,
formatting, lint, and type checks. Merging requires review; SDK version bumps and
releases remain separate.
Configure the repository Actions secret SDK_UPDATE_TOKEN with a bot's fine-grained
personal access token scoped to this repository, with Contents: Read and write
and Pull requests: Read and write. Using a bot token lets the resulting PR run
CI automatically; PR events created with GITHUB_TOKEN require workflow approval
(GitHub token documentation).
After the generated client's PyPI publish job succeeds, add this step to its
publishing workflow (use needs if it is in a separate job):
- name: Request SDK upgrade
env:
GH_TOKEN: ${{ secrets.SDK_UPDATE_TOKEN }}
# Replace this expression with the publishing workflow's version output.
CLIENT_VERSION: ${{ steps.version.outputs.version }}
run: |
jq -n --arg version "$CLIENT_VERSION" \
'{event_type: "platform-api-client-published", client_payload: {version: $version}}' \
| gh api --method POST repos/CentML/centml-python-client/dispatches --input -The publishing repository also needs the SDK_UPDATE_TOKEN secret. Its token
must have Contents: Read and write access to this SDK repository to dispatch
the event; the publisher's default GITHUB_TOKEN cannot access another repository.
For a manual run or a retry after PyPI propagation, use the Actions UI or:
gh workflow run update_platform_api_client.yml \
--repo CentML/centml-python-client -f version=4.42.0The workflow runs on Python 3.12 and accepts stable X.Y.Z versions with an optional
v prefix. It explicitly checks that PyPI has a distribution compatible with the
SDK's minimum supported version, Python 3.10. It skips versions at or below the pin
on the default branch. Repeated requests for the same newer version
leave its existing PR unchanged, including handwritten SDK/CLI fixes. A closed PR
is also left alone; reopen it manually if the upgrade should proceed. If a run
pushed the branch but failed to open a PR, retrying opens a PR from that branch
without rewriting it. Different versions get separate branches so a delayed event
cannot replace a newer pending upgrade. Runs for different version inputs use
separate concurrency groups so incoming events do not replace another version's
pending run. After merging a newer version, close any older pending upgrade PRs.
-
SSLcertificate onMacOSSometimes, you will see issues when using command like
centml cluster [CMD], where the output might look like:File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/util/retry.py", line 519, in increment raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.centml.com', port=443): Max retries exceeded with url: /deployments (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)')))Solution: To fix this issue, navigate to your
pythoninstallation directory and run theInstall Certificates.commandfile located there.For example, if you are using
python3.10, the file path would be:/Applications/Python 3.10/Install Certificates.command