mypy-boto3-sagemaker-geospatial Type Annotations
This library provides type annotations for the `boto3` client for AWS SageMaker Geospatial capabilities, compatible with `mypy`, VSCode, PyCharm, and other static analysis tools. It is automatically generated by `mypy-boto3-builder` and updated frequently to align with new `boto3` and AWS API releases, ensuring comprehensive type checking for your AWS interactions.
Warnings
- breaking Python 3.8 is no longer supported by the `mypy-boto3-builder` and its generated packages, including `mypy-boto3-sagemaker-geospatial`. Users must upgrade to Python 3.9 or newer.
- breaking The `mypy-boto3-builder` has migrated to PEP 561 compliant packages. This might require updates to how stub packages are managed or imported in some build systems.
- gotcha This package provides only type annotations; the `boto3` library itself must be installed in your environment for the code to run.
- breaking TypeDef naming conventions were changed in builder version 8.9.0. For example, `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`. This could break existing type annotations that use the older, longer names.
- gotcha When using PyCharm, performance issues may occur with `Literal` overloads, leading to high CPU usage. In such cases, `mypy-boto3-lite` packages are recommended as an alternative.
Install
-
pip install mypy-boto3-sagemaker-geospatial boto3 -
pip install mypy-boto3-sagemaker-geospatial
Imports
- SagemakerGeospatialClient
from mypy_boto3_sagemaker_geospatial.client import SagemakerGeospatialClient
- ListEarthObservationJobsOutputTypeDef
from mypy_boto3_sagemaker_geospatial.type_defs import ListEarthObservationJobsOutputTypeDef
Quickstart
import boto3
import os
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from mypy_boto3_sagemaker_geospatial.client import SagemakerGeospatialClient
from mypy_boto3_sagemaker_geospatial.type_defs import ListEarthObservationJobsOutputTypeDef
def get_sagemaker_geospatial_client() -> 'SagemakerGeospatialClient':
"""Returns a type-hinted SageMaker Geospatial client."""
client: SagemakerGeospatialClient = boto3.client(
"sagemaker-geospatial",
region_name=os.environ.get("AWS_REGION", "us-west-2")
)
return client
def list_geospatial_jobs():
"""Lists SageMaker Earth Observation Jobs with type hints."""
client = get_sagemaker_geospatial_client()
response: ListEarthObservationJobsOutputTypeDef = client.list_earth_observation_jobs(
MaxResults=5
)
print("Successfully listed Earth Observation Jobs.")
for job in response.get('EarthObservationJobSummaries', []):
print(f" - Job ID: {job['Arn']}, Status: {job['Status']}")
if __name__ == '__main__':
# This assumes AWS credentials and default region are configured (e.g., via ~/.aws/credentials or environment variables)
# For local testing without actual AWS calls, you might mock boto3.client.
try:
list_geospatial_jobs()
except Exception as e:
print(f"An error occurred: {e}")