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-aiobotocore[machinelearning] package installed.

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

# MachineLearningClient usage example

from aiobotocore.session import get_session


session = get_session()

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

from aiobotocore.session import get_session


session = get_session()

async with session.create_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 aiobotocore.session import get_session


session = get_session()

async with session.create_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-aiobotocore-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 aiobotocore.session import get_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 = get_session()

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

from aiobotocore.session import get_session

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


session = get_session()

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

from aiobotocore.session import get_session

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


session = get_session()

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