Skip to content

Examples#

Index > MachineLearning > Examples

Auto-generated documentation for MachineLearning type annotations stubs module types-aiobotocore-machinelearning.

Client#

Implicit type annotations#

Can be used with types-aioboto3[machinelearning] package installed.

Write your MachineLearning code as usual, type checking and code completion should work out of the box.

# MachineLearningClient usage example

from aioboto3.session import Session


session = Session()

async with session.client("machinelearning") as client:  # (1)
    result = await client.add_tags()  # (2)
  1. client: MachineLearningClient
  2. result: AddTagsOutputTypeDef
# DescribeBatchPredictionsPaginator usage example

from aioboto3.session import Session


session = Session()

async with session.client("machinelearning") as client:  # (1)
    paginator = client.get_paginator("describe_batch_predictions")  # (2)
    async for item in paginator.paginate(...):
        print(item)  # (3)
  1. client: MachineLearningClient
  2. paginator: DescribeBatchPredictionsPaginator
  3. item: DescribeBatchPredictionsOutputTypeDef
# BatchPredictionAvailableWaiter usage example

from aioboto3.session import Session


session = Session()

async with session.client("machinelearning") as client:  # (1)
    waiter = client.get_waiter("batch_prediction_available")  # (2)
    await waiter.wait()
  1. client: MachineLearningClient
  2. waiter: BatchPredictionAvailableWaiter

Explicit type annotations#

With types-aioboto3-lite[machinelearning] or a standalone types_aiobotocore_machinelearning package, you have to explicitly specify client: MachineLearningClient type annotation.

All other type annotations are optional, as types should be discovered automatically. However, these type annotations can be helpful in your functions and methods.

# MachineLearningClient usage example with type annotations

from aioboto3.session import Session

from types_aiobotocore_machinelearning.client import MachineLearningClient
from types_aiobotocore_machinelearning.type_defs import AddTagsOutputTypeDef
from types_aiobotocore_machinelearning.type_defs import AddTagsInputRequestTypeDef


session = Session()

client: MachineLearningClient
async with session.client("machinelearning") as client:  # (1)
    kwargs: AddTagsInputRequestTypeDef = {...}  # (2)
    result: AddTagsOutputTypeDef = await client.add_tags(**kwargs)  # (3)
  1. client: MachineLearningClient
  2. kwargs: AddTagsInputRequestTypeDef
  3. result: AddTagsOutputTypeDef
# DescribeBatchPredictionsPaginator usage example with type annotations

from aioboto3.session import Session

from types_aiobotocore_machinelearning.client import MachineLearningClient
from types_aiobotocore_machinelearning.paginator import DescribeBatchPredictionsPaginator
from types_aiobotocore_machinelearning.type_defs import DescribeBatchPredictionsOutputTypeDef


session = Session()

client: MachineLearningClient
async with session.client("machinelearning") as client:  # (1)
    paginator: DescribeBatchPredictionsPaginator = client.get_paginator("describe_batch_predictions")  # (2)
    async for item in paginator.paginate(...):
        item: DescribeBatchPredictionsOutputTypeDef
        print(item)  # (3)
  1. client: MachineLearningClient
  2. paginator: DescribeBatchPredictionsPaginator
  3. item: DescribeBatchPredictionsOutputTypeDef
# BatchPredictionAvailableWaiter usage example with type annotations

from aioboto3.session import Session

from types_aiobotocore_machinelearning.client import MachineLearningClient
from types_aiobotocore_machinelearning.waiter import BatchPredictionAvailableWaiter


session = Session()

async with session.client("machinelearning") as client:  # (1)
    waiter = client.get_waiter("batch_prediction_available")  # (2)
    await waiter.wait()
  1. client: MachineLearningClient
  2. waiter: BatchPredictionAvailableWaiter