1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package sagemaker 4 5import ( 6 "context" 7 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 8 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 9 "github.com/aws/aws-sdk-go-v2/service/sagemaker/types" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// Starts a model compilation job. After the model has been compiled, Amazon 15// SageMaker saves the resulting model artifacts to an Amazon Simple Storage 16// Service (Amazon S3) bucket that you specify. If you choose to host your model 17// using Amazon SageMaker hosting services, you can use the resulting model 18// artifacts as part of the model. You can also use the artifacts with AWS IoT 19// Greengrass. In that case, deploy them as an ML resource. In the request body, 20// you provide the following: 21// 22// * A name for the compilation job 23// 24// * Information 25// about the input model artifacts 26// 27// * The output location for the compiled model 28// and the device (target) that the model runs on 29// 30// * The Amazon Resource Name (ARN) 31// of the IAM role that Amazon SageMaker assumes to perform the model compilation 32// job. 33// 34// You can also provide a Tag to track the model compilation job's resource 35// use and costs. The response body contains the CompilationJobArn for the compiled 36// job. To stop a model compilation job, use StopCompilationJob. To get information 37// about a particular model compilation job, use DescribeCompilationJob. To get 38// information about multiple model compilation jobs, use ListCompilationJobs. 39func (c *Client) CreateCompilationJob(ctx context.Context, params *CreateCompilationJobInput, optFns ...func(*Options)) (*CreateCompilationJobOutput, error) { 40 if params == nil { 41 params = &CreateCompilationJobInput{} 42 } 43 44 result, metadata, err := c.invokeOperation(ctx, "CreateCompilationJob", params, optFns, addOperationCreateCompilationJobMiddlewares) 45 if err != nil { 46 return nil, err 47 } 48 49 out := result.(*CreateCompilationJobOutput) 50 out.ResultMetadata = metadata 51 return out, nil 52} 53 54type CreateCompilationJobInput struct { 55 56 // A name for the model compilation job. The name must be unique within the AWS 57 // Region and within your AWS account. 58 // 59 // This member is required. 60 CompilationJobName *string 61 62 // Provides information about the location of input model artifacts, the name and 63 // shape of the expected data inputs, and the framework in which the model was 64 // trained. 65 // 66 // This member is required. 67 InputConfig *types.InputConfig 68 69 // Provides information about the output location for the compiled model and the 70 // target device the model runs on. 71 // 72 // This member is required. 73 OutputConfig *types.OutputConfig 74 75 // The Amazon Resource Name (ARN) of an IAM role that enables Amazon SageMaker to 76 // perform tasks on your behalf. During model compilation, Amazon SageMaker needs 77 // your permission to: 78 // 79 // * Read input data from an S3 bucket 80 // 81 // * Write model 82 // artifacts to an S3 bucket 83 // 84 // * Write logs to Amazon CloudWatch Logs 85 // 86 // * Publish 87 // metrics to Amazon CloudWatch 88 // 89 // You grant permissions for all of these tasks to an 90 // IAM role. To pass this role to Amazon SageMaker, the caller of this API must 91 // have the iam:PassRole permission. For more information, see Amazon SageMaker 92 // Roles. (https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-roles.html) 93 // 94 // This member is required. 95 RoleArn *string 96 97 // Specifies a limit to how long a model compilation job can run. When the job 98 // reaches the time limit, Amazon SageMaker ends the compilation job. Use this API 99 // to cap model training costs. 100 // 101 // This member is required. 102 StoppingCondition *types.StoppingCondition 103 104 // An array of key-value pairs. You can use tags to categorize your AWS resources 105 // in different ways, for example, by purpose, owner, or environment. For more 106 // information, see Tagging AWS Resources 107 // (https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html). 108 Tags []types.Tag 109} 110 111type CreateCompilationJobOutput struct { 112 113 // If the action is successful, the service sends back an HTTP 200 response. Amazon 114 // SageMaker returns the following data in JSON format: 115 // 116 // * CompilationJobArn: The 117 // Amazon Resource Name (ARN) of the compiled job. 118 // 119 // This member is required. 120 CompilationJobArn *string 121 122 // Metadata pertaining to the operation's result. 123 ResultMetadata middleware.Metadata 124} 125 126func addOperationCreateCompilationJobMiddlewares(stack *middleware.Stack, options Options) (err error) { 127 err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateCompilationJob{}, middleware.After) 128 if err != nil { 129 return err 130 } 131 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateCompilationJob{}, middleware.After) 132 if err != nil { 133 return err 134 } 135 if err = addSetLoggerMiddleware(stack, options); err != nil { 136 return err 137 } 138 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 139 return err 140 } 141 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 142 return err 143 } 144 if err = addResolveEndpointMiddleware(stack, options); err != nil { 145 return err 146 } 147 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 148 return err 149 } 150 if err = addRetryMiddlewares(stack, options); err != nil { 151 return err 152 } 153 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 154 return err 155 } 156 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 157 return err 158 } 159 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 160 return err 161 } 162 if err = addClientUserAgent(stack); err != nil { 163 return err 164 } 165 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 166 return err 167 } 168 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 169 return err 170 } 171 if err = addOpCreateCompilationJobValidationMiddleware(stack); err != nil { 172 return err 173 } 174 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateCompilationJob(options.Region), middleware.Before); err != nil { 175 return err 176 } 177 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 178 return err 179 } 180 if err = addResponseErrorMiddleware(stack); err != nil { 181 return err 182 } 183 if err = addRequestResponseLogging(stack, options); err != nil { 184 return err 185 } 186 return nil 187} 188 189func newServiceMetadataMiddleware_opCreateCompilationJob(region string) *awsmiddleware.RegisterServiceMetadata { 190 return &awsmiddleware.RegisterServiceMetadata{ 191 Region: region, 192 ServiceID: ServiceID, 193 SigningName: "sagemaker", 194 OperationName: "CreateCompilationJob", 195 } 196} 197