capo-sagemaker-runtime-http2 0.7.0__tar.gz → 0.9.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 (56) hide show
  1. {capo_sagemaker_runtime_http2-0.7.0/src/capo_sagemaker_runtime_http2.egg-info → capo_sagemaker_runtime_http2-0.9.0}/PKG-INFO +10 -2
  2. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/README.md +5 -1
  3. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/pyproject.toml +7 -1
  4. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/__init__.py +12 -0
  5. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/_auth/_providers.py +118 -19
  6. capo_sagemaker_runtime_http2-0.9.0/src/capo_sagemaker_runtime_http2/types/_unknown.py +34 -0
  7. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/types/request_stream_event.py +8 -1
  8. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/types/response_stream_event.py +8 -0
  9. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0/src/capo_sagemaker_runtime_http2.egg-info}/PKG-INFO +10 -2
  10. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2.egg-info/SOURCES.txt +1 -0
  11. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/LICENSE +0 -0
  12. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/setup.cfg +0 -0
  13. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/_async.py +0 -0
  14. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/_auth/_identity.py +0 -0
  15. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/_auth/_signers.py +0 -0
  16. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/_auth/_sigv4.py +0 -0
  17. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/_auth/_zapros_handler.py +0 -0
  18. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/_aws.py +0 -0
  19. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/_body.py +0 -0
  20. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/_iter.py +0 -0
  21. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/_operations/amazon_sage_maker_runtime_http2/invoke_endpoint_with_bidirectional_stream.py +0 -0
  22. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/_pagination.py +0 -0
  23. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/_protocol/__init__.py +0 -0
  24. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/_protocol/errors.py +0 -0
  25. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/_protocol/eventstream.py +0 -0
  26. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/_protocol/serialize.py +0 -0
  27. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/_protocol/xml.py +0 -0
  28. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/_rule_engine/__init__.py +0 -0
  29. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/_rule_engine/_aws_partition.py +0 -0
  30. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/_rule_engine/_endpoint_rule_set.py +0 -0
  31. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/_rule_engine/_endpoint_runtime.py +0 -0
  32. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/_services/_aws_config.py +0 -0
  33. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/_services/_pipeline.py +0 -0
  34. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/_services/async_sage_maker_runtime_http2.py +0 -0
  35. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/_services/sage_maker_runtime_http2.py +0 -0
  36. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/errors/__init__.py +0 -0
  37. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/errors/_base.py +0 -0
  38. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/errors/input_validation_error.py +0 -0
  39. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/errors/internal_server_error.py +0 -0
  40. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/errors/internal_stream_failure.py +0 -0
  41. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/errors/model_error.py +0 -0
  42. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/errors/model_stream_error.py +0 -0
  43. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/errors/service_unavailable_error.py +0 -0
  44. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/py.typed +0 -0
  45. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/types/_prelude/blob.py +0 -0
  46. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/types/_prelude/timestamp.py +0 -0
  47. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/types/invoke_endpoint_with_bidirectional_stream_input.py +0 -0
  48. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/types/invoke_endpoint_with_bidirectional_stream_output.py +0 -0
  49. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/types/request_payload_part.py +0 -0
  50. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/types/response_payload_part.py +0 -0
  51. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2/types/sensitive_blob.py +0 -0
  52. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2.egg-info/dependency_links.txt +0 -0
  53. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2.egg-info/requires.txt +0 -0
  54. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/src/capo_sagemaker_runtime_http2.egg-info/top_level.txt +0 -0
  55. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/tests/test_body.py +0 -0
  56. {capo_sagemaker_runtime_http2-0.7.0 → capo_sagemaker_runtime_http2-0.9.0}/tests/test_sigv4.py +0 -0
@@ -1,7 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: capo-sagemaker-runtime-http2
3
- Version: 0.7.0
3
+ Version: 0.9.0
4
4
  Summary: Python SDK for AWS Sagemaker Runtime Http2.
5
+ Project-URL: Homepage, https://capo-sdk.dev/
6
+ Project-URL: Documentation, https://capo-sdk.dev/services/sagemaker-runtime-http2/
7
+ Project-URL: Repository, https://github.com/kap-sh/capo/tree/main/services/sagemaker-runtime-http2
8
+ Project-URL: Changelog, https://github.com/kap-sh/capo/blob/main/services/sagemaker-runtime-http2/CHANGELOG.md
5
9
  Classifier: Development Status :: 4 - Beta
6
10
  Classifier: Intended Audience :: Developers
7
11
  Classifier: License :: OSI Approved :: MIT License
@@ -26,7 +30,11 @@ Requires-Dist: capo-sso-oidc>=0.2.0; extra == "sso"
26
30
  Requires-Dist: capo-sts>=0.3.0; extra == "sso"
27
31
  Dynamic: license-file
28
32
 
29
- # Getting Started
33
+ # capo-sagemaker-runtime-http2: typed, async Python SDK for AWS Sagemaker Runtime Http2
34
+
35
+ `capo-sagemaker-runtime-http2` is a typed Python SDK for AWS Sagemaker Runtime Http2. It has an async client, `AsyncSageMakerRuntimeHTTP2Client`, for asyncio and trio, and a sync client, `SageMakerRuntimeHTTP2Client`, with the same methods. Requests and responses are typed with TypedDicts, so your editor and type checker know every field.
36
+
37
+ It is part of [capo](https://capo-sdk.dev/), a community-driven alternative to boto3 and aioboto3, built on its own HTTP stack instead of botocore and generated from the official AWS Smithy models. Documentation: [https://capo-sdk.dev/services/sagemaker-runtime-http2/](https://capo-sdk.dev/services/sagemaker-runtime-http2/)
30
38
 
31
39
  ## Installation
32
40
 
@@ -1,4 +1,8 @@
1
- # Getting Started
1
+ # capo-sagemaker-runtime-http2: typed, async Python SDK for AWS Sagemaker Runtime Http2
2
+
3
+ `capo-sagemaker-runtime-http2` is a typed Python SDK for AWS Sagemaker Runtime Http2. It has an async client, `AsyncSageMakerRuntimeHTTP2Client`, for asyncio and trio, and a sync client, `SageMakerRuntimeHTTP2Client`, with the same methods. Requests and responses are typed with TypedDicts, so your editor and type checker know every field.
4
+
5
+ It is part of [capo](https://capo-sdk.dev/), a community-driven alternative to boto3 and aioboto3, built on its own HTTP stack instead of botocore and generated from the official AWS Smithy models. Documentation: [https://capo-sdk.dev/services/sagemaker-runtime-http2/](https://capo-sdk.dev/services/sagemaker-runtime-http2/)
2
6
 
3
7
  ## Installation
4
8
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "capo-sagemaker-runtime-http2"
3
- version = "0.7.0"
3
+ version = "0.9.0"
4
4
  description = "Python SDK for AWS Sagemaker Runtime Http2."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -22,6 +22,12 @@ dependencies = [
22
22
  "zapros>=0.21.0",
23
23
  ]
24
24
 
25
+ [project.urls]
26
+ Homepage = "https://capo-sdk.dev/"
27
+ Documentation = "https://capo-sdk.dev/services/sagemaker-runtime-http2/"
28
+ Repository = "https://github.com/kap-sh/capo/tree/main/services/sagemaker-runtime-http2"
29
+ Changelog = "https://github.com/kap-sh/capo/blob/main/services/sagemaker-runtime-http2/CHANGELOG.md"
30
+
25
31
  [project.optional-dependencies]
26
32
  # Async file request bodies via Body.async_from_path
27
33
  anyio = ["anyio>=3.0"]
@@ -16,6 +16,9 @@ from ._auth._providers import (
16
16
  from ._auth._providers import (
17
17
  ChainedProvider as ChainedProvider,
18
18
  )
19
+ from ._auth._providers import (
20
+ CredentialProcessError as CredentialProcessError,
21
+ )
19
22
  from ._auth._providers import (
20
23
  CredentialsProvider as CredentialsProvider,
21
24
  )
@@ -31,6 +34,9 @@ from ._auth._providers import (
31
34
  from ._auth._providers import (
32
35
  MissingDependencyError as MissingDependencyError,
33
36
  )
37
+ from ._auth._providers import (
38
+ ProcessCredentialsProvider as ProcessCredentialsProvider,
39
+ )
34
40
  from ._auth._providers import (
35
41
  ProfileCredentialsProvider as ProfileCredentialsProvider,
36
42
  )
@@ -73,3 +79,9 @@ from ._services.async_sage_maker_runtime_http2 import (
73
79
  from ._services.sage_maker_runtime_http2 import (
74
80
  SageMakerRuntimeHTTP2Client as SageMakerRuntimeHTTP2Client,
75
81
  )
82
+ from .types._unknown import (
83
+ UnknownEvent as UnknownEvent,
84
+ )
85
+ from .types._unknown import (
86
+ UnknownUnionMember as UnknownUnionMember,
87
+ )
@@ -4,6 +4,7 @@ import configparser
4
4
  import hashlib
5
5
  import json
6
6
  import os
7
+ import subprocess
7
8
  import time
8
9
  from abc import abstractmethod
9
10
  from dataclasses import dataclass
@@ -59,6 +60,10 @@ class IdentityNotFound(Exception):
59
60
  """Raised when a provider cannot resolve an identity. Chain continues."""
60
61
 
61
62
 
63
+ class CredentialProcessError(Exception):
64
+ """Raised when a profile's `credential_process` fails or prints unusable output. Chain stops."""
65
+
66
+
62
67
  class MissingDependencyError(Exception):
63
68
  """Raised when a provider needs the `sso` extra but it is not installed."""
64
69
 
@@ -186,13 +191,27 @@ class ProfileCredentialsProvider(CredentialsProvider):
186
191
  self, credentials_file: Path | None = None, profile: str | None = None
187
192
  ) -> None:
188
193
  self._profile = profile or active_profile()
189
- self._cred_file = credentials_file or Path(
190
- os.environ.get("AWS_SHARED_CREDENTIALS_FILE")
191
- or Path.home() / ".aws" / "credentials"
192
- )
194
+ self._cred_file = credentials_file or _shared_credentials_file()
193
195
 
194
196
  def resolve_identity(self) -> Credentials:
195
- section = self._load_section()
197
+ from_config, _ = _load_profile(self._profile)
198
+ from_credentials_file = _credentials_file_section(
199
+ self._profile, self._cred_file
200
+ )
201
+ section = {**from_config, **from_credentials_file}
202
+ if not section:
203
+ raise IdentityNotFound(
204
+ f"profile {self._profile!r} not found in credentials/config files"
205
+ )
206
+ # botocore's order: keys from the credentials file, then credential_process, then keys from the
207
+ # config file, so a profile with a process only takes its keys from the credentials file
208
+ if "credential_process" in section and not (
209
+ from_credentials_file.get("aws_access_key_id")
210
+ and from_credentials_file.get("aws_secret_access_key")
211
+ ):
212
+ raise IdentityNotFound(
213
+ f"profile {self._profile!r}: credential_process comes before the keys in the config file"
214
+ )
196
215
  ak = section.get("aws_access_key_id")
197
216
  sk = section.get("aws_secret_access_key")
198
217
  if not ak or not sk:
@@ -205,19 +224,94 @@ class ProfileCredentialsProvider(CredentialsProvider):
205
224
  out["session_token"] = token
206
225
  return out
207
226
 
208
- def _load_section(self) -> dict[str, str]:
209
- # config-file profile reuses the loader from _services/_aws_config
210
- merged, _ = _load_profile(self._profile)
211
- if self._cred_file.is_file():
212
- cfg = configparser.ConfigParser(interpolation=None)
213
- cfg.read(self._cred_file)
214
- if cfg.has_section(self._profile):
215
- merged.update(dict(cfg.items(self._profile)))
216
- if not merged:
217
- raise IdentityNotFound(
218
- f"profile {self._profile!r} not found in credentials/config files"
227
+
228
+ class ProcessCredentialsProvider(CredentialsProvider):
229
+ """Run the profile's ``credential_process`` command and read the credentials it prints.
230
+
231
+ This is how helpers such as ``aws-sso-cli`` hand out short-term credentials. The command
232
+ runs through the system shell, as in the Rust, Kotlin and Swift SDKs, so a quoted Windows path
233
+ works as written, and it must print the JSON document the AWS SDKs define (``Version`` 1).
234
+ The key is read from the credentials file as well as the config file. A profile without
235
+ ``credential_process`` is skipped; a command that fails or outlives the timeout stops the chain.
236
+ """
237
+
238
+ def __init__(
239
+ self,
240
+ credentials_file: Path | None = None,
241
+ profile: str | None = None,
242
+ timeout: float = 60.0,
243
+ ) -> None:
244
+ self._profile = profile or active_profile()
245
+ self._cred_file = credentials_file or _shared_credentials_file()
246
+ self._timeout = timeout
247
+
248
+ def resolve_identity(self) -> Credentials:
249
+ section = _load_merged_profile(self._profile, self._cred_file)
250
+ command = section.get("credential_process")
251
+ if not command:
252
+ raise IdentityNotFound(f"profile {self._profile!r}: no credential_process")
253
+ try:
254
+ # the shell is sh -c on POSIX and cmd.exe /c on Windows, which parses the path natively
255
+ result = subprocess.run(
256
+ command,
257
+ shell=True,
258
+ capture_output=True,
259
+ text=True,
260
+ check=False,
261
+ timeout=self._timeout,
262
+ )
263
+ except subprocess.TimeoutExpired:
264
+ raise CredentialProcessError(
265
+ f"profile {self._profile!r}: credential_process did not finish within {self._timeout} seconds"
266
+ ) from None
267
+ except OSError as e:
268
+ raise CredentialProcessError(f"profile {self._profile!r}: {e}") from e
269
+ # stdout carries the secret, so only stderr ever goes into an error message
270
+ if result.returncode != 0:
271
+ raise CredentialProcessError(
272
+ f"profile {self._profile!r}: credential_process exited with {result.returncode}: {result.stderr.strip()}"
273
+ )
274
+ try:
275
+ data = json.loads(result.stdout)
276
+ except ValueError:
277
+ raise CredentialProcessError(
278
+ f"profile {self._profile!r}: credential_process did not print JSON"
279
+ ) from None
280
+ if not isinstance(data, dict) or data.get("Version") != 1:
281
+ raise CredentialProcessError(
282
+ f"profile {self._profile!r}: credential_process output must be a JSON object with Version 1"
219
283
  )
220
- return merged
284
+ try:
285
+ return _credentials_from_json(data, token_key="SessionToken")
286
+ except IdentityNotFound as e:
287
+ raise CredentialProcessError(f"profile {self._profile!r}: {e}") from None
288
+ except ValueError:
289
+ raise CredentialProcessError(
290
+ f"profile {self._profile!r}: credential_process printed an invalid Expiration"
291
+ ) from None
292
+
293
+
294
+ def _shared_credentials_file() -> Path:
295
+ return Path(
296
+ os.environ.get("AWS_SHARED_CREDENTIALS_FILE")
297
+ or Path.home() / ".aws" / "credentials"
298
+ )
299
+
300
+
301
+ def _load_merged_profile(profile: str, credentials_file: Path) -> dict[str, str]:
302
+ """The profile's keys from the config file, overlaid by the credentials file, as the AWS SDKs merge them."""
303
+ # config-file profile reuses the loader from _services/_aws_config
304
+ merged, _ = _load_profile(profile)
305
+ merged.update(_credentials_file_section(profile, credentials_file))
306
+ return merged
307
+
308
+
309
+ def _credentials_file_section(profile: str, credentials_file: Path) -> dict[str, str]:
310
+ if not credentials_file.is_file():
311
+ return {}
312
+ cfg = configparser.ConfigParser(interpolation=None)
313
+ cfg.read(credentials_file)
314
+ return dict(cfg.items(profile)) if cfg.has_section(profile) else {}
221
315
 
222
316
 
223
317
  class EcsContainerCredentialsProvider(CredentialsProvider):
@@ -721,6 +815,7 @@ class AssumeRoleCredentialsProvider(CredentialsProvider):
721
815
  ),
722
816
  SsoCredentialsProvider(self._client, source_profile),
723
817
  ProfileCredentialsProvider(profile=source_profile),
818
+ ProcessCredentialsProvider(profile=source_profile),
724
819
  )
725
820
 
726
821
 
@@ -853,7 +948,10 @@ def _parse_iso8601(value: str) -> datetime:
853
948
  return datetime.fromisoformat(value.replace("Z", "+00:00"))
854
949
 
855
950
 
856
- def _credentials_from_json(data: dict[str, object]) -> Credentials:
951
+ def _credentials_from_json(
952
+ data: dict[str, object], *, token_key: str = "Token"
953
+ ) -> Credentials:
954
+ # ECS and IMDS name the session token Token; credential_process names it SessionToken
857
955
  ak = data.get("AccessKeyId")
858
956
  sk = data.get("SecretAccessKey")
859
957
  if not isinstance(ak, str) or not isinstance(sk, str):
@@ -861,7 +959,7 @@ def _credentials_from_json(data: dict[str, object]) -> Credentials:
861
959
  "credentials response missing AccessKeyId/SecretAccessKey"
862
960
  )
863
961
  out: Credentials = {"access_key": ak, "secret_key": sk}
864
- token = data.get("Token")
962
+ token = data.get(token_key)
865
963
  if isinstance(token, str):
866
964
  out["session_token"] = token
867
965
  exp = data.get("Expiration")
@@ -880,6 +978,7 @@ def default_aws_credentials_chain(
880
978
  WebIdentityCredentialsProvider(client),
881
979
  SsoCredentialsProvider(client),
882
980
  ProfileCredentialsProvider(),
981
+ ProcessCredentialsProvider(),
883
982
  EcsContainerCredentialsProvider(client),
884
983
  Ec2InstanceMetadataProvider(client),
885
984
  )
@@ -0,0 +1,34 @@
1
+ """Stand-ins for union variants and events this client doesn't know about.
2
+
3
+ A service may add a union member or an event after the client was generated.
4
+ Smithy asks clients not to fail on those, so deserialization returns one of
5
+ these instead of raising.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from dataclasses import dataclass
11
+
12
+ from .._protocol.eventstream import Message
13
+
14
+
15
+ @dataclass(frozen=True)
16
+ class UnknownUnionMember:
17
+ """A union variant the service sent that this client has no member for."""
18
+
19
+ name: str
20
+ """The variant's name on the wire."""
21
+
22
+
23
+ @dataclass(frozen=True)
24
+ class UnknownEvent:
25
+ """An event-stream event whose ``:event-type`` this client doesn't know."""
26
+
27
+ event_type: str
28
+ """The event's ``:event-type`` header."""
29
+
30
+ message: Message
31
+ """The raw message, headers and undecoded payload."""
32
+
33
+
34
+ __all__ = ["UnknownEvent", "UnknownUnionMember"]
@@ -10,6 +10,7 @@ from capo_sagemaker_runtime_http2._protocol.eventstream import Message
10
10
  from capo_sagemaker_runtime_http2.errors import (
11
11
  UnknownServiceError,
12
12
  )
13
+ from capo_sagemaker_runtime_http2.types._unknown import UnknownEvent
13
14
 
14
15
  if TYPE_CHECKING:
15
16
  import capo_sagemaker_runtime_http2.types.request_payload_part
@@ -21,11 +22,15 @@ class _RequestStreamEvent_PayloadPart(TypedDict, closed=True):
21
22
  )
22
23
 
23
24
 
24
- _RequestStreamEvent: TypeAlias = _RequestStreamEvent_PayloadPart
25
+ _RequestStreamEvent: TypeAlias = _RequestStreamEvent_PayloadPart | UnknownEvent
25
26
  RequestStreamEvent: TypeAlias = AnyIterator[_RequestStreamEvent]
26
27
 
27
28
 
28
29
  def serialize_event_json(value: _RequestStreamEvent) -> bytes:
30
+ if isinstance(value, UnknownEvent):
31
+ raise ValueError(
32
+ f"RequestStreamEvent: cannot serialize unknown event {value.event_type!r}"
33
+ )
29
34
  match value:
30
35
  case {"PayloadPart": payload}:
31
36
  import capo_sagemaker_runtime_http2.types.request_payload_part
@@ -65,6 +70,8 @@ def deserialize_event_json(
65
70
  message
66
71
  )
67
72
  }
73
+ case str():
74
+ return UnknownEvent(event_type, message)
68
75
  case _:
69
76
  raise ValueError(
70
77
  f"RequestStreamEvent: unrecognized event-type {event_type!r}"
@@ -10,6 +10,7 @@ from capo_sagemaker_runtime_http2._protocol.eventstream import Message
10
10
  from capo_sagemaker_runtime_http2.errors import (
11
11
  UnknownServiceError,
12
12
  )
13
+ from capo_sagemaker_runtime_http2.types._unknown import UnknownEvent
13
14
 
14
15
  if TYPE_CHECKING:
15
16
  import capo_sagemaker_runtime_http2.errors.internal_stream_failure
@@ -37,11 +38,16 @@ _ResponseStreamEvent: TypeAlias = (
37
38
  _ResponseStreamEvent_PayloadPart
38
39
  | _ResponseStreamEvent_ModelStreamError
39
40
  | _ResponseStreamEvent_InternalStreamFailure
41
+ | UnknownEvent
40
42
  )
41
43
  ResponseStreamEvent: TypeAlias = AnyIterator[_ResponseStreamEvent]
42
44
 
43
45
 
44
46
  def serialize_event_json(value: _ResponseStreamEvent) -> bytes:
47
+ if isinstance(value, UnknownEvent):
48
+ raise ValueError(
49
+ f"ResponseStreamEvent: cannot serialize unknown event {value.event_type!r}"
50
+ )
45
51
  match value:
46
52
  case {"PayloadPart": payload}:
47
53
  import capo_sagemaker_runtime_http2.types.response_payload_part
@@ -112,6 +118,8 @@ def deserialize_event_json(
112
118
  message
113
119
  )
114
120
  }
121
+ case str():
122
+ return UnknownEvent(event_type, message)
115
123
  case _:
116
124
  raise ValueError(
117
125
  f"ResponseStreamEvent: unrecognized event-type {event_type!r}"
@@ -1,7 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: capo-sagemaker-runtime-http2
3
- Version: 0.7.0
3
+ Version: 0.9.0
4
4
  Summary: Python SDK for AWS Sagemaker Runtime Http2.
5
+ Project-URL: Homepage, https://capo-sdk.dev/
6
+ Project-URL: Documentation, https://capo-sdk.dev/services/sagemaker-runtime-http2/
7
+ Project-URL: Repository, https://github.com/kap-sh/capo/tree/main/services/sagemaker-runtime-http2
8
+ Project-URL: Changelog, https://github.com/kap-sh/capo/blob/main/services/sagemaker-runtime-http2/CHANGELOG.md
5
9
  Classifier: Development Status :: 4 - Beta
6
10
  Classifier: Intended Audience :: Developers
7
11
  Classifier: License :: OSI Approved :: MIT License
@@ -26,7 +30,11 @@ Requires-Dist: capo-sso-oidc>=0.2.0; extra == "sso"
26
30
  Requires-Dist: capo-sts>=0.3.0; extra == "sso"
27
31
  Dynamic: license-file
28
32
 
29
- # Getting Started
33
+ # capo-sagemaker-runtime-http2: typed, async Python SDK for AWS Sagemaker Runtime Http2
34
+
35
+ `capo-sagemaker-runtime-http2` is a typed Python SDK for AWS Sagemaker Runtime Http2. It has an async client, `AsyncSageMakerRuntimeHTTP2Client`, for asyncio and trio, and a sync client, `SageMakerRuntimeHTTP2Client`, with the same methods. Requests and responses are typed with TypedDicts, so your editor and type checker know every field.
36
+
37
+ It is part of [capo](https://capo-sdk.dev/), a community-driven alternative to boto3 and aioboto3, built on its own HTTP stack instead of botocore and generated from the official AWS Smithy models. Documentation: [https://capo-sdk.dev/services/sagemaker-runtime-http2/](https://capo-sdk.dev/services/sagemaker-runtime-http2/)
30
38
 
31
39
  ## Installation
32
40
 
@@ -40,6 +40,7 @@ src/capo_sagemaker_runtime_http2/errors/internal_stream_failure.py
40
40
  src/capo_sagemaker_runtime_http2/errors/model_error.py
41
41
  src/capo_sagemaker_runtime_http2/errors/model_stream_error.py
42
42
  src/capo_sagemaker_runtime_http2/errors/service_unavailable_error.py
43
+ src/capo_sagemaker_runtime_http2/types/_unknown.py
43
44
  src/capo_sagemaker_runtime_http2/types/invoke_endpoint_with_bidirectional_stream_input.py
44
45
  src/capo_sagemaker_runtime_http2/types/invoke_endpoint_with_bidirectional_stream_output.py
45
46
  src/capo_sagemaker_runtime_http2/types/request_payload_part.py