mypy-boto3-sagemaker-a2i-runtime type annotations
This library provides type annotations (stubs) for the `boto3` client and resources related to the AWS SageMaker Augmented AI Runtime (A2I) service. It allows static type checkers like MyPy to validate code using `boto3` for this specific AWS service, catching potential errors before runtime. The current version is `1.42.3`, and releases are frequent, typically in sync with `boto3` updates and `mypy-boto3-builder` improvements.
Warnings
- breaking Python 3.8 support was removed starting from `mypy-boto3-builder` version 8.12.0. This means `mypy-boto3-sagemaker-a2i-runtime` versions built with 8.12.0 or newer (like 1.42.3) require Python 3.9 or higher.
- gotcha This package (`mypy-boto3-sagemaker-a2i-runtime`) provides *only* type stubs. You must install `boto3` separately for your code to run successfully at runtime. The stubs have no runtime effect on `boto3` itself.
- gotcha For optimal type-checking accuracy, ensure the `mypy-boto3-sagemaker-a2i-runtime` version matches your `boto3` library version as closely as possible. Significant version mismatches can lead to incorrect type hints or unresolved names.
Install
-
pip install mypy-boto3-sagemaker-a2i-runtime boto3
Imports
- AugmentedAIRuntimeClient
from mypy_boto3_sagemaker_a2i_runtime.client import AugmentedAIRuntimeClient
- HumanLoopSummaryTypeDef
from mypy_boto3_sagemaker_a2i_runtime.type_defs import HumanLoopSummaryTypeDef
Quickstart
import boto3
from mypy_boto3_sagemaker_a2i_runtime.client import AugmentedAIRuntimeClient
from mypy_boto3_sagemaker_a2i_runtime.type_defs import HumanLoopSummaryTypeDef
import os
def get_a2i_client() -> AugmentedAIRuntimeClient:
"""Initializes and returns a typed Sagemaker A2I Runtime client."""
# Ensure AWS credentials are configured (e.g., via environment variables, ~/.aws/credentials)
# For local development, you might use 'aws configure'
# For production, consider IAM roles.
client: AugmentedAIRuntimeClient = boto3.client(
"sagemaker-a2i-runtime",
region_name=os.environ.get("AWS_REGION", "us-east-1")
)
return client
def list_a2i_flow_definitions():
"""Lists A2I flow definitions using the typed client."""
client = get_a2i_client()
try:
# MyPy will now correctly type-check the client's methods and response structure
response = client.list_flow_definitions(MaxResults=10)
flow_definitions: list[HumanLoopSummaryTypeDef] = response["HumanLoopSummaries"]
print(f"Found {len(flow_definitions)} A2I Flow Definitions:")
for fd in flow_definitions:
print(f"- Name: {fd['FlowDefinitionName']}, Status: {fd['FlowDefinitionStatus']}")
except Exception as e:
print(f"An error occurred: {e}")
if __name__ == "__main__":
list_a2i_flow_definitions()