Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWSSageMakerRuntime Update models to latest #5103

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 135 additions & 7 deletions AWSSageMakerRuntime/AWSSageMakerRuntimeModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ typedef NS_ENUM(NSInteger, AWSSageMakerRuntimeErrorType) {
AWSSageMakerRuntimeErrorUnknown,
AWSSageMakerRuntimeErrorInternalDependency,
AWSSageMakerRuntimeErrorInternalFailure,
AWSSageMakerRuntimeErrorInternalStreamFailure,
AWSSageMakerRuntimeErrorModel,
AWSSageMakerRuntimeErrorModelNotReady,
AWSSageMakerRuntimeErrorModelStream,
AWSSageMakerRuntimeErrorServiceUnavailable,
AWSSageMakerRuntimeErrorValidation,
};
Expand All @@ -35,6 +37,10 @@ typedef NS_ENUM(NSInteger, AWSSageMakerRuntimeErrorType) {
@class AWSSageMakerRuntimeInvokeEndpointAsyncOutput;
@class AWSSageMakerRuntimeInvokeEndpointInput;
@class AWSSageMakerRuntimeInvokeEndpointOutput;
@class AWSSageMakerRuntimeInvokeEndpointWithResponseStreamInput;
@class AWSSageMakerRuntimeInvokeEndpointWithResponseStreamOutput;
@class AWSSageMakerRuntimePayloadPart;
@class AWSSageMakerRuntimeResponseStream;

/**

Expand All @@ -43,7 +49,7 @@ typedef NS_ENUM(NSInteger, AWSSageMakerRuntimeErrorType) {


/**
<p>The desired MIME type of the inference in the response.</p>
<p>The desired MIME type of the inference response from the model container.</p>
*/
@property (nonatomic, strong) NSString * _Nullable accept;

Expand All @@ -53,12 +59,12 @@ typedef NS_ENUM(NSInteger, AWSSageMakerRuntimeErrorType) {
@property (nonatomic, strong) NSString * _Nullable contentType;

/**
<p>Provides additional information about a request for an inference submitted to a model hosted at an Amazon SageMaker endpoint. The information is an opaque value that is forwarded verbatim. You could use this value, for example, to provide an ID that you can use to track a request or to provide other metadata that a service endpoint was programmed to process. The value must consist of no more than 1024 visible US-ASCII characters as 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 (HTTP/1.1). </p><p>The code in your model is responsible for setting or updating any custom attributes in the response. If your code does not set this value in the response, an empty value is returned. For example, if a custom attribute represents the trace ID, your model can prepend the custom attribute with <code>Trace ID</code>: in your post-processing function. </p><p>This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker Python SDK. </p>
<p>Provides additional information about a request for an inference submitted to a model hosted at an Amazon SageMaker endpoint. The information is an opaque value that is forwarded verbatim. You could use this value, for example, to provide an ID that you can use to track a request or to provide other metadata that a service endpoint was programmed to process. The value must consist of no more than 1024 visible US-ASCII characters as 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 (HTTP/1.1). </p><p>The code in your model is responsible for setting or updating any custom attributes in the response. If your code does not set this value in the response, an empty value is returned. For example, if a custom attribute represents the trace ID, your model can prepend the custom attribute with <code>Trace ID:</code> in your post-processing function. </p><p>This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker Python SDK. </p>
*/
@property (nonatomic, strong) NSString * _Nullable customAttributes;

/**
<p>The name of the endpoint that you specified when you created the endpoint using the <a href="https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateEndpoint.html"><code>CreateEndpoint</code></a> API.</p>
<p>The name of the endpoint that you specified when you created the endpoint using the <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/API_CreateEndpoint.html">CreateEndpoint</a> API.</p>
*/
@property (nonatomic, strong) NSString * _Nullable endpointName;

Expand Down Expand Up @@ -114,7 +120,7 @@ typedef NS_ENUM(NSInteger, AWSSageMakerRuntimeErrorType) {


/**
<p>The desired MIME type of the inference in the response.</p>
<p>The desired MIME type of the inference response from the model container.</p>
*/
@property (nonatomic, strong) NSString * _Nullable accept;

Expand All @@ -129,7 +135,7 @@ typedef NS_ENUM(NSInteger, AWSSageMakerRuntimeErrorType) {
@property (nonatomic, strong) NSString * _Nullable contentType;

/**
<p>Provides additional information about a request for an inference submitted to a model hosted at an Amazon SageMaker endpoint. The information is an opaque value that is forwarded verbatim. You could use this value, for example, to provide an ID that you can use to track a request or to provide other metadata that a service endpoint was programmed to process. The value must consist of no more than 1024 visible US-ASCII characters as specified in <a href="https://tools.ietf.org/html/rfc7230#section-3.2.6">Section 3.3.6. Field Value Components</a> of the Hypertext Transfer Protocol (HTTP/1.1). </p><p>The code in your model is responsible for setting or updating any custom attributes in the response. If your code does not set this value in the response, an empty value is returned. For example, if a custom attribute represents the trace ID, your model can prepend the custom attribute with <code>Trace ID:</code> in your post-processing function.</p><p>This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker Python SDK.</p>
<p>Provides additional information about a request for an inference submitted to a model hosted at an Amazon SageMaker endpoint. The information is an opaque value that is forwarded verbatim. You could use this value, for example, to provide an ID that you can use to track a request or to provide other metadata that a service endpoint was programmed to process. The value must consist of no more than 1024 visible US-ASCII characters as 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 (HTTP/1.1). </p><p>The code in your model is responsible for setting or updating any custom attributes in the response. If your code does not set this value in the response, an empty value is returned. For example, if a custom attribute represents the trace ID, your model can prepend the custom attribute with <code>Trace ID:</code> in your post-processing function. </p><p>This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker Python SDK. </p>
*/
@property (nonatomic, strong) NSString * _Nullable customAttributes;

Expand All @@ -139,10 +145,15 @@ typedef NS_ENUM(NSInteger, AWSSageMakerRuntimeErrorType) {
@property (nonatomic, strong) NSString * _Nullable enableExplanations;

/**
<p>The name of the endpoint that you specified when you created the endpoint using the <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/API_CreateEndpoint.html">CreateEndpoint</a> API. </p>
<p>The name of the endpoint that you specified when you created the endpoint using the <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/API_CreateEndpoint.html">CreateEndpoint</a> API.</p>
*/
@property (nonatomic, strong) NSString * _Nullable endpointName;

/**
<p>If the endpoint hosts one or more inference components, this parameter specifies the name of inference component to invoke.</p>
*/
@property (nonatomic, strong) NSString * _Nullable inferenceComponentName;

/**
<p>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 <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/model-monitor-data-capture.html">Capture Data</a>.</p>
*/
Expand Down Expand Up @@ -177,7 +188,7 @@ typedef NS_ENUM(NSInteger, AWSSageMakerRuntimeErrorType) {
@property (nonatomic, strong) NSData * _Nullable body;

/**
<p>The MIME type of the inference returned in the response body.</p>
<p>The MIME type of the inference returned from the model container.</p>
*/
@property (nonatomic, strong) NSString * _Nullable contentType;

Expand All @@ -193,4 +204,121 @@ typedef NS_ENUM(NSInteger, AWSSageMakerRuntimeErrorType) {

@end

/**

*/
@interface AWSSageMakerRuntimeInvokeEndpointWithResponseStreamInput : AWSRequest


/**
<p>The desired MIME type of the inference response from the model container.</p>
*/
@property (nonatomic, strong) NSString * _Nullable accept;

/**
<p>Provides input data, in the format specified in the <code>ContentType</code> request header. Amazon SageMaker passes all of the data in the body to the model. </p><p>For information about the format of the request body, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-inference.html">Common Data Formats-Inference</a>.</p>
*/
@property (nonatomic, strong) NSData * _Nullable body;

/**
<p>The MIME type of the input data in the request body.</p>
*/
@property (nonatomic, strong) NSString * _Nullable contentType;

/**
<p>Provides additional information about a request for an inference submitted to a model hosted at an Amazon SageMaker endpoint. The information is an opaque value that is forwarded verbatim. You could use this value, for example, to provide an ID that you can use to track a request or to provide other metadata that a service endpoint was programmed to process. The value must consist of no more than 1024 visible US-ASCII characters as 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 (HTTP/1.1). </p><p>The code in your model is responsible for setting or updating any custom attributes in the response. If your code does not set this value in the response, an empty value is returned. For example, if a custom attribute represents the trace ID, your model can prepend the custom attribute with <code>Trace ID:</code> in your post-processing function. </p><p>This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker Python SDK. </p>
*/
@property (nonatomic, strong) NSString * _Nullable customAttributes;

/**
<p>The name of the endpoint that you specified when you created the endpoint using the <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/API_CreateEndpoint.html">CreateEndpoint</a> API.</p>
*/
@property (nonatomic, strong) NSString * _Nullable endpointName;

/**
<p>If the endpoint hosts one or more inference components, this parameter specifies the name of inference component to invoke for a streaming response.</p>
*/
@property (nonatomic, strong) NSString * _Nullable inferenceComponentName;

/**
<p>An identifier that you assign to your request.</p>
*/
@property (nonatomic, strong) NSString * _Nullable inferenceId;

/**
<p>If the endpoint hosts multiple containers and is configured to use direct invocation, this parameter specifies the host name of the container to invoke.</p>
*/
@property (nonatomic, strong) NSString * _Nullable targetContainerHostname;

/**
<p>Specify the production variant to send the inference request to when invoking an endpoint that is running two or more variants. Note that this parameter overrides the default behavior for the endpoint, which is to distribute the invocation traffic based on the variant weights.</p><p>For information about how to use variant targeting to perform a/b testing, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/model-ab-testing.html">Test models in production</a></p>
*/
@property (nonatomic, strong) NSString * _Nullable targetVariant;

@end

/**

*/
@interface AWSSageMakerRuntimeInvokeEndpointWithResponseStreamOutput : AWSModel


/**
<p>A stream of payload parts. Each part contains a portion of the response for a streaming inference request.</p>
*/
@property (nonatomic, strong) AWSSageMakerRuntimeResponseStream * _Nullable body;

/**
<p>The MIME type of the inference returned from the model container.</p>
*/
@property (nonatomic, strong) NSString * _Nullable contentType;

/**
<p>Provides additional information in the response about the inference returned by a model hosted at an Amazon SageMaker endpoint. The information is an opaque value that is forwarded verbatim. You could use this value, for example, to return an ID received in the <code>CustomAttributes</code> header of a request or other metadata that a service endpoint was programmed to produce. The value must consist of no more than 1024 visible US-ASCII characters as specified in <a href="https://tools.ietf.org/html/rfc7230#section-3.2.6">Section 3.3.6. Field Value Components</a> of the Hypertext Transfer Protocol (HTTP/1.1). If the customer wants the custom attribute returned, the model must set the custom attribute to be included on the way back. </p><p>The code in your model is responsible for setting or updating any custom attributes in the response. If your code does not set this value in the response, an empty value is returned. For example, if a custom attribute represents the trace ID, your model can prepend the custom attribute with <code>Trace ID:</code> in your post-processing function.</p><p>This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker Python SDK.</p>
*/
@property (nonatomic, strong) NSString * _Nullable customAttributes;

/**
<p>Identifies the production variant that was invoked.</p>
*/
@property (nonatomic, strong) NSString * _Nullable invokedProductionVariant;

@end

/**
<p>A wrapper for pieces of the payload that's returned in response to a streaming inference request. A streaming inference response consists of one or more payload parts. </p>
*/
@interface AWSSageMakerRuntimePayloadPart : AWSModel


/**
<p>A blob that contains part of the response for your streaming inference request.</p>
*/
@property (nonatomic, strong) NSData * _Nullable bytes;

@end

/**
<p>A stream of payload parts. Each part contains a portion of the response for a streaming inference request.</p>
*/
@interface AWSSageMakerRuntimeResponseStream : AWSModel


/**
<p>The stream processing failed because of an unknown error, exception or failure. Try your request again.</p>
*/
@property (nonatomic, strong) _Nullable internalStreamFailure;

/**
<p> An error occurred while streaming the response body. This error can have the following error codes:</p><dl><dt>ModelInvocationTimeExceeded</dt><dd><p>The model failed to finish sending the response within the timeout period allowed by Amazon SageMaker.</p></dd><dt>StreamBroken</dt><dd><p>The Transmission Control Protocol (TCP) connection between the client and the model was reset or closed.</p></dd></dl>
*/
@property (nonatomic, strong) _Nullable modelStreamError;

/**
<p>A wrapper for pieces of the payload that's returned in response to a streaming inference request. A streaming inference response consists of one or more payload parts. </p>
*/
@property (nonatomic, strong) AWSSageMakerRuntimePayloadPart * _Nullable payloadPart;

@end

NS_ASSUME_NONNULL_END
78 changes: 78 additions & 0 deletions AWSSageMakerRuntime/AWSSageMakerRuntimeModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ + (NSDictionary *)JSONKeyPathsByPropertyKey {
@"customAttributes" : @"CustomAttributes",
@"enableExplanations" : @"EnableExplanations",
@"endpointName" : @"EndpointName",
@"inferenceComponentName" : @"InferenceComponentName",
@"inferenceId" : @"InferenceId",
@"targetContainerHostname" : @"TargetContainerHostname",
@"targetModel" : @"TargetModel",
Expand All @@ -94,3 +95,80 @@ + (NSDictionary *)JSONKeyPathsByPropertyKey {
}

@end

@implementation AWSSageMakerRuntimeInvokeEndpointWithResponseStreamInput

+ (BOOL)supportsSecureCoding {
return YES;
}

+ (NSDictionary *)JSONKeyPathsByPropertyKey {
return @{
@"accept" : @"Accept",
@"body" : @"Body",
@"contentType" : @"ContentType",
@"customAttributes" : @"CustomAttributes",
@"endpointName" : @"EndpointName",
@"inferenceComponentName" : @"InferenceComponentName",
@"inferenceId" : @"InferenceId",
@"targetContainerHostname" : @"TargetContainerHostname",
@"targetVariant" : @"TargetVariant",
};
}

@end

@implementation AWSSageMakerRuntimeInvokeEndpointWithResponseStreamOutput

+ (BOOL)supportsSecureCoding {
return YES;
}

+ (NSDictionary *)JSONKeyPathsByPropertyKey {
return @{
@"body" : @"Body",
@"contentType" : @"ContentType",
@"customAttributes" : @"CustomAttributes",
@"invokedProductionVariant" : @"InvokedProductionVariant",
};
}

+ (NSValueTransformer *)bodyJSONTransformer {
return [NSValueTransformer awsmtl_JSONDictionaryTransformerWithModelClass:[AWSSageMakerRuntimeResponseStream class]];
}

@end

@implementation AWSSageMakerRuntimePayloadPart

+ (BOOL)supportsSecureCoding {
return YES;
}

+ (NSDictionary *)JSONKeyPathsByPropertyKey {
return @{
@"bytes" : @"Bytes",
};
}

@end

@implementation AWSSageMakerRuntimeResponseStream

+ (BOOL)supportsSecureCoding {
return YES;
}

+ (NSDictionary *)JSONKeyPathsByPropertyKey {
return @{
@"internalStreamFailure" : @"InternalStreamFailure",
@"modelStreamError" : @"ModelStreamError",
@"payloadPart" : @"PayloadPart",
};
}

+ (NSValueTransformer *)payloadPartJSONTransformer {
return [NSValueTransformer awsmtl_JSONDictionaryTransformerWithModelClass:[AWSSageMakerRuntimePayloadPart class]];
}

@end
Loading
Loading