aws_sdk_sagemaker_runtime_http2 0.9.0__tar.gz → 0.11.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. aws_sdk_sagemaker_runtime_http2-0.11.0/.changes/0.10.0.json +8 -0
  2. aws_sdk_sagemaker_runtime_http2-0.11.0/.changes/0.11.0.json +16 -0
  3. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/CHANGELOG.md +14 -0
  4. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/PKG-INFO +5 -3
  5. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/pyproject.toml +8 -3
  6. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/scripts/docs/generate_doc_stubs.py +85 -13
  7. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/src/aws_sdk_sagemaker_runtime_http2/__init__.py +1 -1
  8. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/src/aws_sdk_sagemaker_runtime_http2/client.py +101 -38
  9. aws_sdk_sagemaker_runtime_http2-0.11.0/src/aws_sdk_sagemaker_runtime_http2/config.py +175 -0
  10. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/src/aws_sdk_sagemaker_runtime_http2/user_agent.py +2 -2
  11. aws_sdk_sagemaker_runtime_http2-0.9.0/src/aws_sdk_sagemaker_runtime_http2/config.py +0 -180
  12. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/.changes/0.1.0.json +0 -0
  13. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/.changes/0.3.0.json +0 -0
  14. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/.changes/0.4.0.json +0 -0
  15. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/.changes/0.5.0.json +0 -0
  16. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/.changes/0.6.0.json +0 -0
  17. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/.changes/0.7.0.json +0 -0
  18. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/.changes/0.8.0.json +0 -0
  19. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/.changes/0.9.0.json +0 -0
  20. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/.gitignore +0 -0
  21. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/LICENSE +0 -0
  22. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/Makefile +0 -0
  23. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/NOTICE +0 -0
  24. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/README.md +0 -0
  25. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/docs/README.md +0 -0
  26. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/docs/index.md +0 -0
  27. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/docs/stylesheets/extra.css +0 -0
  28. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/src/aws_sdk_sagemaker_runtime_http2/_private/__init__.py +0 -0
  29. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/src/aws_sdk_sagemaker_runtime_http2/_private/schemas.py +0 -0
  30. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/src/aws_sdk_sagemaker_runtime_http2/auth.py +0 -0
  31. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/src/aws_sdk_sagemaker_runtime_http2/models.py +0 -0
  32. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/tests/__init__.py +0 -0
  33. /aws_sdk_sagemaker_runtime_http2-0.9.0/tests/test_protocol.py → /aws_sdk_sagemaker_runtime_http2-0.11.0/tests/test_restjson_protocol.py +0 -0
  34. {aws_sdk_sagemaker_runtime_http2-0.9.0 → aws_sdk_sagemaker_runtime_http2-0.11.0}/zensical.toml +0 -0
@@ -0,0 +1,8 @@
1
+ {
2
+ "changes": [
3
+ {
4
+ "type": "dependency",
5
+ "description": "Bump `smithy-aws-core` from `~=0.9.0` to `~=0.10.0`."
6
+ }
7
+ ]
8
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "changes": [
3
+ {
4
+ "type": "enhancement",
5
+ "description": "Re-generated with smithy-python 0.5.0"
6
+ },
7
+ {
8
+ "type": "dependency",
9
+ "description": "Bump `smithy-aws-core` from `~=0.10.0` to `~=0.11.0`."
10
+ },
11
+ {
12
+ "type": "dependency",
13
+ "description": "Bump `smithy-http` from `~=0.4.0` to `~=0.5.0`."
14
+ }
15
+ ]
16
+ }
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.11.0
4
+
5
+ ### Enhancements
6
+ * Re-generated with smithy-python 0.5.0
7
+
8
+ ### Dependencies
9
+ * Bump `smithy-aws-core` from `~=0.10.0` to `~=0.11.0`.
10
+ * Bump `smithy-http` from `~=0.4.0` to `~=0.5.0`.
11
+
12
+ ## v0.10.0
13
+
14
+ ### Dependencies
15
+ * Bump `smithy-aws-core` from `~=0.9.0` to `~=0.10.0`.
16
+
3
17
  ## v0.9.0
4
18
 
5
19
  ### Dependencies
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: aws_sdk_sagemaker_runtime_http2
3
- Version: 0.9.0
3
+ Version: 0.11.0
4
4
  Summary: aws_sdk_sagemaker_runtime_http2 client
5
5
  License: Apache-2.0
6
6
  License-File: LICENSE
@@ -18,9 +18,11 @@ Classifier: Programming Language :: Python :: 3.12
18
18
  Classifier: Programming Language :: Python :: 3.13
19
19
  Classifier: Programming Language :: Python :: 3.14
20
20
  Requires-Python: >=3.12
21
- Requires-Dist: smithy-aws-core[eventstream,json]~=0.9.0
21
+ Requires-Dist: smithy-aws-core[eventstream,json]~=0.11.0
22
22
  Requires-Dist: smithy-core~=0.8.0
23
- Requires-Dist: smithy-http[awscrt]~=0.4.0
23
+ Requires-Dist: smithy-http[aiohttp]~=0.5.0
24
+ Provides-Extra: awscrt
25
+ Requires-Dist: smithy-http[awscrt]~=0.5.0; extra == 'awscrt'
24
26
  Description-Content-Type: text/markdown
25
27
 
26
28
  ## Amazon SageMaker Runtime HTTP2 Client
@@ -2,7 +2,7 @@
2
2
 
3
3
  [project]
4
4
  name = "aws_sdk_sagemaker_runtime_http2"
5
- version = "0.9.0"
5
+ version = "0.11.0"
6
6
  description = "aws_sdk_sagemaker_runtime_http2 client"
7
7
  readme = "README.md"
8
8
  requires-python = ">=3.12"
@@ -23,9 +23,14 @@ classifiers = [
23
23
  ]
24
24
 
25
25
  dependencies = [
26
- "smithy_aws_core[eventstream, json]~=0.9.0",
26
+ "smithy_aws_core[eventstream, json]~=0.11.0",
27
27
  "smithy_core~=0.8.0",
28
- "smithy_http[awscrt]~=0.4.0"
28
+ "smithy_http[aiohttp]~=0.5.0"
29
+ ]
30
+
31
+ [project.optional-dependencies]
32
+ awscrt = [
33
+ "smithy_http[awscrt]~=0.5.0"
29
34
  ]
30
35
 
31
36
  [dependency-groups]
@@ -8,6 +8,7 @@ for the client, operations, models (structures, unions, enums), and errors.
8
8
 
9
9
  import argparse
10
10
  import logging
11
+ import re
11
12
  import sys
12
13
  from collections.abc import Sequence
13
14
  from dataclasses import dataclass
@@ -39,6 +40,7 @@ logger = logging.getLogger("generate_doc_stubs")
39
40
 
40
41
  ENUM_BASE_CLASSES = ("StrEnum", "IntEnum")
41
42
  ERROR_BASE_CLASSES = ("ServiceError", "ModeledError")
43
+ CLIENT_METHOD_NAMES = ("close",)
42
44
 
43
45
 
44
46
  class StreamType(Enum):
@@ -89,6 +91,14 @@ class OperationInfo:
89
91
  event_output_type: str | None # For output/duplex streams
90
92
 
91
93
 
94
+ @dataclass
95
+ class ClientMethodInfo:
96
+ """Information about a non-operation client method."""
97
+
98
+ name: str
99
+ module_path: str
100
+
101
+
92
102
  @dataclass
93
103
  class ModelsInfo:
94
104
  """Information about all modeled types."""
@@ -108,6 +118,7 @@ class ClientInfo:
108
118
  package_name: str # e.g., "aws_sdk_bedrock_runtime"
109
119
  config: TypeInfo
110
120
  plugin: TypeInfo
121
+ client_methods: list[ClientMethodInfo]
111
122
  operations: list[OperationInfo]
112
123
  models: ModelsInfo
113
124
 
@@ -115,19 +126,43 @@ class ClientInfo:
115
126
  class DocStubGenerator:
116
127
  """Generate markdown API Reference stubs for AWS SDK for Python clients."""
117
128
 
118
- def __init__(self, client_dir: Path, output_dir: Path) -> None:
129
+ def __init__(self, client_dir: Path, output_dir: Path, service_name: str | None = None) -> None:
119
130
  """
120
131
  Initialize the documentation generator.
121
132
 
122
133
  Args:
123
134
  client_dir: Path to the client source directory
124
135
  output_dir: Path to the output directory for generated doc stubs
136
+ service_name: Display name for the service (e.g. the Smithy sdkId
137
+ "SNS"). When omitted, falls back to a title-cased derivation of
138
+ the package name, which does not preserve acronym casing.
125
139
  """
126
140
  self.client_dir = client_dir
127
141
  self.output_dir = output_dir
128
- # Extract service name from package name
129
- # (e.g., "aws_sdk_bedrock_runtime" -> "Bedrock Runtime")
130
- self.service_name = client_dir.name.replace("aws_sdk_", "").replace("_", " ").title()
142
+ # Use the explicit override, then the sdkId from the package, then
143
+ # fall back to a title-cased package name (does not keep acronym
144
+ # casing, so "sns" becomes "Sns").
145
+ self.service_name = (
146
+ service_name
147
+ or self._sdk_id_from_package(client_dir)
148
+ or client_dir.name.replace("aws_sdk_", "").replace("_", " ").title()
149
+ )
150
+
151
+ @staticmethod
152
+ def _sdk_id_from_package(client_dir: Path) -> str | None:
153
+ """
154
+ Read the authoritative service name (Smithy sdkId) from the package.
155
+
156
+ The generated ``_private/schemas.py`` carries the ``aws.api#service``
157
+ trait's ``sdkId`` (e.g. "SNS"), the same field the sidebar navigation
158
+ uses, so it keeps acronym casing that the package name does not.
159
+ Returns None if the file or value is absent.
160
+ """
161
+ schemas = client_dir / "_private" / "schemas.py"
162
+ if not schemas.is_file():
163
+ return None
164
+ match = re.search(r'"sdkId":\s*"([^"]+)"', schemas.read_text())
165
+ return match.group(1) if match else None
131
166
 
132
167
  def generate(self) -> bool:
133
168
  """
@@ -166,19 +201,24 @@ class DocStubGenerator:
166
201
  if not client_class:
167
202
  raise ValueError(f"No class ending with 'Client' found in {package_name}.client")
168
203
 
169
- config_class = config_module.members.get("Config")
204
+ config_class = self._find_class_with_suffix(config_module, "Config")
205
+ if not config_class:
206
+ raise ValueError(f"No class ending with 'Config' found in {package_name}.config")
207
+
170
208
  plugin_alias = config_module.members.get("Plugin")
171
- if not config_class or not plugin_alias:
172
- raise ValueError(f"Missing Config or Plugin in {package_name}.config")
209
+ if not plugin_alias:
210
+ raise ValueError(f"Missing Plugin in {package_name}.config")
173
211
 
174
212
  config = TypeInfo(name=config_class.name, module_path=config_class.path)
175
213
  plugin = TypeInfo(name=plugin_alias.name, module_path=plugin_alias.path)
176
214
 
215
+ client_methods = self._extract_client_methods(client_class)
177
216
  operations = self._extract_operations(client_class)
178
217
  models = self._extract_models(models_module, operations)
179
218
 
180
219
  logger.info(
181
- f"Analyzed {client_class.name}: {len(operations)} operations, "
220
+ f"Analyzed {client_class.name}: {len(client_methods)} client methods, "
221
+ f"{len(operations)} operations, "
182
222
  f"{len(models.structures)} structures, {len(models.errors)} errors, "
183
223
  f"{len(models.unions)} unions, {len(models.enums)} enums"
184
224
  )
@@ -189,13 +229,18 @@ class DocStubGenerator:
189
229
  package_name=package_name,
190
230
  config=config,
191
231
  plugin=plugin,
232
+ client_methods=client_methods,
192
233
  operations=operations,
193
234
  models=models,
194
235
  )
195
236
 
196
237
  def _find_class_with_suffix(self, module: Module, suffix: str) -> Class | None:
197
- """Find the class in the module with a matching suffix."""
238
+ """Find the class defined in the module with a matching suffix."""
198
239
  for cls in module.classes.values():
240
+ # Skip imported classes so a same-package import (e.g. a *Config
241
+ # class re-exported from config.py) can't shadow the defined one.
242
+ if cls.is_imported:
243
+ continue
199
244
  if cls.name.endswith(suffix):
200
245
  return cls
201
246
  return None
@@ -204,11 +249,24 @@ class DocStubGenerator:
204
249
  """Extract operation information from client class."""
205
250
  operations = []
206
251
  for op in client_class.functions.values():
207
- if op.is_private or op.is_init_method:
252
+ if (
253
+ op.is_private
254
+ or op.is_init_method
255
+ or op.is_special
256
+ or op.name in CLIENT_METHOD_NAMES
257
+ ):
208
258
  continue
209
259
  operations.append(self._analyze_operation(op))
210
260
  return operations
211
261
 
262
+ def _extract_client_methods(self, client_class: Class) -> list[ClientMethodInfo]:
263
+ """Extract public client methods that are not service operations."""
264
+ return [
265
+ ClientMethodInfo(name=method.name, module_path=method.path)
266
+ for method in client_class.functions.values()
267
+ if not method.is_private and method.name in CLIENT_METHOD_NAMES
268
+ ]
269
+
212
270
  def _analyze_operation(self, operation: Function) -> OperationInfo:
213
271
  """Analyze an operation method to extract information."""
214
272
  stream_type = None
@@ -239,7 +297,8 @@ class DocStubGenerator:
239
297
  event_output_type = stream_args[idx].canonical_name
240
298
 
241
299
  output_info = TypeInfo(
242
- name=stream_args[-1].canonical_name, module_path=stream_args[-1].canonical_path
300
+ name=stream_args[-1].canonical_name,
301
+ module_path=stream_args[-1].canonical_path,
243
302
  )
244
303
  else:
245
304
  output_info = TypeInfo(name=output_type, module_path=returns.canonical_path)
@@ -402,6 +461,9 @@ class DocStubGenerator:
402
461
  "",
403
462
  ]
404
463
 
464
+ for method in sorted(client_info.client_methods, key=lambda x: x.name):
465
+ lines.extend([*self._mkdocs_directive(method.module_path, heading_level=4), ""])
466
+
405
467
  # Operations section
406
468
  if client_info.operations:
407
469
  lines.append("## Operations")
@@ -607,7 +669,11 @@ def main() -> int:
607
669
  description="Generate API documentation stubs for AWS SDK Python client."
608
670
  )
609
671
  parser.add_argument(
610
- "-c", "--client-dir", type=Path, required=True, help="Path to the client source package"
672
+ "-c",
673
+ "--client-dir",
674
+ type=Path,
675
+ required=True,
676
+ help="Path to the client source package",
611
677
  )
612
678
  parser.add_argument(
613
679
  "-o",
@@ -616,6 +682,12 @@ def main() -> int:
616
682
  required=True,
617
683
  help="Output directory for generated doc stubs",
618
684
  )
685
+ parser.add_argument(
686
+ "-s",
687
+ "--service-name",
688
+ default=None,
689
+ help="Display name for the service (Smithy sdkId, e.g. 'SNS')",
690
+ )
619
691
 
620
692
  args = parser.parse_args()
621
693
  client_dir = args.client_dir.resolve()
@@ -626,7 +698,7 @@ def main() -> int:
626
698
  return 1
627
699
 
628
700
  try:
629
- generator = DocStubGenerator(client_dir, output_dir)
701
+ generator = DocStubGenerator(client_dir, output_dir, args.service_name)
630
702
  success = generator.generate()
631
703
  return 0 if success else 1
632
704
  except Exception as e:
@@ -1,3 +1,3 @@
1
1
  # Code generated by smithy-python-codegen DO NOT EDIT.
2
2
 
3
- __version__: str = "0.9.0"
3
+ __version__: str = "0.11.0"
@@ -1,19 +1,24 @@
1
1
  # Code generated by smithy-python-codegen DO NOT EDIT.
2
2
 
3
+ import asyncio
3
4
  from copy import deepcopy
4
5
  import logging
5
- from typing import Any, TYPE_CHECKING
6
- import warnings
6
+ from typing import Any, Self, cast
7
7
 
8
+ from smithy_aws_core.config import ConfigSource
9
+ from smithy_aws_core.identity import AWSCredentialsIdentity
10
+ from smithy_aws_core.identity.chain import IdentityChain
8
11
  from smithy_core.aio.client import ClientCall, RequestPipeline
9
12
  from smithy_core.aio.eventstream import DuplexEventStream
10
13
  from smithy_core.aio.retries import RetryStrategyResolver
14
+ from smithy_core.aio.utils import close
11
15
  from smithy_core.exceptions import ExpectationNotMetError
12
16
  from smithy_core.interceptors import InterceptorChain
13
17
  from smithy_core.types import TypedProperties
18
+ from smithy_http.aio.interfaces import HTTPClient
14
19
  from smithy_http.plugins import user_agent_plugin
15
20
 
16
- from .config import Config, Plugin
21
+ from .config import AsyncSageMakerRuntimeHTTP2Config, Plugin
17
22
  from .models import (
18
23
  INVOKE_ENDPOINT_WITH_BIDIRECTIONAL_STREAM,
19
24
  InvokeEndpointWithBidirectionalStreamInput,
@@ -32,7 +37,9 @@ class AsyncSageMakerRuntimeHTTP2Client:
32
37
  """The Amazon SageMaker AI runtime HTTP/2 API."""
33
38
 
34
39
  def __init__(
35
- self, config: Config | None = None, plugins: list[Plugin] | None = None
40
+ self,
41
+ config: AsyncSageMakerRuntimeHTTP2Config | None = None,
42
+ plugins: list[Plugin] | None = None,
36
43
  ):
37
44
  """
38
45
  Constructor for `AsyncSageMakerRuntimeHTTP2Client`.
@@ -42,19 +49,72 @@ class AsyncSageMakerRuntimeHTTP2Client:
42
49
  Optional configuration for the client. Here you can set things like
43
50
  the endpoint for HTTP services or auth credentials.
44
51
  plugins:
45
- A list of callables that modify the configuration dynamically. These
46
- can be used to set defaults, for example.
52
+ A list of callables applied once to the client's base configuration.
53
+ Their changes are inherited by every operation invocation.
47
54
  """
48
- self._config = config or Config()
49
-
50
- client_plugins: list[Plugin] = [aws_user_agent_plugin, user_agent_plugin]
51
- if plugins:
52
- client_plugins.extend(plugins)
53
-
54
- for plugin in client_plugins:
55
- plugin(self._config)
56
-
55
+ self._config = config
56
+ self._plugins = plugins
57
+ self._derive_lock = asyncio.Lock()
58
+ self._setup_done = False
59
+ self._closed = False
57
60
  self._retry_strategy_resolver = RetryStrategyResolver()
61
+ self._client_plugins: list[Plugin] = [aws_user_agent_plugin, user_agent_plugin]
62
+
63
+ async def _ensure_setup(self) -> None:
64
+ if not self._setup_done:
65
+ async with self._derive_lock:
66
+ if not self._setup_done:
67
+ if self._config is None:
68
+ config = await AsyncSageMakerRuntimeHTTP2Config.resolve()
69
+ else:
70
+ # Copy so plugins don't mutate the caller's config.
71
+ config = deepcopy(self._config)
72
+ for plugin in self._client_plugins:
73
+ plugin(config)
74
+ if self._plugins:
75
+ for plugin in self._plugins:
76
+ plugin(config)
77
+ self._config = config
78
+
79
+ if self._config.aws_credentials_identity_resolver is None:
80
+ config_context = self._config.resolution_context()
81
+ config_file = None
82
+ profile_name = None
83
+ if config_context is not None:
84
+ config_file = await config_context.parsed_profiles()
85
+ if config_context.profile_source is ConfigSource.OVERRIDE:
86
+ profile_name = config_context.profile_name
87
+ self._config.aws_credentials_identity_resolver = (
88
+ await IdentityChain.create(
89
+ AWSCredentialsIdentity,
90
+ config_file=config_file,
91
+ profile_name=profile_name,
92
+ region_override=self._config.region,
93
+ http_client=cast(
94
+ HTTPClient | None, self._config.transport
95
+ ),
96
+ )
97
+ )
98
+ self._setup_done = True
99
+
100
+ async def close(self) -> None:
101
+ """Close this client and any resources held by its transport."""
102
+ if self._closed:
103
+ return
104
+ async with self._derive_lock:
105
+ if self._closed:
106
+ return
107
+ self._closed = True
108
+ if self._setup_done and self._config is not None:
109
+ await close(self._config.transport)
110
+
111
+ async def __aenter__(self) -> Self:
112
+ if self._closed:
113
+ raise RuntimeError("Cannot enter a client that has been closed.")
114
+ return self
115
+
116
+ async def __aexit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None:
117
+ await self.close()
58
118
 
59
119
  async def invoke_endpoint_with_bidirectional_stream(
60
120
  self,
@@ -114,19 +174,39 @@ class AsyncSageMakerRuntimeHTTP2Client:
114
174
  Returns:
115
175
  A `DuplexEventStream` for bidirectional streaming.
116
176
  """
177
+ if self._closed:
178
+ raise RuntimeError(
179
+ "Cannot invoke an operation on a client that has been closed."
180
+ )
181
+
117
182
  operation_plugins: list[Plugin] = []
118
183
  if plugins:
119
184
  operation_plugins.extend(plugins)
120
- config = deepcopy(self._config)
121
- for plugin in operation_plugins:
122
- plugin(config)
123
- if config.protocol is None or config.transport is None:
185
+ await self._ensure_setup()
186
+ assert self._config is not None
187
+ if operation_plugins:
188
+ # Keep operation-plugin mutations scoped to this call.
189
+ config = deepcopy(self._config)
190
+ for plugin in operation_plugins:
191
+ plugin(config)
192
+ else:
193
+ config = self._config
194
+ if (
195
+ config.protocol is None
196
+ or config.transport is None
197
+ or config.endpoint_resolver is None
198
+ or config.auth_scheme_resolver is None
199
+ or config.auth_schemes is None
200
+ ):
124
201
  raise ExpectationNotMetError(
125
- "protocol and transport MUST be set on the config to make calls."
202
+ "protocol, transport, endpoint_resolver, auth_scheme_resolver,"
203
+ " and auth_schemes MUST be set on the config to make calls."
126
204
  )
127
205
 
128
206
  retry_strategy = await self._retry_strategy_resolver.resolve_retry_strategy(
129
- retry_strategy=config.retry_strategy
207
+ retry_strategy=config.retry_strategy,
208
+ retry_mode=config.retry_mode,
209
+ max_attempts=config.max_attempts,
130
210
  )
131
211
 
132
212
  pipeline = RequestPipeline(protocol=config.protocol, transport=config.transport)
@@ -147,20 +227,3 @@ class AsyncSageMakerRuntimeHTTP2Client:
147
227
  ResponseStreamEvent,
148
228
  _ResponseStreamEventDeserializer().deserialize,
149
229
  )
150
-
151
-
152
- if TYPE_CHECKING:
153
- # Deprecated alias for backwards compatibility, to be removed.
154
- SageMakerRuntimeHTTP2Client = AsyncSageMakerRuntimeHTTP2Client
155
-
156
-
157
- def __getattr__(name: str) -> Any:
158
- if name == "SageMakerRuntimeHTTP2Client":
159
- warnings.warn(
160
- "SageMakerRuntimeHTTP2Client is deprecated, use AsyncSageMakerRuntimeHTTP2Client instead. "
161
- "This alias will be removed in a future version.",
162
- DeprecationWarning,
163
- stacklevel=2,
164
- )
165
- return AsyncSageMakerRuntimeHTTP2Client
166
- raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
@@ -0,0 +1,175 @@
1
+ # Code generated by smithy-python-codegen DO NOT EDIT.
2
+
3
+ from dataclasses import dataclass, field
4
+ from typing import Any, Callable, ClassVar, Self, TypeAlias, Union, Unpack
5
+
6
+ from smithy_aws_core.aio.protocols import RestJsonClientProtocol
7
+ from smithy_aws_core.auth import SigV4AuthScheme
8
+ from smithy_aws_core.config import AwsConfigOverrides, FileSystem
9
+ from smithy_aws_core.config.aws_config import AsyncAwsConfig
10
+ from smithy_aws_core.config.resolvers import EndpointUriResolver
11
+ from smithy_aws_core.config.types import FieldSpec
12
+ from smithy_aws_core.endpoints.standard_regional import (
13
+ StandardRegionalEndpointsResolver,
14
+ )
15
+ from smithy_aws_core.identity import AWSCredentialsIdentity, AWSIdentityProperties
16
+ from smithy_core.aio.interfaces import ClientProtocol, EndpointResolver
17
+ from smithy_core.aio.interfaces.auth import AuthScheme
18
+ from smithy_core.aio.interfaces.identity import IdentityResolver
19
+ from smithy_core.interceptors import Interceptor
20
+ from smithy_core.shapes import ShapeID
21
+ from smithy_http.aio.aiohttp import AIOHTTPClient
22
+
23
+ from ._private.schemas import (
24
+ AMAZON_SAGE_MAKER_RUNTIME_HTTP2 as _SCHEMA_AMAZON_SAGE_MAKER_RUNTIME_HTTP2,
25
+ )
26
+ from .auth import HTTPAuthSchemeResolver
27
+ from .models import (
28
+ InvokeEndpointWithBidirectionalStreamInput,
29
+ InvokeEndpointWithBidirectionalStreamOutput,
30
+ )
31
+
32
+
33
+ _ServiceInterceptor = Union[
34
+ Interceptor[
35
+ InvokeEndpointWithBidirectionalStreamInput,
36
+ InvokeEndpointWithBidirectionalStreamOutput,
37
+ Any,
38
+ Any,
39
+ ]
40
+ ]
41
+
42
+
43
+ class _AsyncSageMakerRuntimeHTTP2ConfigOverrides(AwsConfigOverrides, total=False):
44
+ endpoint_resolver: EndpointResolver | None
45
+ protocol: ClientProtocol[Any, Any] | None
46
+ auth_schemes: dict[ShapeID, AuthScheme[Any, Any, Any, Any]] | None
47
+ auth_scheme_resolver: HTTPAuthSchemeResolver | None
48
+
49
+
50
+ @dataclass(kw_only=True, repr=False, init=False)
51
+ class AsyncSageMakerRuntimeHTTP2Config(AsyncAwsConfig):
52
+ """SageMaker Runtime HTTP2 configuration (async-resolved)."""
53
+
54
+ endpoint_resolver: EndpointResolver | None = None
55
+ """
56
+ The endpoint resolver used to resolve the final endpoint per-operation
57
+ based on the configuration.
58
+ """
59
+
60
+ protocol: ClientProtocol[Any, Any] | None = None
61
+ """The protocol to serialize and deserialize requests with."""
62
+
63
+ interceptors: list[_ServiceInterceptor] = field(default_factory=lambda: [])
64
+ """
65
+ The list of interceptors, which are hooks that are called during the
66
+ execution of a request.
67
+ """
68
+
69
+ auth_schemes: dict[ShapeID, AuthScheme[Any, Any, Any, Any]] | None = None
70
+ """A map of auth scheme ids to auth schemes."""
71
+
72
+ auth_scheme_resolver: HTTPAuthSchemeResolver | None = None
73
+ """
74
+ An auth scheme resolver that determines the auth scheme for each
75
+ operation.
76
+ """
77
+
78
+ aws_credentials_identity_resolver: (
79
+ IdentityResolver[AWSCredentialsIdentity, AWSIdentityProperties] | None
80
+ ) = None
81
+ """Resolves AWS Credentials. Required for operations that use Sigv4 Auth."""
82
+
83
+ region: str | None = None
84
+ """
85
+ The AWS region to connect to. The configured region is used to determine
86
+ the service endpoint.
87
+ """
88
+
89
+ aws_access_key_id: str | None = None
90
+ """The identifier for a secret access key."""
91
+
92
+ aws_secret_access_key: str | None = None
93
+ """A secret access key that can be used to sign requests."""
94
+
95
+ aws_session_token: str | None = None
96
+ """The session token used with temporary AWS credentials."""
97
+
98
+ user_agent_extra: str | None = None
99
+ """Additional suffix to be added to the User-Agent header."""
100
+
101
+ sdk_ua_app_id: str | None = None
102
+ """
103
+ A unique and opaque application ID that is appended to the User-Agent
104
+ header.
105
+ """
106
+
107
+ _FIELDS: ClassVar[dict[str, FieldSpec]] = {
108
+ "aws_credentials_identity_resolver": FieldSpec(default=None),
109
+ "region": FieldSpec(default=None),
110
+ "aws_access_key_id": FieldSpec(default=None),
111
+ "aws_secret_access_key": FieldSpec(default=None),
112
+ "aws_session_token": FieldSpec(default=None),
113
+ "user_agent_extra": FieldSpec(default=None),
114
+ "sdk_ua_app_id": FieldSpec(default=None),
115
+ **AsyncAwsConfig._FIELDS,
116
+ "endpoint_uri": FieldSpec(
117
+ default=None, resolver=EndpointUriResolver("sagemaker_runtime_http2")
118
+ ),
119
+ "endpoint_resolver": FieldSpec(
120
+ default_factory=lambda: StandardRegionalEndpointsResolver(
121
+ endpoint_prefix="runtime.sagemaker"
122
+ )
123
+ ),
124
+ "protocol": FieldSpec(
125
+ default_factory=lambda: RestJsonClientProtocol(
126
+ _SCHEMA_AMAZON_SAGE_MAKER_RUNTIME_HTTP2
127
+ )
128
+ ),
129
+ "auth_schemes": FieldSpec(
130
+ default_factory=lambda: {
131
+ ShapeID("aws.auth#sigv4"): SigV4AuthScheme(service="sagemaker")
132
+ }
133
+ ),
134
+ "auth_scheme_resolver": FieldSpec(default_factory=HTTPAuthSchemeResolver),
135
+ "transport": FieldSpec(default_factory=lambda: AIOHTTPClient()),
136
+ }
137
+
138
+ def set_auth_scheme(self, scheme: AuthScheme[Any, Any, Any, Any]) -> None:
139
+ """
140
+ Set an auth scheme implementation using its scheme ID. :param scheme:
141
+ The auth scheme to add or replace.
142
+ """
143
+ auth_schemes = dict(self.auth_schemes or {})
144
+ auth_schemes[scheme.scheme_id] = scheme
145
+ self.auth_schemes = auth_schemes
146
+
147
+ @classmethod
148
+ async def resolve( # pyright: ignore[reportIncompatibleMethodOverride]
149
+ cls,
150
+ *,
151
+ profile: str | None = None,
152
+ fs: FileSystem | None = None,
153
+ config_file_path: str | None = None,
154
+ credentials_file_path: str | None = None,
155
+ **overrides: Unpack[_AsyncSageMakerRuntimeHTTP2ConfigOverrides],
156
+ ) -> Self:
157
+ """
158
+ Resolve config from environment, config files, defaults, and explicit
159
+ overrides.
160
+ """
161
+ return await cls._resolve(
162
+ profile=profile,
163
+ fs=fs,
164
+ config_file_path=config_file_path,
165
+ credentials_file_path=credentials_file_path,
166
+ overrides=overrides,
167
+ )
168
+
169
+
170
+ Plugin: TypeAlias = Callable[[AsyncSageMakerRuntimeHTTP2Config], None]
171
+ """
172
+ A callable that customizes a client configuration. Service-level plugins
173
+ are applied once to the base configuration inherited by every operation.
174
+ Operation-level plugins apply only to a single operation invocation.
175
+ """
@@ -3,10 +3,10 @@
3
3
  from smithy_aws_core.interceptors.user_agent import UserAgentInterceptor
4
4
 
5
5
  from . import __version__
6
- from .config import Config
6
+ from .config import AsyncSageMakerRuntimeHTTP2Config
7
7
 
8
8
 
9
- def aws_user_agent_plugin(config: Config):
9
+ def aws_user_agent_plugin(config: AsyncSageMakerRuntimeHTTP2Config):
10
10
  config.interceptors.append(
11
11
  UserAgentInterceptor(
12
12
  ua_suffix=config.user_agent_extra,
@@ -1,180 +0,0 @@
1
- # Code generated by smithy-python-codegen DO NOT EDIT.
2
-
3
- from dataclasses import dataclass
4
- from typing import Any, Callable, TypeAlias, Union
5
-
6
- from smithy_aws_core.aio.protocols import RestJsonClientProtocol
7
- from smithy_aws_core.auth import SigV4AuthScheme
8
- from smithy_aws_core.endpoints.standard_regional import (
9
- StandardRegionalEndpointsResolver,
10
- )
11
- from smithy_aws_core.identity import AWSCredentialsIdentity, AWSIdentityProperties
12
- from smithy_core.aio.interfaces import ClientProtocol, ClientTransport, EndpointResolver
13
- from smithy_core.aio.interfaces.auth import AuthScheme
14
- from smithy_core.aio.interfaces.identity import IdentityResolver
15
- from smithy_core.aio.interfaces.retries import RetryStrategy
16
- from smithy_core.interceptors import Interceptor
17
- from smithy_core.interfaces import URI
18
- from smithy_core.retries import RetryStrategyOptions
19
- from smithy_core.shapes import ShapeID
20
- from smithy_http.aio.crt import AWSCRTHTTPClient
21
- from smithy_http.interfaces import HTTPRequestConfiguration
22
-
23
- from ._private.schemas import (
24
- AMAZON_SAGE_MAKER_RUNTIME_HTTP2 as _SCHEMA_AMAZON_SAGE_MAKER_RUNTIME_HTTP2,
25
- )
26
- from .auth import HTTPAuthSchemeResolver
27
- from .models import (
28
- InvokeEndpointWithBidirectionalStreamInput,
29
- InvokeEndpointWithBidirectionalStreamOutput,
30
- )
31
-
32
-
33
- _ServiceInterceptor = Union[
34
- Interceptor[
35
- InvokeEndpointWithBidirectionalStreamInput,
36
- InvokeEndpointWithBidirectionalStreamOutput,
37
- Any,
38
- Any,
39
- ]
40
- ]
41
-
42
-
43
- @dataclass(init=False)
44
- class Config:
45
- """Configuration for SageMaker Runtime HTTP2."""
46
-
47
- auth_scheme_resolver: HTTPAuthSchemeResolver
48
- """
49
- An auth scheme resolver that determines the auth scheme for each
50
- operation.
51
- """
52
-
53
- auth_schemes: dict[ShapeID, AuthScheme[Any, Any, Any, Any]]
54
- """A map of auth scheme ids to auth schemes."""
55
-
56
- aws_access_key_id: str | None
57
- """The identifier for a secret access key."""
58
-
59
- aws_credentials_identity_resolver: (
60
- IdentityResolver[AWSCredentialsIdentity, AWSIdentityProperties] | None
61
- )
62
- """Resolves AWS Credentials. Required for operations that use Sigv4 Auth."""
63
-
64
- aws_secret_access_key: str | None
65
- """A secret access key that can be used to sign requests."""
66
-
67
- aws_session_token: str | None
68
- """An access key ID that identifies temporary security credentials."""
69
-
70
- endpoint_resolver: EndpointResolver
71
- """
72
- The endpoint resolver used to resolve the final endpoint per-operation
73
- based on the configuration.
74
- """
75
-
76
- endpoint_uri: str | URI | None
77
- """A static URI to route requests to."""
78
-
79
- http_request_config: HTTPRequestConfiguration | None
80
- """Configuration for individual HTTP requests."""
81
-
82
- interceptors: list[_ServiceInterceptor]
83
- """
84
- The list of interceptors, which are hooks that are called during the
85
- execution of a request.
86
- """
87
-
88
- protocol: ClientProtocol[Any, Any] | None
89
- """The protocol to serialize and deserialize requests with."""
90
-
91
- region: str | None
92
- """
93
- The AWS region to connect to. The configured region is used to determine
94
- the service endpoint.
95
- """
96
-
97
- retry_strategy: RetryStrategy | RetryStrategyOptions | None
98
- """
99
- The retry strategy or options for configuring retry behavior. Can be
100
- either a configured RetryStrategy or RetryStrategyOptions to create one.
101
- """
102
-
103
- sdk_ua_app_id: str | None
104
- """
105
- A unique and opaque application ID that is appended to the User-Agent
106
- header.
107
- """
108
-
109
- transport: ClientTransport[Any, Any] | None
110
- """
111
- The transport to use to send requests (e.g. an HTTP client). Operations
112
- with bidirectional event streams require a DuplexClientTransport, such
113
- as AWSCRTHTTPClient. Transports are assumed not to support duplex
114
- streaming unless they explicitly set SUPPORTS_DUPLEX_STREAMING to True.
115
- """
116
-
117
- user_agent_extra: str | None
118
- """Additional suffix to be added to the User-Agent header."""
119
-
120
- def __init__(
121
- self,
122
- *,
123
- auth_scheme_resolver: HTTPAuthSchemeResolver | None = None,
124
- auth_schemes: dict[ShapeID, AuthScheme[Any, Any, Any, Any]] | None = None,
125
- aws_access_key_id: str | None = None,
126
- aws_credentials_identity_resolver: IdentityResolver[
127
- AWSCredentialsIdentity, AWSIdentityProperties
128
- ]
129
- | None = None,
130
- aws_secret_access_key: str | None = None,
131
- aws_session_token: str | None = None,
132
- endpoint_resolver: EndpointResolver | None = None,
133
- endpoint_uri: str | URI | None = None,
134
- http_request_config: HTTPRequestConfiguration | None = None,
135
- interceptors: list[_ServiceInterceptor] | None = None,
136
- protocol: ClientProtocol[Any, Any] | None = None,
137
- region: str | None = None,
138
- retry_strategy: RetryStrategy | RetryStrategyOptions | None = None,
139
- sdk_ua_app_id: str | None = None,
140
- transport: ClientTransport[Any, Any] | None = None,
141
- user_agent_extra: str | None = None,
142
- ):
143
- self.auth_scheme_resolver = auth_scheme_resolver or HTTPAuthSchemeResolver()
144
- self.auth_schemes = auth_schemes or {
145
- ShapeID("aws.auth#sigv4"): SigV4AuthScheme(service="sagemaker")
146
- }
147
- self.aws_access_key_id = aws_access_key_id
148
- self.aws_credentials_identity_resolver = aws_credentials_identity_resolver
149
- self.aws_secret_access_key = aws_secret_access_key
150
- self.aws_session_token = aws_session_token
151
- self.endpoint_resolver = endpoint_resolver or StandardRegionalEndpointsResolver(
152
- endpoint_prefix="runtime.sagemaker"
153
- )
154
- self.endpoint_uri = endpoint_uri
155
- self.http_request_config = http_request_config
156
- self.interceptors = interceptors or []
157
- self.protocol = protocol or RestJsonClientProtocol(
158
- _SCHEMA_AMAZON_SAGE_MAKER_RUNTIME_HTTP2
159
- )
160
- self.region = region
161
- self.retry_strategy = retry_strategy
162
- self.sdk_ua_app_id = sdk_ua_app_id
163
- self.transport = transport or AWSCRTHTTPClient()
164
- self.user_agent_extra = user_agent_extra
165
-
166
- def set_auth_scheme(self, scheme: AuthScheme[Any, Any, Any, Any]) -> None:
167
- """
168
- Sets the implementation of an auth scheme.
169
-
170
- Using this method ensures the correct key is used.
171
-
172
- Args:
173
- scheme:
174
- The auth scheme to add.
175
- """
176
- self.auth_schemes[scheme.scheme_id] = scheme
177
-
178
-
179
- Plugin: TypeAlias = Callable[[Config], None]
180
- """A callable that allows customizing the config object on each request."""