Breaking changes in 0.10.0: async client configuration
- Ngôn ngữ chính
- Python
- Star
- 169
- Fork
- 19
- Merge trung bình
- 1 ngày 20 giờ
- Pull request đã merge (30 ngày)
- 11
Mô tả
## 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:
```python
# Before
from aws_sdk_bedrock_runtime.config import Config
```
is now:
```python
# 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.
```python
# 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:
```python
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, `AsyncConfig`, instead of the previous `Config` type.
For example:
```python
# Before
from aws_sdk_bedrock_runtime.config import Config
def my_plugin(config: Config) -> None:
...
```
is now:
```python
# 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 `AsyncConfig`.
2. Replace direct configuration construction with `await AsyncConfig.resolve(...)`.
3. Ensure explicit configuration resolution occurs within an asynchronous context.
4. Update configuration plugins to accept the service-specific `AsyncConfig` type instead of `Config`.
For example:
```python
# 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:
```python
# 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`:
```bash
python -m pip install --upgrade aws-sdk-
```
For example:
```bash
python -m pip install --upgrade aws-sdk-bedrock-runtime
```
To explicitly require version `0.10.0` or later:
```bash
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:
```bash
python -m pip install "aws-sdk-bedrock-runtime==0.10.0"
```
To allow compatible patch releases while avoiding newer minor releases:
```bash
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.
Hướng dẫn đóng góp
Hướng nghiên cứu
Không có tệp repository hoặc test nào được nêu tên. Hãy bắt đầu bằng cách kiểm tra nơi duy trì release notes hoặc tài liệu migration cho phiên bản 0.10.0, sau đó so sánh các import AsyncConfig được ghi trong tài liệu, cách sử dụng resolve(), các kiểu plugin và các ví dụ pin phiên bản với issue; hoàn thành nghĩa là hướng dẫn về breaking changes được công bố tại vị trí tài liệu đã được thiết lập của project.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- aws, python
- Lĩnh vực
- documentation
- Loại issue
- Tài liệu
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 35/100