sagemaker-core 1.0.4__py3-none-any.whl → 1.0.5__py3-none-any.whl

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.

Potentially problematic release.


This version of sagemaker-core might be problematic. Click here for more details.

@@ -27,7 +27,6 @@ from sagemaker_core.main.code_injection.codec import transform
27
27
  from sagemaker_core.main.code_injection.constants import Color
28
28
  from sagemaker_core.main.utils import (
29
29
  SageMakerClient,
30
- SageMakerRuntimeClient,
31
30
  ResourceIterator,
32
31
  Unassigned,
33
32
  get_textual_rich_logger,
@@ -35,7 +34,6 @@ from sagemaker_core.main.utils import (
35
34
  pascal_to_snake,
36
35
  is_not_primitive,
37
36
  is_not_str_dict,
38
- is_snake_case,
39
37
  is_primitive_list,
40
38
  serialize,
41
39
  )
@@ -55,9 +53,9 @@ class Base(BaseModel):
55
53
 
56
54
  @classmethod
57
55
  def get_sagemaker_client(cls, session=None, region_name=None, service_name="sagemaker"):
58
- return SageMakerClient(
59
- session=session, region_name=region_name, service_name=service_name
60
- ).client
56
+ return SageMakerClient(session=session, region_name=region_name).get_client(
57
+ service_name=service_name
58
+ )
61
59
 
62
60
  @staticmethod
63
61
  def get_updated_kwargs_with_configured_attributes(
@@ -8107,6 +8105,125 @@ class Endpoint(Base):
8107
8105
  raise e
8108
8106
  time.sleep(poll)
8109
8107
 
8108
+ @classmethod
8109
+ @Base.add_validate_call
8110
+ def get_all(
8111
+ cls,
8112
+ sort_by: Optional[str] = Unassigned(),
8113
+ sort_order: Optional[str] = Unassigned(),
8114
+ name_contains: Optional[str] = Unassigned(),
8115
+ creation_time_before: Optional[datetime.datetime] = Unassigned(),
8116
+ creation_time_after: Optional[datetime.datetime] = Unassigned(),
8117
+ last_modified_time_before: Optional[datetime.datetime] = Unassigned(),
8118
+ last_modified_time_after: Optional[datetime.datetime] = Unassigned(),
8119
+ status_equals: Optional[str] = Unassigned(),
8120
+ session: Optional[Session] = None,
8121
+ region: Optional[str] = None,
8122
+ ) -> ResourceIterator["Endpoint"]:
8123
+ """
8124
+ Get all Endpoint resources
8125
+
8126
+ Parameters:
8127
+ sort_by: Sorts the list of results. The default is CreationTime.
8128
+ sort_order: The sort order for results. The default is Descending.
8129
+ next_token: If the result of a ListEndpoints request was truncated, the response includes a NextToken. To retrieve the next set of endpoints, use the token in the next request.
8130
+ max_results: The maximum number of endpoints to return in the response. This value defaults to 10.
8131
+ name_contains: A string in endpoint names. This filter returns only endpoints whose name contains the specified string.
8132
+ creation_time_before: A filter that returns only endpoints that were created before the specified time (timestamp).
8133
+ creation_time_after: A filter that returns only endpoints with a creation time greater than or equal to the specified time (timestamp).
8134
+ last_modified_time_before: A filter that returns only endpoints that were modified before the specified timestamp.
8135
+ last_modified_time_after: A filter that returns only endpoints that were modified after the specified timestamp.
8136
+ status_equals: A filter that returns only endpoints with the specified status.
8137
+ session: Boto3 session.
8138
+ region: Region name.
8139
+
8140
+ Returns:
8141
+ Iterator for listed Endpoint resources.
8142
+
8143
+ Raises:
8144
+ botocore.exceptions.ClientError: This exception is raised for AWS service related errors.
8145
+ The error message and error code can be parsed from the exception as follows:
8146
+ ```
8147
+ try:
8148
+ # AWS service call here
8149
+ except botocore.exceptions.ClientError as e:
8150
+ error_message = e.response['Error']['Message']
8151
+ error_code = e.response['Error']['Code']
8152
+ ```
8153
+ """
8154
+
8155
+ client = Base.get_sagemaker_client(
8156
+ session=session, region_name=region, service_name="sagemaker"
8157
+ )
8158
+
8159
+ operation_input_args = {
8160
+ "SortBy": sort_by,
8161
+ "SortOrder": sort_order,
8162
+ "NameContains": name_contains,
8163
+ "CreationTimeBefore": creation_time_before,
8164
+ "CreationTimeAfter": creation_time_after,
8165
+ "LastModifiedTimeBefore": last_modified_time_before,
8166
+ "LastModifiedTimeAfter": last_modified_time_after,
8167
+ "StatusEquals": status_equals,
8168
+ }
8169
+
8170
+ # serialize the input request
8171
+ operation_input_args = serialize(operation_input_args)
8172
+ logger.debug(f"Serialized input request: {operation_input_args}")
8173
+
8174
+ return ResourceIterator(
8175
+ client=client,
8176
+ list_method="list_endpoints",
8177
+ summaries_key="Endpoints",
8178
+ summary_name="EndpointSummary",
8179
+ resource_cls=Endpoint,
8180
+ list_method_kwargs=operation_input_args,
8181
+ )
8182
+
8183
+ @Base.add_validate_call
8184
+ def update_weights_and_capacities(
8185
+ self,
8186
+ desired_weights_and_capacities: List[DesiredWeightAndCapacity],
8187
+ session: Optional[Session] = None,
8188
+ region: Optional[str] = None,
8189
+ ) -> None:
8190
+ """
8191
+ Updates variant weight of one or more variants associated with an existing endpoint, or capacity of one variant associated with an existing endpoint.
8192
+
8193
+ Parameters:
8194
+ desired_weights_and_capacities: An object that provides new capacity and weight values for a variant.
8195
+ session: Boto3 session.
8196
+ region: Region name.
8197
+
8198
+ Raises:
8199
+ botocore.exceptions.ClientError: This exception is raised for AWS service related errors.
8200
+ The error message and error code can be parsed from the exception as follows:
8201
+ ```
8202
+ try:
8203
+ # AWS service call here
8204
+ except botocore.exceptions.ClientError as e:
8205
+ error_message = e.response['Error']['Message']
8206
+ error_code = e.response['Error']['Code']
8207
+ ```
8208
+ ResourceLimitExceeded: You have exceeded an SageMaker resource limit. For example, you might have too many training jobs created.
8209
+ """
8210
+
8211
+ operation_input_args = {
8212
+ "EndpointName": self.endpoint_name,
8213
+ "DesiredWeightsAndCapacities": desired_weights_and_capacities,
8214
+ }
8215
+ # serialize the input request
8216
+ operation_input_args = serialize(operation_input_args)
8217
+ logger.debug(f"Serialized input request: {operation_input_args}")
8218
+
8219
+ client = Base.get_sagemaker_client(
8220
+ session=session, region_name=region, service_name="sagemaker"
8221
+ )
8222
+
8223
+ logger.debug(f"Calling update_endpoint_weights_and_capacities API")
8224
+ response = client.update_endpoint_weights_and_capacities(**operation_input_args)
8225
+ logger.debug(f"Response: {response}")
8226
+
8110
8227
  @Base.add_validate_call
8111
8228
  def invoke(
8112
8229
  self,
@@ -8120,9 +8237,12 @@ class Endpoint(Base):
8120
8237
  inference_id: Optional[str] = Unassigned(),
8121
8238
  enable_explanations: Optional[str] = Unassigned(),
8122
8239
  inference_component_name: Optional[str] = Unassigned(),
8123
- ) -> Optional[object]:
8240
+ session_id: Optional[str] = Unassigned(),
8241
+ session: Optional[Session] = None,
8242
+ region: Optional[str] = None,
8243
+ ) -> Optional[InvokeEndpointOutput]:
8124
8244
  """
8125
- Invoke a Endpoint resource
8245
+ After you deploy a model into production using Amazon SageMaker hosting services, your client applications use this API to get inferences from the model hosted at the specified endpoint.
8126
8246
 
8127
8247
  Parameters:
8128
8248
  body: Provides input data, in the format specified in the ContentType request header. Amazon SageMaker passes all of the data in the body to the model. For information about the format of the request body, see Common Data Formats-Inference.
@@ -8135,9 +8255,12 @@ class Endpoint(Base):
8135
8255
  inference_id: If you provide a value, it is added to the captured data when you enable data capture on the endpoint. For information about data capture, see Capture Data.
8136
8256
  enable_explanations: An optional JMESPath expression used to override the EnableExplanations parameter of the ClarifyExplainerConfig API. See the EnableExplanations section in the developer guide for more information.
8137
8257
  inference_component_name: If the endpoint hosts one or more inference components, this parameter specifies the name of inference component to invoke.
8258
+ session_id: Creates a stateful session or identifies an existing one. You can do one of the following: Create a stateful session by specifying the value NEW_SESSION. Send your request to an existing stateful session by specifying the ID of that session. With a stateful session, you can send multiple requests to a stateful model. When you create a session with a stateful model, the model must create the session ID and set the expiration time. The model must also provide that information in the response to your request. You can get the ID and timestamp from the NewSessionId response parameter. For any subsequent request where you specify that session ID, SageMaker routes the request to the same instance that supports the session.
8259
+ session: Boto3 session.
8260
+ region: Region name.
8138
8261
 
8139
8262
  Returns:
8140
- The Invoke response.
8263
+ InvokeEndpointOutput
8141
8264
 
8142
8265
  Raises:
8143
8266
  botocore.exceptions.ClientError: This exception is raised for AWS service related errors.
@@ -8150,15 +8273,13 @@ class Endpoint(Base):
8150
8273
  error_code = e.response['Error']['Code']
8151
8274
  ```
8152
8275
  InternalDependencyException: Your request caused an exception with an internal dependency. Contact customer support.
8153
- InternalFailure: An internal failure occurred.
8276
+ InternalFailure: An internal failure occurred. Try your request again. If the problem persists, contact Amazon Web Services customer support.
8154
8277
  ModelError: Model (owned by the customer in the container) returned 4xx or 5xx error code.
8155
8278
  ModelNotReadyException: Either a serverless endpoint variant's resources are still being provisioned, or a multi-model endpoint is still downloading or loading the target model. Wait and try your request again.
8156
- ServiceUnavailable: The service is unavailable. Try your call again.
8157
- ValidationError: Inspect your request and try again.
8279
+ ServiceUnavailable: The service is currently unavailable.
8280
+ ValidationError: There was an error validating your request.
8158
8281
  """
8159
8282
 
8160
- logger.info(f"Invoking endpoint resource.")
8161
- client = SageMakerRuntimeClient(service_name="sagemaker-runtime").client
8162
8283
  operation_input_args = {
8163
8284
  "EndpointName": self.endpoint_name,
8164
8285
  "Body": body,
@@ -8171,17 +8292,22 @@ class Endpoint(Base):
8171
8292
  "InferenceId": inference_id,
8172
8293
  "EnableExplanations": enable_explanations,
8173
8294
  "InferenceComponentName": inference_component_name,
8295
+ "SessionId": session_id,
8174
8296
  }
8175
- logger.debug(f"Input request: {operation_input_args}")
8176
8297
  # serialize the input request
8177
8298
  operation_input_args = serialize(operation_input_args)
8178
8299
  logger.debug(f"Serialized input request: {operation_input_args}")
8179
8300
 
8180
- # create the resource
8301
+ client = Base.get_sagemaker_client(
8302
+ session=session, region_name=region, service_name="sagemaker-runtime"
8303
+ )
8304
+
8305
+ logger.debug(f"Calling invoke_endpoint API")
8181
8306
  response = client.invoke_endpoint(**operation_input_args)
8182
8307
  logger.debug(f"Response: {response}")
8183
8308
 
8184
- return response
8309
+ transformed_response = transform(response, "InvokeEndpointOutput")
8310
+ return InvokeEndpointOutput(**transformed_response)
8185
8311
 
8186
8312
  @Base.add_validate_call
8187
8313
  def invoke_async(
@@ -8193,9 +8319,11 @@ class Endpoint(Base):
8193
8319
  inference_id: Optional[str] = Unassigned(),
8194
8320
  request_ttl_seconds: Optional[int] = Unassigned(),
8195
8321
  invocation_timeout_seconds: Optional[int] = Unassigned(),
8196
- ) -> Optional[object]:
8322
+ session: Optional[Session] = None,
8323
+ region: Optional[str] = None,
8324
+ ) -> Optional[InvokeEndpointAsyncOutput]:
8197
8325
  """
8198
- Invoke Async a Endpoint resource
8326
+ After you deploy a model into production using Amazon SageMaker hosting services, your client applications use this API to get inferences from the model hosted at the specified endpoint in an asynchronous manner.
8199
8327
 
8200
8328
  Parameters:
8201
8329
  input_location: The Amazon S3 URI where the inference request payload is stored.
@@ -8205,9 +8333,11 @@ class Endpoint(Base):
8205
8333
  inference_id: The identifier for the inference request. Amazon SageMaker will generate an identifier for you if none is specified.
8206
8334
  request_ttl_seconds: Maximum age in seconds a request can be in the queue before it is marked as expired. The default is 6 hours, or 21,600 seconds.
8207
8335
  invocation_timeout_seconds: Maximum amount of time in seconds a request can be processed before it is marked as expired. The default is 15 minutes, or 900 seconds.
8336
+ session: Boto3 session.
8337
+ region: Region name.
8208
8338
 
8209
8339
  Returns:
8210
- The Invoke response.
8340
+ InvokeEndpointAsyncOutput
8211
8341
 
8212
8342
  Raises:
8213
8343
  botocore.exceptions.ClientError: This exception is raised for AWS service related errors.
@@ -8219,14 +8349,11 @@ class Endpoint(Base):
8219
8349
  error_message = e.response['Error']['Message']
8220
8350
  error_code = e.response['Error']['Code']
8221
8351
  ```
8222
- InternalFailure: An internal failure occurred.
8223
- ServiceUnavailable: The service is unavailable. Try your call again.
8224
- ValidationError: Inspect your request and try again.
8352
+ InternalFailure: An internal failure occurred. Try your request again. If the problem persists, contact Amazon Web Services customer support.
8353
+ ServiceUnavailable: The service is currently unavailable.
8354
+ ValidationError: There was an error validating your request.
8225
8355
  """
8226
8356
 
8227
- logger.info(f"Invoking endpoint resource Async.")
8228
- client = SageMakerRuntimeClient(service_name="sagemaker-runtime").client
8229
-
8230
8357
  operation_input_args = {
8231
8358
  "EndpointName": self.endpoint_name,
8232
8359
  "ContentType": content_type,
@@ -8237,16 +8364,20 @@ class Endpoint(Base):
8237
8364
  "RequestTTLSeconds": request_ttl_seconds,
8238
8365
  "InvocationTimeoutSeconds": invocation_timeout_seconds,
8239
8366
  }
8240
- logger.debug(f"Input request: {operation_input_args}")
8241
8367
  # serialize the input request
8242
8368
  operation_input_args = serialize(operation_input_args)
8243
8369
  logger.debug(f"Serialized input request: {operation_input_args}")
8244
8370
 
8245
- # create the resource
8371
+ client = Base.get_sagemaker_client(
8372
+ session=session, region_name=region, service_name="sagemaker-runtime"
8373
+ )
8374
+
8375
+ logger.debug(f"Calling invoke_endpoint_async API")
8246
8376
  response = client.invoke_endpoint_async(**operation_input_args)
8247
8377
  logger.debug(f"Response: {response}")
8248
8378
 
8249
- return response
8379
+ transformed_response = transform(response, "InvokeEndpointAsyncOutput")
8380
+ return InvokeEndpointAsyncOutput(**transformed_response)
8250
8381
 
8251
8382
  @Base.add_validate_call
8252
8383
  def invoke_with_response_stream(
@@ -8259,9 +8390,12 @@ class Endpoint(Base):
8259
8390
  target_container_hostname: Optional[str] = Unassigned(),
8260
8391
  inference_id: Optional[str] = Unassigned(),
8261
8392
  inference_component_name: Optional[str] = Unassigned(),
8262
- ) -> Optional[object]:
8393
+ session_id: Optional[str] = Unassigned(),
8394
+ session: Optional[Session] = None,
8395
+ region: Optional[str] = None,
8396
+ ) -> Optional[InvokeEndpointWithResponseStreamOutput]:
8263
8397
  """
8264
- Invoke with response stream a Endpoint resource
8398
+ Invokes a model at the specified endpoint to return the inference response as a stream.
8265
8399
 
8266
8400
  Parameters:
8267
8401
  body: Provides input data, in the format specified in the ContentType request header. Amazon SageMaker passes all of the data in the body to the model. For information about the format of the request body, see Common Data Formats-Inference.
@@ -8272,9 +8406,12 @@ class Endpoint(Base):
8272
8406
  target_container_hostname: If the endpoint hosts multiple containers and is configured to use direct invocation, this parameter specifies the host name of the container to invoke.
8273
8407
  inference_id: An identifier that you assign to your request.
8274
8408
  inference_component_name: If the endpoint hosts one or more inference components, this parameter specifies the name of inference component to invoke for a streaming response.
8409
+ session_id: The ID of a stateful session to handle your request. You can't create a stateful session by using the InvokeEndpointWithResponseStream action. Instead, you can create one by using the InvokeEndpoint action. In your request, you specify NEW_SESSION for the SessionId request parameter. The response to that request provides the session ID for the NewSessionId response parameter.
8410
+ session: Boto3 session.
8411
+ region: Region name.
8275
8412
 
8276
8413
  Returns:
8277
- The Invoke response.
8414
+ InvokeEndpointWithResponseStreamOutput
8278
8415
 
8279
8416
  Raises:
8280
8417
  botocore.exceptions.ClientError: This exception is raised for AWS service related errors.
@@ -8286,17 +8423,14 @@ class Endpoint(Base):
8286
8423
  error_message = e.response['Error']['Message']
8287
8424
  error_code = e.response['Error']['Code']
8288
8425
  ```
8289
- InternalFailure: An internal failure occurred.
8426
+ InternalFailure: An internal failure occurred. Try your request again. If the problem persists, contact Amazon Web Services customer support.
8290
8427
  InternalStreamFailure: The stream processing failed because of an unknown error, exception or failure. Try your request again.
8291
8428
  ModelError: Model (owned by the customer in the container) returned 4xx or 5xx error code.
8292
8429
  ModelStreamError: An error occurred while streaming the response body. This error can have the following error codes: ModelInvocationTimeExceeded The model failed to finish sending the response within the timeout period allowed by Amazon SageMaker. StreamBroken The Transmission Control Protocol (TCP) connection between the client and the model was reset or closed.
8293
- ServiceUnavailable: The service is unavailable. Try your call again.
8294
- ValidationError: Inspect your request and try again.
8430
+ ServiceUnavailable: The service is currently unavailable.
8431
+ ValidationError: There was an error validating your request.
8295
8432
  """
8296
8433
 
8297
- logger.info(f"Invoking endpoint resource with Response Stream.")
8298
- client = SageMakerRuntimeClient(service_name="sagemaker-runtime").client
8299
-
8300
8434
  operation_input_args = {
8301
8435
  "EndpointName": self.endpoint_name,
8302
8436
  "Body": body,
@@ -8307,137 +8441,23 @@ class Endpoint(Base):
8307
8441
  "TargetContainerHostname": target_container_hostname,
8308
8442
  "InferenceId": inference_id,
8309
8443
  "InferenceComponentName": inference_component_name,
8310
- }
8311
- logger.debug(f"Input request: {operation_input_args}")
8312
- # serialize the input request
8313
- operation_input_args = serialize(operation_input_args)
8314
- logger.debug(f"Serialized input request: {operation_input_args}")
8315
-
8316
- # create the resource
8317
- response = client.invoke_endpoint_with_response_stream(**operation_input_args)
8318
- logger.debug(f"Response: {response}")
8319
-
8320
- return response
8321
-
8322
- @classmethod
8323
- @Base.add_validate_call
8324
- def get_all(
8325
- cls,
8326
- sort_by: Optional[str] = Unassigned(),
8327
- sort_order: Optional[str] = Unassigned(),
8328
- name_contains: Optional[str] = Unassigned(),
8329
- creation_time_before: Optional[datetime.datetime] = Unassigned(),
8330
- creation_time_after: Optional[datetime.datetime] = Unassigned(),
8331
- last_modified_time_before: Optional[datetime.datetime] = Unassigned(),
8332
- last_modified_time_after: Optional[datetime.datetime] = Unassigned(),
8333
- status_equals: Optional[str] = Unassigned(),
8334
- session: Optional[Session] = None,
8335
- region: Optional[str] = None,
8336
- ) -> ResourceIterator["Endpoint"]:
8337
- """
8338
- Get all Endpoint resources
8339
-
8340
- Parameters:
8341
- sort_by: Sorts the list of results. The default is CreationTime.
8342
- sort_order: The sort order for results. The default is Descending.
8343
- next_token: If the result of a ListEndpoints request was truncated, the response includes a NextToken. To retrieve the next set of endpoints, use the token in the next request.
8344
- max_results: The maximum number of endpoints to return in the response. This value defaults to 10.
8345
- name_contains: A string in endpoint names. This filter returns only endpoints whose name contains the specified string.
8346
- creation_time_before: A filter that returns only endpoints that were created before the specified time (timestamp).
8347
- creation_time_after: A filter that returns only endpoints with a creation time greater than or equal to the specified time (timestamp).
8348
- last_modified_time_before: A filter that returns only endpoints that were modified before the specified timestamp.
8349
- last_modified_time_after: A filter that returns only endpoints that were modified after the specified timestamp.
8350
- status_equals: A filter that returns only endpoints with the specified status.
8351
- session: Boto3 session.
8352
- region: Region name.
8353
-
8354
- Returns:
8355
- Iterator for listed Endpoint resources.
8356
-
8357
- Raises:
8358
- botocore.exceptions.ClientError: This exception is raised for AWS service related errors.
8359
- The error message and error code can be parsed from the exception as follows:
8360
- ```
8361
- try:
8362
- # AWS service call here
8363
- except botocore.exceptions.ClientError as e:
8364
- error_message = e.response['Error']['Message']
8365
- error_code = e.response['Error']['Code']
8366
- ```
8367
- """
8368
-
8369
- client = Base.get_sagemaker_client(
8370
- session=session, region_name=region, service_name="sagemaker"
8371
- )
8372
-
8373
- operation_input_args = {
8374
- "SortBy": sort_by,
8375
- "SortOrder": sort_order,
8376
- "NameContains": name_contains,
8377
- "CreationTimeBefore": creation_time_before,
8378
- "CreationTimeAfter": creation_time_after,
8379
- "LastModifiedTimeBefore": last_modified_time_before,
8380
- "LastModifiedTimeAfter": last_modified_time_after,
8381
- "StatusEquals": status_equals,
8382
- }
8383
-
8384
- # serialize the input request
8385
- operation_input_args = serialize(operation_input_args)
8386
- logger.debug(f"Serialized input request: {operation_input_args}")
8387
-
8388
- return ResourceIterator(
8389
- client=client,
8390
- list_method="list_endpoints",
8391
- summaries_key="Endpoints",
8392
- summary_name="EndpointSummary",
8393
- resource_cls=Endpoint,
8394
- list_method_kwargs=operation_input_args,
8395
- )
8396
-
8397
- @Base.add_validate_call
8398
- def update_weights_and_capacities(
8399
- self,
8400
- desired_weights_and_capacities: List[DesiredWeightAndCapacity],
8401
- session: Optional[Session] = None,
8402
- region: Optional[str] = None,
8403
- ) -> None:
8404
- """
8405
- Updates variant weight of one or more variants associated with an existing endpoint, or capacity of one variant associated with an existing endpoint.
8406
-
8407
- Parameters:
8408
- desired_weights_and_capacities: An object that provides new capacity and weight values for a variant.
8409
- session: Boto3 session.
8410
- region: Region name.
8411
-
8412
- Raises:
8413
- botocore.exceptions.ClientError: This exception is raised for AWS service related errors.
8414
- The error message and error code can be parsed from the exception as follows:
8415
- ```
8416
- try:
8417
- # AWS service call here
8418
- except botocore.exceptions.ClientError as e:
8419
- error_message = e.response['Error']['Message']
8420
- error_code = e.response['Error']['Code']
8421
- ```
8422
- ResourceLimitExceeded: You have exceeded an SageMaker resource limit. For example, you might have too many training jobs created.
8423
- """
8424
-
8425
- operation_input_args = {
8426
- "EndpointName": self.endpoint_name,
8427
- "DesiredWeightsAndCapacities": desired_weights_and_capacities,
8444
+ "SessionId": session_id,
8428
8445
  }
8429
8446
  # serialize the input request
8430
8447
  operation_input_args = serialize(operation_input_args)
8431
8448
  logger.debug(f"Serialized input request: {operation_input_args}")
8432
8449
 
8433
8450
  client = Base.get_sagemaker_client(
8434
- session=session, region_name=region, service_name="sagemaker"
8451
+ session=session, region_name=region, service_name="sagemaker-runtime"
8435
8452
  )
8436
8453
 
8437
- logger.debug(f"Calling update_endpoint_weights_and_capacities API")
8438
- response = client.update_endpoint_weights_and_capacities(**operation_input_args)
8454
+ logger.debug(f"Calling invoke_endpoint_with_response_stream API")
8455
+ response = client.invoke_endpoint_with_response_stream(**operation_input_args)
8439
8456
  logger.debug(f"Response: {response}")
8440
8457
 
8458
+ transformed_response = transform(response, "InvokeEndpointWithResponseStreamOutput")
8459
+ return InvokeEndpointWithResponseStreamOutput(**transformed_response)
8460
+
8441
8461
 
8442
8462
  class EndpointConfig(Base):
8443
8463
  """
@@ -9677,6 +9697,230 @@ class FeatureGroup(Base):
9677
9697
  list_method_kwargs=operation_input_args,
9678
9698
  )
9679
9699
 
9700
+ @Base.add_validate_call
9701
+ def get_record(
9702
+ self,
9703
+ record_identifier_value_as_string: str,
9704
+ feature_names: Optional[List[str]] = Unassigned(),
9705
+ expiration_time_response: Optional[str] = Unassigned(),
9706
+ session: Optional[Session] = None,
9707
+ region: Optional[str] = None,
9708
+ ) -> Optional[GetRecordResponse]:
9709
+ """
9710
+ Use for OnlineStore serving from a FeatureStore.
9711
+
9712
+ Parameters:
9713
+ record_identifier_value_as_string: The value that corresponds to RecordIdentifier type and uniquely identifies the record in the FeatureGroup.
9714
+ feature_names: List of names of Features to be retrieved. If not specified, the latest value for all the Features are returned.
9715
+ expiration_time_response: Parameter to request ExpiresAt in response. If Enabled, GetRecord will return the value of ExpiresAt, if it is not null. If Disabled and null, GetRecord will return null.
9716
+ session: Boto3 session.
9717
+ region: Region name.
9718
+
9719
+ Returns:
9720
+ GetRecordResponse
9721
+
9722
+ Raises:
9723
+ botocore.exceptions.ClientError: This exception is raised for AWS service related errors.
9724
+ The error message and error code can be parsed from the exception as follows:
9725
+ ```
9726
+ try:
9727
+ # AWS service call here
9728
+ except botocore.exceptions.ClientError as e:
9729
+ error_message = e.response['Error']['Message']
9730
+ error_code = e.response['Error']['Code']
9731
+ ```
9732
+ AccessForbidden: You do not have permission to perform an action.
9733
+ InternalFailure: An internal failure occurred. Try your request again. If the problem persists, contact Amazon Web Services customer support.
9734
+ ResourceNotFound: Resource being access is not found.
9735
+ ServiceUnavailable: The service is currently unavailable.
9736
+ ValidationError: There was an error validating your request.
9737
+ """
9738
+
9739
+ operation_input_args = {
9740
+ "FeatureGroupName": self.feature_group_name,
9741
+ "RecordIdentifierValueAsString": record_identifier_value_as_string,
9742
+ "FeatureNames": feature_names,
9743
+ "ExpirationTimeResponse": expiration_time_response,
9744
+ }
9745
+ # serialize the input request
9746
+ operation_input_args = serialize(operation_input_args)
9747
+ logger.debug(f"Serialized input request: {operation_input_args}")
9748
+
9749
+ client = Base.get_sagemaker_client(
9750
+ session=session, region_name=region, service_name="sagemaker-featurestore-runtime"
9751
+ )
9752
+
9753
+ logger.debug(f"Calling get_record API")
9754
+ response = client.get_record(**operation_input_args)
9755
+ logger.debug(f"Response: {response}")
9756
+
9757
+ transformed_response = transform(response, "GetRecordResponse")
9758
+ return GetRecordResponse(**transformed_response)
9759
+
9760
+ @Base.add_validate_call
9761
+ def put_record(
9762
+ self,
9763
+ record: List[FeatureValue],
9764
+ target_stores: Optional[List[str]] = Unassigned(),
9765
+ ttl_duration: Optional[TtlDuration] = Unassigned(),
9766
+ session: Optional[Session] = None,
9767
+ region: Optional[str] = None,
9768
+ ) -> None:
9769
+ """
9770
+ The PutRecord API is used to ingest a list of Records into your feature group.
9771
+
9772
+ Parameters:
9773
+ record: List of FeatureValues to be inserted. This will be a full over-write. If you only want to update few of the feature values, do the following: Use GetRecord to retrieve the latest record. Update the record returned from GetRecord. Use PutRecord to update feature values.
9774
+ target_stores: A list of stores to which you're adding the record. By default, Feature Store adds the record to all of the stores that you're using for the FeatureGroup.
9775
+ ttl_duration: Time to live duration, where the record is hard deleted after the expiration time is reached; ExpiresAt = EventTime + TtlDuration. For information on HardDelete, see the DeleteRecord API in the Amazon SageMaker API Reference guide.
9776
+ session: Boto3 session.
9777
+ region: Region name.
9778
+
9779
+ Raises:
9780
+ botocore.exceptions.ClientError: This exception is raised for AWS service related errors.
9781
+ The error message and error code can be parsed from the exception as follows:
9782
+ ```
9783
+ try:
9784
+ # AWS service call here
9785
+ except botocore.exceptions.ClientError as e:
9786
+ error_message = e.response['Error']['Message']
9787
+ error_code = e.response['Error']['Code']
9788
+ ```
9789
+ AccessForbidden: You do not have permission to perform an action.
9790
+ InternalFailure: An internal failure occurred. Try your request again. If the problem persists, contact Amazon Web Services customer support.
9791
+ ServiceUnavailable: The service is currently unavailable.
9792
+ ValidationError: There was an error validating your request.
9793
+ """
9794
+
9795
+ operation_input_args = {
9796
+ "FeatureGroupName": self.feature_group_name,
9797
+ "Record": record,
9798
+ "TargetStores": target_stores,
9799
+ "TtlDuration": ttl_duration,
9800
+ }
9801
+ # serialize the input request
9802
+ operation_input_args = serialize(operation_input_args)
9803
+ logger.debug(f"Serialized input request: {operation_input_args}")
9804
+
9805
+ client = Base.get_sagemaker_client(
9806
+ session=session, region_name=region, service_name="sagemaker-featurestore-runtime"
9807
+ )
9808
+
9809
+ logger.debug(f"Calling put_record API")
9810
+ response = client.put_record(**operation_input_args)
9811
+ logger.debug(f"Response: {response}")
9812
+
9813
+ @Base.add_validate_call
9814
+ def delete_record(
9815
+ self,
9816
+ record_identifier_value_as_string: str,
9817
+ event_time: str,
9818
+ target_stores: Optional[List[str]] = Unassigned(),
9819
+ deletion_mode: Optional[str] = Unassigned(),
9820
+ session: Optional[Session] = None,
9821
+ region: Optional[str] = None,
9822
+ ) -> None:
9823
+ """
9824
+ Deletes a Record from a FeatureGroup in the OnlineStore.
9825
+
9826
+ Parameters:
9827
+ record_identifier_value_as_string: The value for the RecordIdentifier that uniquely identifies the record, in string format.
9828
+ event_time: Timestamp indicating when the deletion event occurred. EventTime can be used to query data at a certain point in time.
9829
+ target_stores: A list of stores from which you're deleting the record. By default, Feature Store deletes the record from all of the stores that you're using for the FeatureGroup.
9830
+ deletion_mode: The name of the deletion mode for deleting the record. By default, the deletion mode is set to SoftDelete.
9831
+ session: Boto3 session.
9832
+ region: Region name.
9833
+
9834
+ Raises:
9835
+ botocore.exceptions.ClientError: This exception is raised for AWS service related errors.
9836
+ The error message and error code can be parsed from the exception as follows:
9837
+ ```
9838
+ try:
9839
+ # AWS service call here
9840
+ except botocore.exceptions.ClientError as e:
9841
+ error_message = e.response['Error']['Message']
9842
+ error_code = e.response['Error']['Code']
9843
+ ```
9844
+ AccessForbidden: You do not have permission to perform an action.
9845
+ InternalFailure: An internal failure occurred. Try your request again. If the problem persists, contact Amazon Web Services customer support.
9846
+ ServiceUnavailable: The service is currently unavailable.
9847
+ ValidationError: There was an error validating your request.
9848
+ """
9849
+
9850
+ operation_input_args = {
9851
+ "FeatureGroupName": self.feature_group_name,
9852
+ "RecordIdentifierValueAsString": record_identifier_value_as_string,
9853
+ "EventTime": event_time,
9854
+ "TargetStores": target_stores,
9855
+ "DeletionMode": deletion_mode,
9856
+ }
9857
+ # serialize the input request
9858
+ operation_input_args = serialize(operation_input_args)
9859
+ logger.debug(f"Serialized input request: {operation_input_args}")
9860
+
9861
+ client = Base.get_sagemaker_client(
9862
+ session=session, region_name=region, service_name="sagemaker-featurestore-runtime"
9863
+ )
9864
+
9865
+ logger.debug(f"Calling delete_record API")
9866
+ response = client.delete_record(**operation_input_args)
9867
+ logger.debug(f"Response: {response}")
9868
+
9869
+ @Base.add_validate_call
9870
+ def batch_get_record(
9871
+ self,
9872
+ identifiers: List[BatchGetRecordIdentifier],
9873
+ expiration_time_response: Optional[str] = Unassigned(),
9874
+ session: Optional[Session] = None,
9875
+ region: Optional[str] = None,
9876
+ ) -> Optional[BatchGetRecordResponse]:
9877
+ """
9878
+ Retrieves a batch of Records from a FeatureGroup.
9879
+
9880
+ Parameters:
9881
+ identifiers: A list containing the name or Amazon Resource Name (ARN) of the FeatureGroup, the list of names of Features to be retrieved, and the corresponding RecordIdentifier values as strings.
9882
+ expiration_time_response: Parameter to request ExpiresAt in response. If Enabled, BatchGetRecord will return the value of ExpiresAt, if it is not null. If Disabled and null, BatchGetRecord will return null.
9883
+ session: Boto3 session.
9884
+ region: Region name.
9885
+
9886
+ Returns:
9887
+ BatchGetRecordResponse
9888
+
9889
+ Raises:
9890
+ botocore.exceptions.ClientError: This exception is raised for AWS service related errors.
9891
+ The error message and error code can be parsed from the exception as follows:
9892
+ ```
9893
+ try:
9894
+ # AWS service call here
9895
+ except botocore.exceptions.ClientError as e:
9896
+ error_message = e.response['Error']['Message']
9897
+ error_code = e.response['Error']['Code']
9898
+ ```
9899
+ AccessForbidden: You do not have permission to perform an action.
9900
+ InternalFailure: An internal failure occurred. Try your request again. If the problem persists, contact Amazon Web Services customer support.
9901
+ ServiceUnavailable: The service is currently unavailable.
9902
+ ValidationError: There was an error validating your request.
9903
+ """
9904
+
9905
+ operation_input_args = {
9906
+ "Identifiers": identifiers,
9907
+ "ExpirationTimeResponse": expiration_time_response,
9908
+ }
9909
+ # serialize the input request
9910
+ operation_input_args = serialize(operation_input_args)
9911
+ logger.debug(f"Serialized input request: {operation_input_args}")
9912
+
9913
+ client = Base.get_sagemaker_client(
9914
+ session=session, region_name=region, service_name="sagemaker-featurestore-runtime"
9915
+ )
9916
+
9917
+ logger.debug(f"Calling batch_get_record API")
9918
+ response = client.batch_get_record(**operation_input_args)
9919
+ logger.debug(f"Response: {response}")
9920
+
9921
+ transformed_response = transform(response, "BatchGetRecordResponse")
9922
+ return BatchGetRecordResponse(**transformed_response)
9923
+
9680
9924
 
9681
9925
  class FeatureMetadata(Base):
9682
9926
  """
@@ -27666,6 +27910,49 @@ class TrialComponent(Base):
27666
27910
  response = client.disassociate_trial_component(**operation_input_args)
27667
27911
  logger.debug(f"Response: {response}")
27668
27912
 
27913
+ @Base.add_validate_call
27914
+ def batch_put_metrics(
27915
+ self,
27916
+ metric_data: List[RawMetricData],
27917
+ session: Optional[Session] = None,
27918
+ region: Optional[str] = None,
27919
+ ) -> None:
27920
+ """
27921
+ Used to ingest training metrics into SageMaker.
27922
+
27923
+ Parameters:
27924
+ metric_data: A list of raw metric values to put.
27925
+ session: Boto3 session.
27926
+ region: Region name.
27927
+
27928
+ Raises:
27929
+ botocore.exceptions.ClientError: This exception is raised for AWS service related errors.
27930
+ The error message and error code can be parsed from the exception as follows:
27931
+ ```
27932
+ try:
27933
+ # AWS service call here
27934
+ except botocore.exceptions.ClientError as e:
27935
+ error_message = e.response['Error']['Message']
27936
+ error_code = e.response['Error']['Code']
27937
+ ```
27938
+ """
27939
+
27940
+ operation_input_args = {
27941
+ "TrialComponentName": self.trial_component_name,
27942
+ "MetricData": metric_data,
27943
+ }
27944
+ # serialize the input request
27945
+ operation_input_args = serialize(operation_input_args)
27946
+ logger.debug(f"Serialized input request: {operation_input_args}")
27947
+
27948
+ client = Base.get_sagemaker_client(
27949
+ session=session, region_name=region, service_name="sagemaker-metrics"
27950
+ )
27951
+
27952
+ logger.debug(f"Calling batch_put_metrics API")
27953
+ response = client.batch_put_metrics(**operation_input_args)
27954
+ logger.debug(f"Response: {response}")
27955
+
27669
27956
 
27670
27957
  class UserProfile(Base):
27671
27958
  """