Skip to content

Commit

Permalink
feat(client-sagemaker-runtime): This release adds a new InvokeEndpoin…
Browse files Browse the repository at this point in the history
…tWithResponseStream API to support streaming of model responses.
  • Loading branch information
awstools committed Aug 31, 2023
1 parent 83abe06 commit 2263b20
Show file tree
Hide file tree
Showing 14 changed files with 1,391 additions and 369 deletions.
8 changes: 8 additions & 0 deletions clients/client-sagemaker-runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,11 @@ InvokeEndpointAsync
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-sagemaker-runtime/classes/invokeendpointasynccommand.html) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-sagemaker-runtime/interfaces/invokeendpointasynccommandinput.html) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-sagemaker-runtime/interfaces/invokeendpointasynccommandoutput.html)

</details>
<details>
<summary>
InvokeEndpointWithResponseStream
</summary>

[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-sagemaker-runtime/classes/invokeendpointwithresponsestreamcommand.html) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-sagemaker-runtime/interfaces/invokeendpointwithresponsestreamcommandinput.html) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-sagemaker-runtime/interfaces/invokeendpointwithresponsestreamcommandoutput.html)

</details>
3 changes: 3 additions & 0 deletions clients/client-sagemaker-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
"@aws-sdk/util-user-agent-browser": "*",
"@aws-sdk/util-user-agent-node": "*",
"@smithy/config-resolver": "^2.0.5",
"@smithy/eventstream-serde-browser": "^2.0.5",
"@smithy/eventstream-serde-config-resolver": "^2.0.5",
"@smithy/eventstream-serde-node": "^2.0.5",
"@smithy/fetch-http-handler": "^2.0.5",
"@smithy/hash-node": "^2.0.5",
"@smithy/invalid-dependency": "^2.0.5",
Expand Down
23 changes: 23 additions & 0 deletions clients/client-sagemaker-runtime/src/SageMakerRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ import {
InvokeEndpointCommandInput,
InvokeEndpointCommandOutput,
} from "./commands/InvokeEndpointCommand";
import {
InvokeEndpointWithResponseStreamCommand,
InvokeEndpointWithResponseStreamCommandInput,
InvokeEndpointWithResponseStreamCommandOutput,
} from "./commands/InvokeEndpointWithResponseStreamCommand";
import { SageMakerRuntimeClient, SageMakerRuntimeClientConfig } from "./SageMakerRuntimeClient";

const commands = {
InvokeEndpointCommand,
InvokeEndpointAsyncCommand,
InvokeEndpointWithResponseStreamCommand,
};

export interface SageMakerRuntime {
Expand Down Expand Up @@ -50,6 +56,23 @@ export interface SageMakerRuntime {
options: __HttpHandlerOptions,
cb: (err: any, data?: InvokeEndpointAsyncCommandOutput) => void
): void;

/**
* @see {@link InvokeEndpointWithResponseStreamCommand}
*/
invokeEndpointWithResponseStream(
args: InvokeEndpointWithResponseStreamCommandInput,
options?: __HttpHandlerOptions
): Promise<InvokeEndpointWithResponseStreamCommandOutput>;
invokeEndpointWithResponseStream(
args: InvokeEndpointWithResponseStreamCommandInput,
cb: (err: any, data?: InvokeEndpointWithResponseStreamCommandOutput) => void
): void;
invokeEndpointWithResponseStream(
args: InvokeEndpointWithResponseStreamCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: InvokeEndpointWithResponseStreamCommandOutput) => void
): void;
}

/**
Expand Down
34 changes: 29 additions & 5 deletions clients/client-sagemaker-runtime/src/SageMakerRuntimeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ import {
} from "@aws-sdk/middleware-user-agent";
import { Credentials as __Credentials } from "@aws-sdk/types";
import { RegionInputConfig, RegionResolvedConfig, resolveRegionConfig } from "@smithy/config-resolver";
import {
EventStreamSerdeInputConfig,
EventStreamSerdeResolvedConfig,
resolveEventStreamSerdeConfig,
} from "@smithy/eventstream-serde-config-resolver";
import { getContentLengthPlugin } from "@smithy/middleware-content-length";
import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint";
import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry";
Expand All @@ -39,6 +44,7 @@ import {
Decoder as __Decoder,
Encoder as __Encoder,
EndpointV2 as __EndpointV2,
EventStreamSerdeProvider as __EventStreamSerdeProvider,
Hash as __Hash,
HashConstructor as __HashConstructor,
HttpHandlerOptions as __HttpHandlerOptions,
Expand All @@ -55,6 +61,10 @@ import {
InvokeEndpointAsyncCommandOutput,
} from "./commands/InvokeEndpointAsyncCommand";
import { InvokeEndpointCommandInput, InvokeEndpointCommandOutput } from "./commands/InvokeEndpointCommand";
import {
InvokeEndpointWithResponseStreamCommandInput,
InvokeEndpointWithResponseStreamCommandOutput,
} from "./commands/InvokeEndpointWithResponseStreamCommand";
import {
ClientInputEndpointParameters,
ClientResolvedEndpointParameters,
Expand All @@ -69,12 +79,18 @@ export { __Client };
/**
* @public
*/
export type ServiceInputTypes = InvokeEndpointAsyncCommandInput | InvokeEndpointCommandInput;
export type ServiceInputTypes =
| InvokeEndpointAsyncCommandInput
| InvokeEndpointCommandInput
| InvokeEndpointWithResponseStreamCommandInput;

/**
* @public
*/
export type ServiceOutputTypes = InvokeEndpointAsyncCommandOutput | InvokeEndpointCommandOutput;
export type ServiceOutputTypes =
| InvokeEndpointAsyncCommandOutput
| InvokeEndpointCommandOutput
| InvokeEndpointWithResponseStreamCommandOutput;

/**
* @public
Expand Down Expand Up @@ -199,6 +215,11 @@ export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__
*/
extensions?: RuntimeExtension[];

/**
* The function that provides necessary utilities for generating and parsing event stream
*/
eventStreamSerdeProvider?: __EventStreamSerdeProvider;

/**
* The {@link @smithy/smithy-client#DefaultsMode} that will be used to determine how certain default configuration options are resolved in the SDK.
*/
Expand All @@ -216,6 +237,7 @@ export type SageMakerRuntimeClientConfigType = Partial<__SmithyConfiguration<__H
HostHeaderInputConfig &
AwsAuthInputConfig &
UserAgentInputConfig &
EventStreamSerdeInputConfig &
ClientInputEndpointParameters;
/**
* @public
Expand All @@ -236,6 +258,7 @@ export type SageMakerRuntimeClientResolvedConfigType = __SmithyResolvedConfigura
HostHeaderResolvedConfig &
AwsAuthResolvedConfig &
UserAgentResolvedConfig &
EventStreamSerdeResolvedConfig &
ClientResolvedEndpointParameters;
/**
* @public
Expand Down Expand Up @@ -268,9 +291,10 @@ export class SageMakerRuntimeClient extends __Client<
const _config_5 = resolveHostHeaderConfig(_config_4);
const _config_6 = resolveAwsAuthConfig(_config_5);
const _config_7 = resolveUserAgentConfig(_config_6);
const _config_8 = resolveRuntimeExtensions(_config_7, configuration?.extensions || []);
super(_config_8);
this.config = _config_8;
const _config_8 = resolveEventStreamSerdeConfig(_config_7);
const _config_9 = resolveRuntimeExtensions(_config_8, configuration?.extensions || []);
super(_config_9);
this.config = _config_9;
this.middlewareStack.use(getRetryPlugin(this.config));
this.middlewareStack.use(getContentLengthPlugin(this.config));
this.middlewareStack.use(getHostHeaderPlugin(this.config));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ export interface InvokeEndpointAsyncCommandOutput extends InvokeEndpointAsyncOut

/**
* @public
* <p>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.</p>
* <p>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.</p>
* <p>Inference requests sent to this API are enqueued for asynchronous processing. The
* processing of the inference request may or may not complete before you receive a
* response from this API. The response from this API will not contain the result of the
* inference request but contain information about where you can locate it.</p>
* <p>Amazon SageMaker strips all <code>POST</code> headers except those supported by the API. Amazon SageMaker
* might add additional headers. You should not rely on the behavior of headers outside
* those enumerated in the request syntax.</p>
* <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/AmazonS3/latest/API/sig-v4-authenticating-requests.html">Authenticating Requests (Amazon Web Services Signature Version 4)</a> in the
* <i>Amazon S3 API Reference</i>.</p>
* <p>Amazon SageMaker strips all POST headers except those supported by the API. Amazon SageMaker might add
* additional headers. You should not rely on the behavior of headers outside those
* enumerated in the request syntax. </p>
* <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/AmazonS3/latest/API/sig-v4-authenticating-requests.html">Authenticating
* Requests (Amazon Web Services Signature Version 4)</a> in the <i>Amazon S3 API Reference</i>.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,24 @@ export interface InvokeEndpointCommandOutput extends InvokeEndpointCommandOutput

/**
* @public
* <p>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
* <p>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. </p>
* <p>For an overview of Amazon SageMaker, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/how-it-works.html">How It Works</a>. </p>
* <p>Amazon SageMaker strips all POST headers except those supported by the API. Amazon SageMaker might add
* additional headers. You should not rely on the behavior of headers outside those
* enumerated in the request syntax. </p>
* additional headers. You should not rely on the behavior of headers outside those
* enumerated in the request syntax. </p>
* <p>Calls to <code>InvokeEndpoint</code> are authenticated by using Amazon Web Services
* Signature Version 4. For information, see <a href="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
* Reference</i>.</p>
* Requests (Amazon Web Services Signature Version 4)</a> in the <i>Amazon S3 API Reference</i>.</p>
* <p>A customer's model containers must respond to requests within 60 seconds. The model
* itself can have a maximum processing time of 60 seconds before responding to
* invocations. If your model is going to take 50-60 seconds of processing time, the SDK
* socket timeout should be set to be 70 seconds.</p>
* <note>
* <p>Endpoints are scoped to an individual account, and are not public. The URL does
* not contain the account ID, but Amazon SageMaker determines the account ID from the
* authentication token that is supplied by the caller.</p>
* not contain the account ID, but Amazon SageMaker determines the account ID from
* the authentication token that is supplied by the caller.</p>
* </note>
* @example
* Use a bare-bones client and the command you need to make an API call.
Expand Down
Loading

0 comments on commit 2263b20

Please sign in to comment.