Getting Started
Installation
pip install capo-sagemaker-runtime-http2
Usage
from capo_sagemaker_runtime_http2 import AsyncSageMakerRuntimeHTTP2Client
async def main():
async with AsyncSageMakerRuntimeHTTP2Client() as sage_maker_runtime_http2:
# Example: call the invoke_endpoint_with_bidirectional_stream operation
response = await sage_maker_runtime_http2.invoke_endpoint_with_bidirectional_stream()
print(response["body"])
Streaming Request
Some operations accept a streaming request body. Pass an async iterator of bytes chunks, or the whole body as bytes, for the streaming parameter.
from capo_sagemaker_runtime_http2 import AsyncSageMakerRuntimeHTTP2Client
async def main():
async with AsyncSageMakerRuntimeHTTP2Client() as sage_maker_runtime_http2:
# Example: call invoke_endpoint_with_bidirectional_stream with a streaming request body
async def chunks():
yield b'Hello, World!'
response = await sage_maker_runtime_http2.invoke_endpoint_with_bidirectional_stream(body=chunks())
print(response)
# Or pass the whole body as bytes
response = await sage_maker_runtime_http2.invoke_endpoint_with_bidirectional_stream(body=b'Hello, World!')
print(response)
Error Handling
The SDK raises exceptions for errors returned by the API. Catch them to handle failures gracefully.
from capo_sagemaker_runtime_http2 import AsyncSageMakerRuntimeHTTP2Client
from capo_sagemaker_runtime_http2.error import InputValidationError
async def main():
async with AsyncSageMakerRuntimeHTTP2Client() as sage_maker_runtime_http2:
try:
await sage_maker_runtime_http2.invoke_endpoint_with_bidirectional_stream()
except InputValidationError as e:
print(f"Error: {e}")
print(e.data) # additional error data
Retrying
The SDK retries failed operations automatically. Retry behaviour follows the Smithy specification: errors are retried based on their is_retryable and is_throttling_error attributes. Throttling errors use a longer base delay. Network-level failures (connection errors and timeouts) are also retried. Non-retryable errors, such as client errors without the @retryable trait, are raised immediately without further attempts.
The number of attempts defaults to 3 and can be changed at the client level via retry_max_attempts, or per call via config_overrides.
from capo_sagemaker_runtime_http2 import AsyncSageMakerRuntimeHTTP2Client
async def main():
async with AsyncSageMakerRuntimeHTTP2Client() as sage_maker_runtime_http2:
# Default: 3 attempts for every operation
response = await sage_maker_runtime_http2.invoke_endpoint_with_bidirectional_stream()
# Override per operation
response = await sage_maker_runtime_http2.invoke_endpoint_with_bidirectional_stream(config_overrides={"retry_max_attempts": 5})
# Disable retries for this call
response = await sage_maker_runtime_http2.invoke_endpoint_with_bidirectional_stream(config_overrides={"retry_max_attempts": 1})
Metadata
Release files for capo-sagemaker-runtime-http2 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| capo_sagemaker_runtime_http2-0.1.0.tar.gz | 48.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| capo_sagemaker_runtime_http2-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 109.3 kB
Release files / capo_sagemaker_runtime_http2-0.1.0.tar.gz
| Download URL | capo_sagemaker_runtime_http2-0.1.0.tar.gz |
|---|---|
| Size | 48.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
342f12acc23a65e7c0cd2e0ca020834d74c41464f8dc1c6c392cb6bd0804c677
|
|
BLAKE2b-256 checksum How to use checksums |
0ff1c1a4ce2240b0c0922e62f7324b195d0a14b3afde3a77d982f4b64b6eec69
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.20 {"installer":{"name":"uv","version":"0.12.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / capo_sagemaker_runtime_http2-0.1.0-py3-none-any.whl
| Download URL | capo_sagemaker_runtime_http2-0.1.0-py3-none-any.whl |
|---|---|
| Size | 61.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4f8e0acd8ee1e1fda27d86418ad3a7ae6d01992356d316ce4e8f916e59e59582
|
|
BLAKE2b-256 checksum How to use checksums |
97064a18980179e15c14ac714c924df13e5eaa04896d63b34265015fd7c40fcc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.20 {"installer":{"name":"uv","version":"0.12.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|