Skip to content

Commit 4ad08ad

Browse files
author
awstools
committed
feat(client-sagemaker-runtime): A new parameter called EnableExplanations is added to InvokeEndpoint API to enable on-demand SageMaker Clarify online explainability requests.
1 parent c26a733 commit 4ad08ad

File tree

6 files changed

+113
-87
lines changed

6 files changed

+113
-87
lines changed

clients/client-sagemaker-runtime/src/SageMakerRuntime.ts

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export class SageMakerRuntime extends SageMakerRuntimeClient {
2525
* <p>Amazon SageMaker strips all POST headers except those supported by the API. Amazon SageMaker might add
2626
* additional headers. You should not rely on the behavior of headers outside those
2727
* enumerated in the request syntax. </p>
28-
* <p>Calls to <code>InvokeEndpoint</code> are authenticated by using Amazon Web Services Signature Version
29-
* 4. For information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html">Authenticating
28+
* <p>Calls to <code>InvokeEndpoint</code> are authenticated by using Amazon Web Services
29+
* Signature Version 4. For information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html">Authenticating
3030
* Requests (Amazon Web Services Signature Version 4)</a> in the <i>Amazon S3 API
3131
* Reference</i>.</p>
3232
* <p>A customer's model containers must respond to requests within 60 seconds. The model
@@ -69,23 +69,21 @@ export class SageMakerRuntime extends SageMakerRuntimeClient {
6969
}
7070

7171
/**
72-
* <p>After you deploy a model into production using Amazon SageMaker hosting services,
73-
* your client applications use this API to get inferences from the model hosted at
74-
* the specified endpoint in an asynchronous manner.</p>
72+
* <p>After you deploy a model into production using Amazon SageMaker hosting services, your client
73+
* applications use this API to get inferences from the model hosted at the specified
74+
* endpoint in an asynchronous manner.</p>
7575
*
76-
* <p>Inference requests sent to this API are enqueued for asynchronous processing.
77-
* The processing of the inference request may or may not complete before the
78-
* you receive a response from this API. The response from this API will
79-
* not contain the result of the inference request but contain information
80-
* about where you can locate it.</p>
76+
* <p>Inference requests sent to this API are enqueued for asynchronous processing. The
77+
* processing of the inference request may or may not complete before the you receive a
78+
* response from this API. The response from this API will not contain the result of the
79+
* inference request but contain information about where you can locate it.</p>
8180
*
82-
* <p>Amazon SageMaker strips all <code>POST</code> headers except those supported by the API.
83-
* Amazon SageMaker might add additional headers. You should not rely on the behavior
84-
* of headers outside those enumerated in the request syntax.</p>
81+
* <p>Amazon SageMaker strips all <code>POST</code> headers except those supported by the API. Amazon SageMaker
82+
* might add additional headers. You should not rely on the behavior of headers outside
83+
* those enumerated in the request syntax.</p>
8584
*
86-
* <p>Calls to <code>InvokeEndpointAsync</code> are authenticated by using Amazon Web Services Signature
87-
* Version 4. For information, see <a href="https://docs.aws.amazon.com/https:/docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html">Authenticating Requests (Amazon Web Services Signature Version 4)</a> in the <i>Amazon S3 API
88-
* Reference</i>.</p>
85+
* <p>Calls to <code>InvokeEndpointAsync</code> are authenticated by using Amazon Web Services Signature Version 4. For information, see <a href="https://docs.aws.amazon.com/https:/docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html">Authenticating Requests (Amazon Web Services Signature Version 4)</a> in the
86+
* <i>Amazon S3 API Reference</i>.</p>
8987
*/
9088
public invokeEndpointAsync(
9189
args: InvokeEndpointAsyncCommandInput,

clients/client-sagemaker-runtime/src/commands/InvokeEndpointAsyncCommand.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,21 @@ export interface InvokeEndpointAsyncCommandInput extends InvokeEndpointAsyncInpu
2828
export interface InvokeEndpointAsyncCommandOutput extends InvokeEndpointAsyncOutput, __MetadataBearer {}
2929

3030
/**
31-
* <p>After you deploy a model into production using Amazon SageMaker hosting services,
32-
* your client applications use this API to get inferences from the model hosted at
33-
* the specified endpoint in an asynchronous manner.</p>
31+
* <p>After you deploy a model into production using Amazon SageMaker hosting services, your client
32+
* applications use this API to get inferences from the model hosted at the specified
33+
* endpoint in an asynchronous manner.</p>
3434
*
35-
* <p>Inference requests sent to this API are enqueued for asynchronous processing.
36-
* The processing of the inference request may or may not complete before the
37-
* you receive a response from this API. The response from this API will
38-
* not contain the result of the inference request but contain information
39-
* about where you can locate it.</p>
35+
* <p>Inference requests sent to this API are enqueued for asynchronous processing. The
36+
* processing of the inference request may or may not complete before the you receive a
37+
* response from this API. The response from this API will not contain the result of the
38+
* inference request but contain information about where you can locate it.</p>
4039
*
41-
* <p>Amazon SageMaker strips all <code>POST</code> headers except those supported by the API.
42-
* Amazon SageMaker might add additional headers. You should not rely on the behavior
43-
* of headers outside those enumerated in the request syntax.</p>
40+
* <p>Amazon SageMaker strips all <code>POST</code> headers except those supported by the API. Amazon SageMaker
41+
* might add additional headers. You should not rely on the behavior of headers outside
42+
* those enumerated in the request syntax.</p>
4443
*
45-
* <p>Calls to <code>InvokeEndpointAsync</code> are authenticated by using Amazon Web Services Signature
46-
* Version 4. For information, see <a href="https://docs.aws.amazon.com/https:/docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html">Authenticating Requests (Amazon Web Services Signature Version 4)</a> in the <i>Amazon S3 API
47-
* Reference</i>.</p>
44+
* <p>Calls to <code>InvokeEndpointAsync</code> are authenticated by using Amazon Web Services Signature Version 4. For information, see <a href="https://docs.aws.amazon.com/https:/docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html">Authenticating Requests (Amazon Web Services Signature Version 4)</a> in the
45+
* <i>Amazon S3 API Reference</i>.</p>
4846
* @example
4947
* Use a bare-bones client and the command you need to make an API call.
5048
* ```javascript

clients/client-sagemaker-runtime/src/commands/InvokeEndpointCommand.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ export interface InvokeEndpointCommandOutput extends InvokeEndpointOutput, __Met
3535
* <p>Amazon SageMaker strips all POST headers except those supported by the API. Amazon SageMaker might add
3636
* additional headers. You should not rely on the behavior of headers outside those
3737
* enumerated in the request syntax. </p>
38-
* <p>Calls to <code>InvokeEndpoint</code> are authenticated by using Amazon Web Services Signature Version
39-
* 4. For information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html">Authenticating
38+
* <p>Calls to <code>InvokeEndpoint</code> are authenticated by using Amazon Web Services
39+
* Signature Version 4. For information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html">Authenticating
4040
* Requests (Amazon Web Services Signature Version 4)</a> in the <i>Amazon S3 API
4141
* Reference</i>.</p>
4242
* <p>A customer's model containers must respond to requests within 60 seconds. The model

clients/client-sagemaker-runtime/src/models/models_0.ts

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { ExceptionOptionType as __ExceptionOptionType, SENSITIVE_STRING } from "
44
import { SageMakerRuntimeServiceException as __BaseException } from "./SageMakerRuntimeServiceException";
55

66
/**
7-
* <p>Your request caused an exception with an internal dependency. Contact customer support. </p>
7+
* <p>Your request caused an exception with an internal dependency. Contact customer
8+
* support. </p>
89
*/
910
export class InternalDependencyException extends __BaseException {
1011
readonly name: "InternalDependencyException" = "InternalDependencyException";
@@ -84,8 +85,8 @@ export interface InvokeEndpointInput {
8485
* prepend the custom attribute with <code>Trace ID:</code> in your post-processing
8586
* function.</p>
8687
*
87-
* <p>This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker Python
88-
* SDK.</p>
88+
* <p>This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker
89+
* Python SDK.</p>
8990
*/
9091
CustomAttributes?: string;
9192

@@ -117,13 +118,23 @@ export interface InvokeEndpointInput {
117118
* Data</a>.</p>
118119
*/
119120
InferenceId?: string;
121+
122+
/**
123+
* <p>An optional JMESPath expression used to override the <code>EnableExplanations</code>
124+
* parameter of the <code>ClarifyExplainerConfig</code> API. See the <a href="https://docs.aws.amazon.com/clarify-online-explainability-create-endpoint.html#clarify-online-exaplainability-create-endpoint-enable">EnableExplanations</a> section in the developer guide for more information.
125+
* </p>
126+
*/
127+
EnableExplanations?: string;
120128
}
121129

122130
export interface InvokeEndpointOutput {
123131
/**
124-
* <p>Includes the inference provided by the model.</p>
132+
* <p>Includes the inference provided by the model. </p>
125133
* <p>For information about the format of the response body, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-inference.html">Common Data
126134
* Formats-Inference</a>.</p>
135+
* <p>If the explainer is activated, the
136+
* body includes the explanations provided by the model. For more information, see the
137+
* <b>Response section</b> under <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-online-explainability-invoke-endpoint.html#clarify-online-explainability-response">Invoke the Endpoint</a> in the Developer Guide.</p>
127138
*/
128139
Body: Uint8Array | undefined;
129140

@@ -152,8 +163,8 @@ export interface InvokeEndpointOutput {
152163
* returned. For example, if a custom attribute represents the trace ID, your model can
153164
* prepend the custom attribute with <code>Trace ID:</code> in your post-processing
154165
* function.</p>
155-
* <p>This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker Python
156-
* SDK.</p>
166+
* <p>This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker
167+
* Python SDK.</p>
157168
*/
158169
CustomAttributes?: string;
159170
}
@@ -198,7 +209,9 @@ export class ModelError extends __BaseException {
198209
}
199210

200211
/**
201-
* <p>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.</p>
212+
* <p>Either a serverless endpoint variant's resources are still being provisioned, or a
213+
* multi-model endpoint is still downloading or loading the target model. Wait and try your
214+
* request again.</p>
202215
*/
203216
export class ModelNotReadyException extends __BaseException {
204217
readonly name: "ModelNotReadyException" = "ModelNotReadyException";
@@ -262,8 +275,8 @@ export class ValidationError extends __BaseException {
262275

263276
export interface InvokeEndpointAsyncInput {
264277
/**
265-
* <p>The name of the endpoint that you specified when you created the endpoint using
266-
* the <a href="https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateEndpoint.html">
278+
* <p>The name of the endpoint that you specified when you created the endpoint using the
279+
* <a href="https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateEndpoint.html">
267280
* <code>CreateEndpoint</code>
268281
* </a> API.</p>
269282
*/
@@ -280,27 +293,28 @@ export interface InvokeEndpointAsyncInput {
280293
Accept?: string;
281294

282295
/**
283-
* <p>Provides additional information about a request for an inference submitted to
284-
* a model hosted at an Amazon SageMaker endpoint. The information is an opaque value that is
285-
* forwarded verbatim. You could use this value, for example, to provide an ID that you
286-
* can use to track a request or to provide other metadata that a service endpoint was
287-
* programmed to process. The value must consist of no more than 1024
288-
* visible US-ASCII characters as specified in
289-
* <a href="https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.6">Section 3.3.6.
290-
* Field Value Components</a> of the Hypertext Transfer Protocol (HTTP/1.1). </p>
296+
* <p>Provides additional information about a request for an inference submitted to a model
297+
* hosted at an Amazon SageMaker endpoint. The information is an opaque value that is forwarded
298+
* verbatim. You could use this value, for example, to provide an ID that you can use to
299+
* track a request or to provide other metadata that a service endpoint was programmed to
300+
* process. The value must consist of no more than 1024 visible US-ASCII characters as
301+
* specified in <a href="https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.6">Section 3.3.6. Field Value Components</a> of the Hypertext Transfer Protocol
302+
* (HTTP/1.1). </p>
291303
*
292-
* <p>The code in your model is responsible for setting or updating any custom attributes
293-
* in the response. If your code does not set this value in the response, an empty
294-
* value is returned. For example, if a custom attribute represents the trace ID,
295-
* your model can prepend the custom attribute with <code>Trace ID</code>: in your post-processing function. </p>
304+
* <p>The code in your model is responsible for setting or updating any custom attributes in
305+
* the response. If your code does not set this value in the response, an empty value is
306+
* returned. For example, if a custom attribute represents the trace ID, your model can
307+
* prepend the custom attribute with <code>Trace ID</code>: in your post-processing
308+
* function. </p>
296309
*
297-
* <p>This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker Python SDK. </p>
310+
* <p>This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker
311+
* Python SDK. </p>
298312
*/
299313
CustomAttributes?: string;
300314

301315
/**
302-
* <p>The identifier for the inference request. Amazon SageMaker will generate an identifier for you
303-
* if none is specified. </p>
316+
* <p>The identifier for the inference request. Amazon SageMaker will generate an identifier for you if
317+
* none is specified. </p>
304318
*/
305319
InferenceId?: string;
306320

@@ -310,15 +324,17 @@ export interface InvokeEndpointAsyncInput {
310324
InputLocation: string | undefined;
311325

312326
/**
313-
* <p>Maximum age in seconds a request can be in the queue before it is marked as expired.</p>
327+
* <p>Maximum age in seconds a request can be in the queue before it is marked as
328+
* expired.</p>
314329
*/
315330
RequestTTLSeconds?: number;
316331
}
317332

318333
export interface InvokeEndpointAsyncOutput {
319334
/**
320-
* <p>Identifier for an inference request. This will be the same as the <code>InferenceId</code> specified
321-
* in the input. Amazon SageMaker will generate an identifier for you if you do not specify one.</p>
335+
* <p>Identifier for an inference request. This will be the same as the
336+
* <code>InferenceId</code> specified in the input. Amazon SageMaker will generate an identifier
337+
* for you if you do not specify one.</p>
322338
*/
323339
InferenceId?: string;
324340

clients/client-sagemaker-runtime/src/protocols/Aws_restJson1.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export const serializeAws_restJson1InvokeEndpointCommand = async (
4444
"x-amzn-sagemaker-target-variant": input.TargetVariant!,
4545
"x-amzn-sagemaker-target-container-hostname": input.TargetContainerHostname!,
4646
"x-amzn-sagemaker-inference-id": input.InferenceId!,
47+
"x-amzn-sagemaker-enable-explanations": input.EnableExplanations!,
4748
});
4849
let resolvedPath =
4950
`${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/endpoints/{EndpointName}/invocations";

0 commit comments

Comments
 (0)