mypy-boto3-sagemaker-geospatial Type Annotations

1.42.3 · active · verified Sat Apr 11

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

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a type-hinted `SageMakergeospatialcapabilities` client and use it to call `list_earth_observation_jobs`. The `TYPE_CHECKING` block ensures that the type imports are only used by type checkers, avoiding runtime dependencies. It uses environment variables for the AWS region.

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}")

view raw JSON →