AWSSageMakerRuntime Class Reference

Inherits from AWSService : NSObject
Declared in AWSSageMakerRuntimeService.h
AWSSageMakerRuntimeService.m

Overview

The Amazon SageMaker runtime API.

  configuration

The service configuration used to instantiate this service client.

@property (nonatomic, strong, readonly) AWSServiceConfiguration *configuration

Discussion

Warning: Once the client is instantiated, do not modify the configuration object. It may cause unspecified behaviors.

Declared In

AWSSageMakerRuntimeService.h

+ defaultSageMakerRuntime

Returns the singleton service client. If the singleton object does not exist, the SDK instantiates the default service client with defaultServiceConfiguration from [AWSServiceManager defaultServiceManager]. The reference to this object is maintained by the SDK, and you do not need to retain it manually.

+ (instancetype)defaultSageMakerRuntime

Return Value

The default service client.

Discussion

For example, set the default service configuration in - application:didFinishLaunchingWithOptions:

Swift

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
    let configuration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: credentialProvider)
    AWSServiceManager.default().defaultServiceConfiguration = configuration

    return true
}

Objective-C

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
      AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
                                                                                                      identityPoolId:@"YourIdentityPoolId"];
      AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1
                                                                           credentialsProvider:credentialsProvider];
      [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;

      return YES;
  }

Then call the following to get the default service client:

Swift

 let SageMakerRuntime = AWSSageMakerRuntime.default()

Objective-C

 AWSSageMakerRuntime *SageMakerRuntime = [AWSSageMakerRuntime defaultSageMakerRuntime];

Declared In

AWSSageMakerRuntimeService.h

+ registerSageMakerRuntimeWithConfiguration:forKey:

Creates a service client with the given service configuration and registers it for the key.

+ (void)registerSageMakerRuntimeWithConfiguration:(AWSServiceConfiguration *)configuration forKey:(NSString *)key

Parameters

configuration

A service configuration object.

key

A string to identify the service client.

Discussion

For example, set the default service configuration in - application:didFinishLaunchingWithOptions:

Swift

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
    let configuration = AWSServiceConfiguration(region: .USWest2, credentialsProvider: credentialProvider)
    AWSSageMakerRuntime.register(with: configuration!, forKey: "USWest2SageMakerRuntime")

    return true
}

Objective-C

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
     AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
                                                                                                     identityPoolId:@"YourIdentityPoolId"];
     AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSWest2
                                                                          credentialsProvider:credentialsProvider];

     [AWSSageMakerRuntime registerSageMakerRuntimeWithConfiguration:configuration forKey:@"USWest2SageMakerRuntime"];

     return YES;
 }

Then call the following to get the service client:

Swift

 let SageMakerRuntime = AWSSageMakerRuntime(forKey: "USWest2SageMakerRuntime")

Objective-C

 AWSSageMakerRuntime *SageMakerRuntime = [AWSSageMakerRuntime SageMakerRuntimeForKey:@"USWest2SageMakerRuntime"];

Warning: After calling this method, do not modify the configuration object. It may cause unspecified behaviors.

Declared In

AWSSageMakerRuntimeService.h

+ SageMakerRuntimeForKey:

Retrieves the service client associated with the key. You need to call + registerSageMakerRuntimeWithConfiguration:forKey: before invoking this method.

+ (instancetype)SageMakerRuntimeForKey:(NSString *)key

Parameters

key

A string to identify the service client.

Return Value

An instance of the service client.

Discussion

For example, set the default service configuration in - application:didFinishLaunchingWithOptions:

Swift

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
    let configuration = AWSServiceConfiguration(region: .USWest2, credentialsProvider: credentialProvider)
    AWSSageMakerRuntime.register(with: configuration!, forKey: "USWest2SageMakerRuntime")

    return true
}

Objective-C

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
     AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
                                                                                                     identityPoolId:@"YourIdentityPoolId"];
     AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSWest2
                                                                          credentialsProvider:credentialsProvider];

     [AWSSageMakerRuntime registerSageMakerRuntimeWithConfiguration:configuration forKey:@"USWest2SageMakerRuntime"];

     return YES;
 }

Then call the following to get the service client:

Swift

 let SageMakerRuntime = AWSSageMakerRuntime(forKey: "USWest2SageMakerRuntime")

Objective-C

 AWSSageMakerRuntime *SageMakerRuntime = [AWSSageMakerRuntime SageMakerRuntimeForKey:@"USWest2SageMakerRuntime"];

Declared In

AWSSageMakerRuntimeService.h

+ removeSageMakerRuntimeForKey:

Removes the service client associated with the key and release it.

+ (void)removeSageMakerRuntimeForKey:(NSString *)key

Parameters

key

A string to identify the service client.

Discussion

Warning: Before calling this method, make sure no method is running on this client.

Declared In

AWSSageMakerRuntimeService.h

– invokeEndpoint:

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.

For an overview of Amazon SageMaker, see How It Works.

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.

Cals to InvokeEndpoint are authenticated by using AWS Signature Version 4. For information, see Authenticating Requests (AWS Signature Version 4) in the Amazon S3 API Reference.

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.

- (AWSTask<AWSSageMakerRuntimeInvokeEndpointOutput*> *)invokeEndpoint:(AWSSageMakerRuntimeInvokeEndpointInput *)request

Parameters

request

A container for the necessary parameters to execute the InvokeEndpoint service method.

Return Value

An instance of AWSTask. On successful execution, task.result will contain an instance of AWSSageMakerRuntimeInvokeEndpointOutput. On failed execution, task.error may contain an NSError with AWSSageMakerRuntimeErrorDomain domain and the following error code: AWSSageMakerRuntimeErrorInternalFailure, AWSSageMakerRuntimeErrorServiceUnavailable, AWSSageMakerRuntimeErrorValidation, AWSSageMakerRuntimeErrorModel.

Declared In

AWSSageMakerRuntimeService.h

– invokeEndpoint:completionHandler:

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.

For an overview of Amazon SageMaker, see How It Works.

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.

Cals to InvokeEndpoint are authenticated by using AWS Signature Version 4. For information, see Authenticating Requests (AWS Signature Version 4) in the Amazon S3 API Reference.

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.

- (void)invokeEndpoint:(AWSSageMakerRuntimeInvokeEndpointInput *)request completionHandler:(void ( ^ _Nullable ) ( AWSSageMakerRuntimeInvokeEndpointOutput *_Nullable response , NSError *_Nullable error ))completionHandler

Parameters

request

A container for the necessary parameters to execute the InvokeEndpoint service method.

completionHandler

The completion handler to call when the load request is complete. response - A response object, or nil if the request failed. error - An error object that indicates why the request failed, or nil if the request was successful. On failed execution, error may contain an NSError with AWSSageMakerRuntimeErrorDomain domain and the following error code: AWSSageMakerRuntimeErrorInternalFailure, AWSSageMakerRuntimeErrorServiceUnavailable, AWSSageMakerRuntimeErrorValidation, AWSSageMakerRuntimeErrorModel.

Declared In

AWSSageMakerRuntimeService.h