Breaking changes in 0.10.0: async client configuration

Abierto
#84 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Documentación
Claridad
Necesita aclaración
Estado de actividad
Activo
Stack tecnológico
aws, python

Línea de trabajo

No se ha indicado ningún archivo del repositorio ni ninguna prueba. Empieza comprobando dónde se mantienen las notas de la versión o la documentación de migración para la versión 0.10.0 y, después, compara con el issue las importaciones documentadas de AsyncConfig, el uso de resolve(), los tipos de plugin y los ejemplos de fijación de versiones; la tarea estará terminada cuando la guía sobre los breaking changes se publique en la ubicación de documentación establecida del proyecto.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

announcement

Breaking changes in 0.10.0 release

Starting with version 0.10.0, the aws-sdk-* client packages include breaking changes to client configuration.

New configuration object

The synchronous Config class previously exported from each service package has been replaced with a service-specific asynchronous configuration class.

For example, for Bedrock Runtime:

# Before
from aws_sdk_bedrock_runtime.config import Config

is now:

# 0.10.0 and later
from aws_sdk_bedrock_runtime.config import AsyncBedrockRuntimeConfig
Configuration is now asynchronous

Configuration objects must now be created using the asynchronous resolve() method. Directly instantiating the configuration class is not supported and results in an error.

# Incorrect
config = AsyncBedrockRuntimeConfig(
    region="us-west-2",
)

# Raises
smithy_aws_core.config.exceptions.ConfigError: AsyncBedrockRuntimeConfig cannot be constructed directly. Use `await AsyncBedrockRuntimeConfig.resolve(...)` instead.

Instead, resolve the configuration before passing it to the client:

from aws_sdk_bedrock_runtime.config import AsyncBedrockRuntimeConfig

config = await AsyncBedrockRuntimeConfig.resolve(
    region="us-west-2",
)

This change allows the SDK to perform configuration resolution that requires I/O, such as reading shared AWS configuration and credentials files, without blocking the event loop.

Configuration values are resolved from explicit overrides passed to resolve(), environment variables, and shared AWS configuration and credentials files. If no configuration is provided when constructing a client, the SDK automatically resolves one for you.

Plugins

Configuration plugins must now receive the service-specific asynchronous configuration type, Async<ServiceId>Config, instead of the previous Config type.

For example:

# Before
from aws_sdk_bedrock_runtime.config import Config

def my_plugin(config: Config) -> None:
    ...

is now:

# 0.10.0 and later
from aws_sdk_bedrock_runtime.config import AsyncBedrockRuntimeConfig

def my_plugin(config: AsyncBedrockRuntimeConfig) -> None:
    ...
Migrating existing applications

Update configuration usage as follows:

  1. Replace imports of Config with the service-specific Async<ServiceId>Config.
  2. Replace direct configuration construction with await Async<ServiceId>Config.resolve(...).
  3. Ensure explicit configuration resolution occurs within an asynchronous context.
  4. Update configuration plugins to accept the service-specific Async<ServiceId>Config type instead of Config.

For example:

# Before
from aws_sdk_bedrock_runtime.client import AsyncBedrockRuntimeClient
from aws_sdk_bedrock_runtime.config import Config

def my_plugin(config: Config) -> None:
    ...

config = Config(
    region="us-west-2",
)

client = AsyncBedrockRuntimeClient(
    config=config,
    plugins=[my_plugin],
)

becomes:

# 0.10.0 and later
from aws_sdk_bedrock_runtime.client import AsyncBedrockRuntimeClient
from aws_sdk_bedrock_runtime.config import AsyncBedrockRuntimeConfig

def my_plugin(config: AsyncBedrockRuntimeConfig) -> None:
    ...

config = await AsyncBedrockRuntimeConfig.resolve(
    region="us-west-2",
)

client = AsyncBedrockRuntimeClient(
    config=config,
    plugins=[my_plugin],
)
Installing the latest version

Upgrade an existing client package with pip:

python -m pip install --upgrade aws-sdk-<service-id>

For example:

python -m pip install --upgrade aws-sdk-bedrock-runtime

To explicitly require version 0.10.0 or later:

python -m pip install "aws-sdk-bedrock-runtime>=0.10.0"
Pinning versions

To avoid unexpected breaking changes when installing or deploying your application, we recommend pinning aws-sdk-* client packages to a specific version or compatible version range.

To pin to an exact version:

python -m pip install "aws-sdk-bedrock-runtime==0.10.0"

To allow compatible patch releases while avoiding newer minor releases:

python -m pip install "aws-sdk-bedrock-runtime~=0.10.0"

This is important while the SDK is pre-1.0.0, when minor releases may include breaking changes.

Lenguaje dominante
Python
Estrellas
171
Forks
24
Merge medio
10 h 47 min
PR fusionados (30 d)
7

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de aws/aws-sdk-python

Todos los issues de aws/aws-sdk-python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.